Author Topic: Core Wars  (Read 24047 times)

0 Members and 1 Guest are viewing this topic.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Core Wars
« on: February 28, 2012, 11:29:22 pm »
   A few days 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 the Core.  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!

Redcode:
   The programming language of The Core is called RedCode, and is like a simplified version of assembly.  There are only 18 possible instructions, but many different modifiers that make each instruction powerful.  The instructions are formatted in a very specific way that is consistant for all instructions:

Code: [Select]
NAME A B
NAME is the name of the instruction.  The name also indicates the type of instruction, and what it does.  The A and B field both hold numbers, and in general data passes from the A field into the B field.  The instructions are specifically:

Code: [Select]
DAT: If any process tries to execute a DAT command, that process is killed.  A and B field can be used to hold data.
MOV: Moves data from A into B
ADD: Adds A to B and stores the result into B
SUB: Subtracts A from B and stores the result into B
MUL: Multiplies A and B and stores the result into B
DIV: Divides B by A and stores the result into B
MOD: Divides B by A and stores the remainder into B
JMP: Moves program execution to location A (B is ignored)
JMZ: Jumps to location A if B is zero
JMN: Humps to location A if B is not zero
DJN: Decreases B and jumps to A if B is not zero
SPL: Starts a new process at location A
SEQ: Skips the next instruction if A and B are equal
SNE: Skips the next instruction if A and B are not equal
SLT: Skips the next instruction if A is less than B
NOP: Does nothing, guess you could use this to hold data as well.

There is more than these instructions, and A/B than is just told here, and there are some good tutorials that I will LINK to in order to help keep this post shorter, and to probably help better explain as well. 

One element I do want to cover though is the SPL instruction.  It says that it creates another process at location A, but what does that mean?  Processes in Redcode are handled a very specific way.  If you have two processes, each process will run twice as slow as if you only had one process.  In other words, creating new processes does not give you any more computing power.  If you had 3 processes and your opponent only has 1, then execution might look something like this:

Code: [Select]
Player 1 Process 1
Player 2 Process 1
Player 1 Process 2
Player 2 Process 1
Player 1 Process 3
Player 2 Process 1

As you can see, Player 2 was able to execute 3 instructions in his one process, while each of your processes were only able to execute a single instruction.

Conclusion/Plans:
  Now the game hasn't been completed yet, but I do have the majority of the instructions implemented, as well as an assembler and a working interpreter.  I will be updating the tutorial part of this thread as time goes on, but in the meantime feel free to visit This tutorial as well.  The syntax is slightly different since we don't have access to the same characters as they do, but I will be posting more on syntax in the future.  For now I will leave you with this screenie of what the game screen will look like!  It features the two program's names, as well as showing how many processes they currently have.  The square in the center is a visual representation of the Core, and shows how the programs move through and modify memory.  The two other squares are each programs private memory areas.

« Last Edit: March 15, 2012, 01:44:55 pm by Geekboy1011 »

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Core Wars
« Reply #1 on: February 29, 2012, 12:11:06 am »
I've neither played nor heard of the original, but this looks really interesting. :)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Core Wars
« Reply #2 on: March 01, 2012, 08:45:44 pm »
Update!  Both the assembler and the interpreter are complete!  Every command is functional and tested (hopefully) and programs can now compete successfully :) Now all that is left to do is to set up the UI, and start having wars!

Offline LincolnB

  • Check It Out Now
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1115
  • Rating: +125/-4
  • By Hackers For Hackers
    • View Profile
Re: Core Wars
« Reply #3 on: March 01, 2012, 09:59:48 pm »
Sweet! I read about this game in some book, and it sounded really awesome. Know what'd be cool? Setting this up over global Calcnet and battling fellow omni-and ceme-ians. :D
Completed Projects:
   >> Spacky Emprise   >> Spacky 2 - Beta   >> Fantastic Sam
   >> An Exercise In Futility   >> GeoCore

My Current Projects:

Projects in Development:
In Medias Res - Contest Entry

Talk to me if you need help with Axe coding.


Spoiler For Bragging Rights:
Not much yet, hopefully this section will grow soon with time (and more contests)



Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Core Wars
« Reply #4 on: March 01, 2012, 10:05:21 pm »
It's not played over the link port, so that would be a bit weird methinks :P The programmers write their programs separately, and then only need to get them onto the same calculator in order to run the competition.  I do hope that we can set up a competition though :D

Offline mrmprog

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 559
  • Rating: +35/-1
    • View Profile
Re: Core Wars
« Reply #5 on: March 01, 2012, 10:11:32 pm »
No way! Just recently I was considering starting something similar to this. I am glad you did though, you will do a much better job than I would have. This game has always intrigued me, and I am very happy to see it for calc.

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: Core Wars
« Reply #6 on: March 02, 2012, 02:31:24 am »
this is brilliant!
i can't wait to test it out against you folks

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: Core Wars
« Reply #7 on: March 02, 2012, 04:12:10 am »
Wow! The ingenuity of the original clearly looks translated to the calc version, man, I've never heard Core Wars but sound like quite a game I've never seen before. I'll see how I go as soon as it is available.
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Core Wars
« Reply #8 on: March 02, 2012, 12:30:45 pm »
Progress is still chugging along!  I found a bug or two in the interpreter involving post-incrementing on the A operator, and I'm working on fixing that now, as well as getting the UI up to speed.  Memkit is really helping a lot, and the UI should be finished relatively soon.  I will be adding options to provide different core sizes, as well as running multiple games back to back.

Offline Scipi

  • Omni Kitten Meow~ =^ω^=
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1547
  • Rating: +192/-3
  • Meow :3
    • View Profile
    • ScipiSoftware
Re: Core Wars
« Reply #9 on: March 02, 2012, 12:43:37 pm »
It's not played over the link port, so that would be a bit weird methinks :P The programmers write their programs separately, and then only need to get them onto the same calculator in order to run the competition.  I do hope that we can set up a competition though :D

You could probably set up multiplayer so that one calc serves as the host. And the client sends its code across to the host and the host runs the game with both codes.

Imma Cat! =^_^= :3 (It's an emoticon now!)
Spoiler For Things I find interesting:
Spoiler For AI Programming:
Spoiler For Shameless advertising:

Spoiler For OldSig:





Spoiler For IMPORTANT NEWS!:
Late last night, Quebec was invaded by a group calling themselves, "Omnimaga". Not much is known about these mysterious people except that they all carried calculators of some kind and they all seemed to converge on one house in particular. Experts estimate that the combined power of their fabled calculators is greater than all the worlds super computers put together. The group seems to be holding out in the home of a certain DJ_O, who the Omnimagians claim to be their founder. Such power has put the world at a standstill with everyone waiting to see what the Omnimagians will do...

Wait... This just in, the Omnimagians have sent the UN a list of demands that must be met or else the world will be "submitted to the wrath of Netham45's Lobster Army". Such demands include >9001 crates of peanuts, sacrificial blue lobsters, and a wide assortment of cherry flavored items. With such computing power stored in the hands of such people, we can only hope these demands are met.

In the wake of these events, we can only ask, Why? Why do these people make these demands, what caused them to gather, and what are their future plans...

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Core Wars
« Reply #10 on: March 02, 2012, 12:50:47 pm »
It would probably just be easier to send the program using the built in TiOS interface.  You would still be connecting via linkport, but you could disconnect as soon as the program was transferred.  No reason to force the users to be connected through the entire game when they only have to be connected to send the program, especially when it would add a whole bunch of unnecessary linking code.

Offline Spyro543

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1189
  • Rating: +74/-3
    • View Profile
Re: Core Wars
« Reply #11 on: March 02, 2012, 04:52:22 pm »
I think the coolest thing is the visual representation of the Core. Are all the on/off pixels bits of data that are equal to 1 or 0?

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Core Wars
« Reply #12 on: March 02, 2012, 04:58:25 pm »
Each pixel is a single instruction.  If the instruction is a DAT instruction the pixel is white, and black otherwise. 

Offline Spyro543

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1189
  • Rating: +74/-3
    • View Profile
Re: Core Wars
« Reply #13 on: March 02, 2012, 05:02:50 pm »
That's cool! Will you have an animated screenshot soon?

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Core Wars
« Reply #14 on: March 02, 2012, 05:08:29 pm »
Very soon!  I'm currently working on getting all of the UI elements coded, and after that is done there should be many screenshots to be had ^^