A few weeks ago a friend in my math class introduced me to the game Core Wars, and I immediately decided to port it to the calculator! Core Wars is a two player competitive game, featuring a unique type of gameplay. The two contestants must each write a program in Redcode, which is the programming language of this game. Each program is then inserted into a section of memory called the Core. If either program stops executing, that player loses. Of course it is simple to make a program that never terminates when left on its own, the tricky part is that both programs live in the same memory (the Core) and so can influence each other. The programs must try to find their opposing program and sabotage and destroy it in order to halt it's execution. It's the greatest battle of a programmers ingenuity, as they pit their own programs to destroy others in The Core!

The language RedCode is assembly-line in nature, and features a very small set of instructions. These instructions do, however, have a fair number of variations due to different addressing modes for different arguments, and different modes for each of the instructions. I have detailed some of the syntax changes in the Readme, but for a detailed tutorial on the basics of Redcode, you can check out This online page. Some of the more notable features of Redcode are relative addressing, as well as a circularly mapped memory for the Core.

You can download the Core Wars app and other files Here, although note that this is the first version, and since the app contains both an assembler and an interpreter for Redcode, there is likely going to be a bug or two that I didn't catch Smile Nevertheless, feel free to try it out! The app also comes with a built-in debugger so you can test your programs in a less hostile environment.

I had heard of this game, so I'm very impressed that you're porting it to our dear calculators. You certainly seem to have put a lot of stuff together in "a few days." It looks to me as if you always play against a human opponent in this version; is that accurate? Or do you also have "AI" programs to try to defeat?
Ah, I pulled that opening text from my original post on Omnimaga, which was posted about two weeks ago, so I have been working on it for a bit longer than a few days, although it is still by no means a large project. Should be all fixed now!

And indeed you can only play against human opponents, and I don't have any plans of introducing an AI either. Since both programs are created before the battle begins, if the AI contained no random elements it would always generate the same program anyway! And even if I did introduce some sort of variability, it would amount to a program to write programs Razz However, I do think that I will release a few programs along with the final pack for the user to test themselves against. Currently the only program released alongside is BOMB, which is extremely simplistic and easy to beat. Perhaps the community can band together and compete to create some particularly difficult programs to be included in later versions Smile
Just a small update now that I have two neat example programs built. The first is a Warrior called copy. It first copies itself to a new location and starts a new process there, and then proceeds to start clearing the memory in front of it. It is hopefully both resilient because it has many processes, and hopefuly lethal since it is attacking a large percentage of the core.


Code:
:*ORG CPY
Lbl CPY
 MOV )X }X
 JMN CPY X
 NOP (69 {69
 SPL 61
 ADD e2 X
Lbl CLR
 MOV X (X
 JMP CLR
Lbl X
 DAT e73 e9


And here is a different version of the original bomber that instead of bombing with DAT instructions, bombs with SPL 0 instructions, causing your opponent to create unlimited numbers of subroutines, thus preventing them from functioning normally. After you finish bombing, your opponent should be subdued, so the program enters the 'clear' mode, where it goes through and clears every instruction until its opponent is dead


Code:
:*ORG TOP
Lbl TOP
 MOV S /S
 ADD e4 S
 JMN TOP S
Lbl CLR
 MOV D (D
 JMP CLR
Lbl S
 SPL 0 e8
Lbl D
 DAT e0 e2


And Here is the source, as well as a screenshot of them doing battle! Scan won that round, and as you can see, as soon as the Split Bombs hit the other program, all movement completely stopped and it's processes completely maxed out!

Ah, I see that each player can have at most 64 processes? What happens if the SPL opcode executes and the processes are already maxed out, does it just execute as a no-op?
Correct after you have the max number of processes SPL acts exactly like a NOP
geekboy1011 wrote:
Correct after you have the max number of processes SPL acts exactly like a NOP
Hmm, I'll definitely have to try this out when it gets released. In a way I wish there could be a version that would run natively on the calculator, and be able to break out and affect the actual memory of the calculator, but that of course would be a rather risky version.
I would think executing two different programs at the same time would be rather tricky right? Not to mention aren't there commands in z80 that can fill large sections of memory with a single command? I think it would definitely be a much different game, and quite tricky to write at that o.O

Oh, and it has been released, there is a download in the original post Smile
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement