Sim Town

Original Sim Town ingame screen

Newer colour version achieved thanks to further space saving of BASIC code (see below).

Program listing on 48K Spectrum

Greatly improved listing saving a further 37 characters from the previous version. Thanks to Einar Saukas for the space saving suggestions. (Notes at bottom).

Final listing, using the freed up space to implement colour and an island. Further thanks to Einar Saukas for the island drawing code. The listing is now exactly the maximum number of bytes permitted in the competition.

Text Listing (Final Colour Version)

1 DEF FN v(o$)=2*(o$="r")+3*(o$="c")+4*(o$="i")+5*(o$="e"):
 DIM a(5):
 READ x,y,m,p,d,s:
 FOR e=0 TO m:
 PRINT PAPER 6-e/m, PAPER 5;"  ":
 NEXT e:
 FOR e=1900 TO 2e3 STEP .1:
 LET x=x+(k$="p")*(x<15)-(k$="o")*(x>0):
 LET y=y+(k$="a")*(y<10)-(k$="q")*(y>0):
 LET c$=SCREEN$ (y,x):
 LET c=(m>0)*(c$=" ")*FN v(k$):
 FOR r=1 TO c>0:
 LET a(c)=a(c)+1/(7-c):
 LET s=0:
 FOR i=2 TO 5:
 LET s=s+a(i):
 NEXT i:
 LET d=0:
 FOR i=2 TO 5:
 LET d=d+ABS (a(i)-s/4):
 NEXT i:
 NEXT r:
 LET p=p+s*(a(5)>0)*(.5-d):
 LET p=(p>0)*p:
 LET m=m-c+((p>20)+INT (p/100))*(e-INT e<.1):
 LET c$=(k$ AND c)+(c$ AND c=0):
 PRINT AT y,x;"+";AT 0,24;INT e;AT 2,24;"$";m,AT 4,24;"P";INT p,AT y,x; PAPER 6-FN v(c$);c$:
 NEXT e:
 DATA 9,9,20,0,1,0

Download the game

About the game

This town building simulation runs from the year 1900 through to 2000. The object of the game is to achieve a highest town population as possible by the year 2000.

Key, showing in-game features.

Rules of the Game

If you can't make any progress in the game then some hints are in the following box. (Drag mouse over to reveal hidden text):-

To start off with, build one electricity generating plant, one industrial zone, one commercial zone, and two residential zones. After a few years, some tax will start to be collected. Once your funds are again up to around $10-$20 million or so start expanding further (add an extra commercial zone for example). Add a few more various buildings of different types. If the town goes out of balance (population starts declining), then try to make up for it by building something different. As a rule, more residental areas are needed than commercial zones, which are needed more than industrial zones, which are needed more than electricty plants.

Hall of Fame
The following high scores have been submitted
Einar Saukas achieved a population of 2,980 (2,980,000) on 11th August 2007
Digital Prawn achieved a population of 503 (503,000) on 27th July 2007

To submit a score to the hall of fame, please send a PM to "Digital Prawn" on the "World of Spectrum" Forums.

Development notes

Out of all the oneliners I've submitted so far, this is the one I had to "chop back" the most in order to get it to fit into the single screen BASIC listing limit. First version of the game was over-ambitious and featured a full colour game world. First thing to be chopped out was the colour. The game also started off with an island surrounded by sea, and you could reclaim land, and extend the island out into the sea. This feature also had to be removed. Finally, the ability to demolish buildings had to be removed, as it complicated the working out of the "town balance" calculations. Removing that feature saved a lot more space. So the final game is much reduced from how I originally envisioned it, but it is a working (albeit incredibly simplistic) town sim game within one line/one screen of code.

In game screen from aborted first version, which was too big to enter in the oneliner competition. It featured an island, and sea that could be converted to land.

Thanks again to Einar Saukas specifically for his following work on this program on 10-11/08/07:-

Used a comma to erase characters up to end of line, and dispensed with b$ variable altogether.
Changed "2000" to "2e3"
Removed excess parenthesis
Also noticed that
LET p=p+s*(a(5)>0)*(.5-d-(a(5)=0))
is logically equivalent to
LET p=p+s*(a(5)>0)*(.5-d)
Wrote compact island drawing code

Back to Sinclair stuff index