The Space Tyrant Source Code
|The Space Tyrant source code is written in C and compiles with every recent GCC compiler I've tried on both Linux and Mac OS X. It should be pretty easy to port the code to other Unices as well. |
The Source Code: st.c (Linux and Mac)Just download the source file, save it as st.c, and then compile it as follows:
sh st.cThe compile script is embedded at the top of the source file so the above command is all you have to do to build your own binary.
This source file is preconfigured to produce a 100,000 sector universe. That is easy enough to modify -- but you'll have to edit the source file. To do so, find the #define statements that set GAMESIZE and DBLOCK. Comment out the pair that sets GAMESIZE to 100000 and DBLOCK to 100 and uncomment another pair. Then, compile it again for a smaller or a larger game universe.
Unless you are a C programmer, that is proabably all you'll want to do to it at first. I'd recommend you run it with the default settings for a game or two so you appreciate just how big a game you would like.
Once you have a binary, type the following command in the directory with the binary to initialize the system and start the first game:
./st 9999Note that the '9999' number refers to the network port the game will listen on for connections.
Type `telnet localhost 9999` to connect -- the first player to register in a newly initialized game becomes the administrator of the system -- so make sure you are the first to log in!
A few features of the code:
ST is 100% C code (the embedded shell script, mentioned above, is technically a C comment ;). It is a single source file that is:
The ST code also includes:
- a Unix daemon
- an example of POSIX thread programming
- a network server using TCP sockets
- a memory based daemon with an asynchronous dirty block disk backup thread
The code is less than 4500 C source statements in length. Including comments and C statements that span multiple lines, the source file is under 9500 lines long.
- an easily understandable recursive sort
- a function pointer array
- ring buffer message queues
- random number generator macros
- detached thread spawning and reaping routines
- signal processing routines (interrupt handlers)
- a shortest-path algorithm
Space Tyrant is released under the terms of the GPL Version 2.
|mail this link | -Ray, March 6, 2007 (Updated: March 12, 2007)|
Linux System Administration: Linux Applications
(Contact: r00t at this domain)
© 2008-2012, Ray Yeargin