home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software of the Month Club 1995 March
/
SOFM_Mar1995.bin
/
pc
/
sri
/
kids
/
corewars.280
/
corewars.doc
< prev
next >
Wrap
Text File
|
1995-01-27
|
14KB
|
363 lines
COREWARS (Revision 2.80) Page 1 of 7
Copyright (c) Triskelian Simulations 1990.
Program: COREWARS
Revision: 2.80
Date: 24 August 1991
COREWARS (just a little light reading)
======================================
The enclosed files are released (again) into the public domain.
The original program I found was written by Kevin A. Bjorke in
May 1984. Mr.Bjorke's version was targeted at Unix machines and
used the Small-C dialect.
The program itself is based on several Scientific American
"Computer Recreations" articles written by A.K.Dewdney. These
articles appeared in the May 1984, March 1985, and January 1987
issues. Check these articles at your local library for the gory
details.
Mr.Dewdney also describes COREWARS in his book, "The Armchair
Universe: An exploration of Computer Worlds", W.H.Freeman and
Company, New York, 1988.
So What IS "COREWARS"?
======================
The idea behind COREWARS is that two mutually antagonistic
programs are loaded into the memory of a hypothetical machine.
The two programs then try to obliterate each other. They may
shoot at each other, roll over one another, whatever. The first
program to crash and burn, or to start executing the other
program's code, LOSES.
COREWARS v2.80
==============
This program (COREWARS) plays the part of the hypothetical
machine and referee. There are a few additions and enhancements
added to this version. (How's that for understatement?)
This program supports up to eight initial programs. Each program
may spawn as many other programs (called tasks, just to be
obnoxious) as it wants, up to a user specified per program and
per system limit (currently 255). Each program is loaded
starting at a random location (this version supports either
random or fixed starting locations, that's up to you).
Speaking of memory, this version provides two different methods
of defining memory range. You may select the overall memory
COREWARS (Revision 2.80) Page 2 of 7
Copyright (c) Triskelian Simulations 1990.
size, from 500 to 8000 locations. You may also set the
addressing range, from 1/32 to the entire available memory range.
You may specify the number of instructions per cycle, i.e. how
many instructions each task may execute sequentially before
another task gets to execute. The original COREWARS used a 1:1
ratio. This version allows any ratio up to 64:1.
You may also specify the task scheduling method used. By default
this version will use a task number based round robin scheduler.
This means it just goes from task to task in sequential numeric
order (e.g. 1,2,3,etc.). As Dewdney points out, this can give an
undo advantage to "rabbit" programs. This is the NUMERIC
scheduling option.
The two alternative scheduling methods are PROGRAM and
INTERLEAVE. Program is blatantly unfair, but interesting for
comparison purposes. This scheduling approach runs all of each
programs tasks as a single clump, before proceeding to the next
program (e.g. A1,A2,A3,B1,B2,C1, etc.). By contrast, the
INTERLEAVE scheduler attempts to mix tasks from each of the
original programs (e.g. A1,B1,C1,A2,B2,C1,A1,B3,C1,etc.).
The display is peculiar to this particular COREWARS incarnation.
You may specify which, if any, program is to be displayed. You
may select detailed display, which will also display the
effective addresses for each instruction as they are resolved.
The instruction steps are displayed on the right hand side of the
runtime display screen. The particular program and display mode
are displayed at the top of the screen.
COREWARS statistics are displayed on the lefthand side of the
screen. The current cycle, slice (instruction within a cycle),
active task, total instruction count, and free memory information
are continually displayed. Below this is a table detailing the
current status for each active program (all task information is
reflected under the appropriate parent program). This area is
continually updated in conjunction with the program instruction
display. The statistics display will also be automatically
updated every 100 cycles.
You can single step execution OF THE DISPLAYED PROGRAM ONLY.
Press "S" each time you want to single step the next instruction
of the program being displayed. The breakpoint occurs AFTER the
execution of the instruction. The breakpoint will not be reached
if the current instruction causes the battle program to die.
When the COREWARS programs are running you may pause the program
by pressing "P". You can abort the combat by pressing [ESCAPE].
COREWARS (Revision 2.80) Page 3 of 7
Copyright (c) Triskelian Simulations 1990.
"REDCODE"
=========
Core Wars uses a machine language-like instruction set called
"REDCODE". The table below shows the basic instruction formats
and their addressing modes. Programs must be terminated by the
pseudo-instruction END (no arguments). Note that the
instructions [DJN, PCT, SPL, SWP] are all extensions to the
original REDCODE instruction set.
Description Instruction Notes
----------------------------------- ----------- -----
Add A to B ADD A B
Compare A to B, skip next loc if != CMP A B
Data DAT B
Decrement B, jump to A if nonzero DJN A B 1
Decrement B, jump to A if zero DJZ A B 1
Jump to A if B is > zero JMG A B
Jump to A JMP A
Jump to A if B is zero JMZ A B
Move A to B MOV A B
Protect PCT A 2
Split (spawn task) SPL A 2
Subtract A from B SUB A B
Swap contents of A and B SWP A B 3
Addressing modes: IMMEDIATE #n
DIRECT n
INDIRECT @n
Notes:
1) As has been pointed out, these were confused in
A.K.Dewdney's original discussions. I have chosen the
coward's solution: implement both.
2) These are extensions proposed by Dewdney.
3) This was added for amusement value. Neither argument may
be immediate.
COREWARS (Revision 2.80) Page 4 of 7
Copyright (c) Triskelian Simulations 1990.
This is not the place to describe what assembly language
programming is all about. People have written entire books on
the subject. (Then again, people have written entire books on
the mating habits of frogs.) The original Scientific American
articles contain a good overview and list some useful references
for further reading.
SAMPLE PROGRAMS
===============
Some sample REDCODE programs have been included. All of the
sample programs are in files with an *.WAR extension. Many of
these programs are taken directly from the magazine articles and
discussed there in some detail. Two programs, A_IMP and AA_IMP,
were borrowed from R.Sawyer. DDWARF and IMPACT were added just
to keep everything interesting.
New combatants:
IMPGUN2, comes from D.Sharpe.
MORTAR, is inspired by Michael L. Mauldin.
MORTAR2, is my own MORTAR variant.
TRAPDWARF, is inspired by Stephen Peters and Mark A. Durham.
Filename Description
-------- -----------
CHANG1 A sample sophisticated program using SPL
DWARF A simple attack program, step of 5
DWARF7 Same as DWARF, step of 7
DWARF13 Same as DWARF, step of 13
DWARF29 Same as DWARF, but hits every 29th
DDWARF DWARF modified to cope with PCT instruction
MORTAR Like DWARF, but using a Fibonacci sequence
MORTAR2 A variant of MORTAR, using PCT also
TRAPDWARF An anti-DWARF program
GEMINI A self-cloning program (offset 100)
BIGFOOT A GEMINI clone using a large prime number offset
JUGGER "JUGGERNAUT", a GEMINI clone that rolls through memory
IMP Core Wars' answer to the tortoise
IMPGUN An IMP deringer (i.e. 2 shot)
IMPGUN2 An IMP generator
IMPSTOMP Defensive Anti-IMP program
IMPACT IMPSTOMP using PCT instruction
A_IMP Anti-IMP program
AA_IMP Anti-Anti-IMP program
COREWARS (Revision 2.80) Page 5 of 7
Copyright (c) Triskelian Simulations 1990.
REVISION HISTORY
================
"There I was, basking in the egocentric glow of COREWARS
v2.22. And then I spotted D.Sharpe's COREWARS 3.0 on a local
BBS! OK, so this particular programmer has a wee bit of ego.
I'll just add one or two things..."
That was a year ago. I have no excuse for all the time I spent
on it this year. <grin>
Version 2.70
-------------
1. Implement SPL instruction.
2. Correct detailed display for newer REDCODE instructions.
3. Add single step option.
4. Allow user to select task scheduling algorithm. Only round
robin scheduling is currently implemented.
Version 2.60
-------------
1. Corrected overflow error in ADD/SUB instructions.
Version 2.50
------------
1. Change user runtime display.
2. Allow user interaction with runtime operation.
3. Allow user to enter up to eight initial programs.
4. Add MORTAR and MORTAR2 *.WAR programs.
Version 2.40
------------
1. Add printer dumps.
2. Allow user to specify multiple memory ranges on display/dumps.
3. Add DJN and SWP instructions.
4. Add hooks to support SPL instruction in future release.
It is currently processed as a "NOP".
5. Add memory "fuelgauge", numeric indicator of memory ownership.
6. Allow user to save REDCODE programs to disk.
Version 2.30
------------
1. Add more sample programs.
2. Standardize documentation with other Triskelian Simulation
products.
3. Internal code cleanup.
Version 2.22
------------
1. Selectable instruction addressing range.
COREWARS (Revision 2.80) Page 6 of 7
Copyright (c) Triskelian Simulations 1990.
Version 2.21
------------
1. Show user why *.WAR file input aborted and recover.
2. Trap user null programs and recover.
Version 2.20
------------
1. Added PCT instruction.
2. Detect program subversion (IMP problem).
3. User interrupt of memory dump (hit [ESCAPE]).
4. Add flags (MemA, MemB, PROTECT) to memory dump.
5. Cosmetic changes to execution display.
Version 2.11
------------
1. Selectable CPU slice (instructions per cycle).
2. Added numerous *.WAR files.
Version 2.10
------------
1. Use the *.WAR extension (borrowed from R.Sawyer).
2. Semicolon comments in *.WAR files.
3. Selectable maximum memory size.
4. Selectable starting locations.
5. Options to suppress execution outputs.
6. Flags to support memory displays, PCT, etc..
7. A_IMP.WAR & AA_IMP.WAR (borrowed from R.Sawyer).
Version 2.00
------------
1. Upgrade COREWARS Small-C to Turbo-C, ANSI, etc.
FOR MORE INFORMATION
====================
Contact the following people for further information about
COREWARS. Please note this information is several years old and
therefore rather suspect.
International Core Wars Society
and/or
The Core Wars Newsletter
William R. Buckley
5712 Kern Drive
Huntington Beach, CA 92649
A.K.Dewdney
c/o The Editors
Scientific American
415 Madison Avenue
New York, NY 10017
COREWARS (Revision 2.80) Page 7 of 7
Copyright (c) Triskelian Simulations 1990.
NONE OF THE ABOVE (obviously)
=============================
COREWARS requires ANSI.SYS support to run normally. If you start
seeing things like "[4;H" or "[35m" popping up on your screen --
DON'T PANIC. Just add a line like "DEVICE=ANSI.SYS" to your
CONFIG.SYS file. Pertinent details can be found in your (or
anybody else's) DOS manual.
This program is hereby released to the PUBLIC DOMAIN. No copies
or derivatives of this product may be distributed for profit or
personal gain. A minimal handling fee may be charged for
distribution.
COREWARS and any associated files and documentation are
distributed without any express or implied warranties.
Triskelian Simulations does not warrant that COREWARS or any
associated files operate as claimed. You the user assume full
risk for any direct or consequential damages, even if Triskelian
Simulations has been advised of the possibility of any damages.
By using this program you agree to abide by the terms and
conditions stated above.
If all else fails, contact Triskelian Simulations on our local
support bulletin board: TECHLINE BBS (206)532-9220. We are
probably more confused than you are, but we will try and help.
One final parting shot, er, note. I would like to thank Richard
Edwards for nagging me so much about COREWARS that I spiffied the
thing up just to make him go away. Actually, it was a blast.
David E. Thomas
Triskelian Simulations
630 Washington
Hoquiam, WA 98550
FIDOnet (1:352/30.3)