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 k$=INKEY$:
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
-
All buildings are placed on the town by first moving the 'game cursor' to the desired location and then pressing a key to build it.
-
Keys are as follows:-
'q','a','o','p' - move the game cursor around the screen
'r' - build a residential block
'c' - build a commercial block
'i' - build an industrial block
'e' - build an electricity generating power plant
-
Buildings cost the following:-
residential block - 2 million dollars
commerical block - 3 million dollars
industrial block - 4 million dollars
electricity generating plant - 5 million dollars
-
You start the game with a budget of 20 million dollars. If/when your funds get down to zero (or sometimes a few million dollars below zero), then you can no longer build anything. In that case then you can only build again when your funds have recovered.
-
Funds are generated through tax. Tax is at a fixed level and is only collected once the town population exceeds 20,000.
After this point, Tax is collected in proportion to the population of the town. i.e. higher population leads to more tax collected , which in turn leads to more funds available for building.
-
Population will only increase if you have (a) at least one electricity generating station, and (b) the town is "balanced" in terms of having residential, commercial, industrial and electricity plants in reasonable proportions. If the town goes out of balance (too much industry or not enough housing for example), then the population will cease to expand, and may even fall.
But overall, for a correctly balanced town, more buildings will generate greater population increases. So in the long run, increasing the total number of buildings in the town will give the player a higher final score.
-
If you get to the point where all your funds are exhausted, and everyone has fled the town (Population 0), then the game is unwinnable from that position, might as well restart and try again. (Can break out with shift-space, and RUN it again).
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