! Hamurabi Game. ! 10/08/92 ! EQU CTRLX TO 24, ESCAPE TO 27, BSPCE TO 8, RETRN TO 13 EQU AM TO CHAR(254), VM TO CHAR(253), BELL TO CHAR(7) ECHO OFF BREAK OFF USERID = FIELD(OCONV(OCONV(0, 'U50BB'), 'MCU'), ' ', 3) IF INDEX(USERID, '&', 1) # 0 THEN USERID = OCONV(USERID, 'G1&1') USERNAME = USERID OPEN 'STAFF' THEN ATTR = 2 OPEN 'DICT', 'STAFF' THEN READV ATTR FROM 'NAME', 2 THEN NULL USERNAME = OCONV(USERID, 'TSTAFF;C;;':ATTR:';':ATTR) END LOOP CRT @(-1) : '"HAMURABI"' CRT CRT FIELD(USERNAME, ' ', 1): CRT ', try your hand at governing ancient Sumeria' CRT 'for a ten year term of office.' CRT CRT 'Do you want some help ? ': XIT = 0 LOOP IN KBD KBD = OCONV(CHAR(KBD), 'MCU') IF KBD = 'Y' OR KBD = 'N' THEN CRT KBD XIT = 1 END ELSE CRT BELL: END UNTIL XIT DO REPEAT IF KBD = 'Y' THEN CRT @(-1) : '"HAMURABI"' CRT CRT 'The object of this game is to govern ancient Sumeria for a ten' CRT 'year term of office, during which time you should;' CRT CRT 'a. Gain a modest increase in wealth, measured in land and' CRT ' grain. This is achieved by buying land for grain, when' CRT ' the price is low, and only selling when necessary and the' CRT ' price is high. Twenty-one bushels per acre is an average' CRT ' price. To sell land, enter "0" to amount to buy.' CRT CRT 'b. Provide enough food for your people that none die.' CRT ' Extra food, over and above the basics will yield some' CRT ' increase in productivity, but an excess of food will lead' CRT ' to waste. Ten bushels per person is usually enough food' CRT ' for subsistence, but more will be done on fourteen.' CRT CRT 'c. Plant your land with grain to yield a crop for the next' CRT ' year, supplies. Obviously, you can only plant up to as' CRT ' much land as you own, with as much grain as is left after' CRT ' trading land and feeding the people. Also, you need' CRT ' healthy people to till the land and produce a good yield.' CRT ' Half a bushel per acre is required for planting.' CRT CRT 'Press any key to continue .... ': IN KBD END VITA = 20 YEAR = 0 POPU = 95 STOR = 2800 RATS = 200 ACRE = 1000 BUSH = 3 HARV = ACRE * BUSH INCR = 5 PLAG = 1 QUIT = 0 START = 0 NODEAD = 1 TOTDEAD = 0 TOTPERC = 0 LOOP UNTIL YEAR > 10 OR QUIT DO IF NODEAD THEN DEAD = 0 YEAR = YEAR + 1 POPU = POPU + INCR COST = RND(10) + 17 COSTREF = COST IF YEAR = 1 THEN START = ACRE * COST + STOR CRT @(-1) : 'Hamurabi, I beg to report to you;' CRT 'In year ' : YEAR : ', ' : DEAD : ' people starved, ' : INCR: IF INCR < 0 THEN CRT ' left the city.' END ELSE CRT ' came to the city.' END IF PLAG < 0 THEN POPU = INT(POPU / 2) CRT 'A horrible plague struck ! Half the people died.' END CRT 'The population is now ' : POPU : '.' CRT 'The city now owns ' : ACRE : ' acres.' CRT 'You harvested ' : BUSH : ' bushels per acre.' CRT 'Rats ate ' : RATS : ' bushels.' CRT 'You now have ' : STOR : ' bushels in store.' CRT CRT 'Land is trading at ' : COST : ' bushels per acre.' CRT 'Your total wealth stands at ' : STOR + ACRE * COST : ' bushels.' IF YEAR < 11 THEN LOOP OK = 0 LOOP CRT 'How many acres do you wish to buy ? ': GOSUB 100 WHILE CMD = 'REPEAT' DO REPEAT BUY = CMD IF BUY < 0 OR COST * BUY LE STOR THEN OK = 1 END ELSE CRT 'Hamurabi, think again ! You have only ' : STOR: CRT ' bushels of grain.' CRT 'Now then, ': END UNTIL OK DO REPEAT IF BUY # 0 THEN ACRE = ACRE + BUY STOR = STOR - COST * BUY DECR = -INT(COST / 4) END ELSE LOOP OK = 0 LOOP CRT 'How many acres do you wish to sell ? ': GOSUB 100 WHILE CMD = 'REPEAT' DO REPEAT SELL = CMD IF SELL < 0 OR SELL < ACRE THEN OK = 1 END ELSE CRT 'Hamurabi, think again ! You only own ' : ACRE: ' acres.' CRT 'Now then, ': END UNTIL OK DO REPEAT ACRE = ACRE - SELL STOR = STOR + COST * SELL DECR = INT(COST / 2) END CRT LOOP OK = 0 LOOP CRT 'How many bushels do you wish to feed your people ? ': GOSUB 100 WHILE CMD = 'REPEAT' DO REPEAT FEED = CMD IF FEED < 0 OR FEED LE STOR THEN OK = 1 END ELSE CRT 'Hamurabi, think again ! You have only ' : STOR: CRT ' bushels of grain.' CRT 'Now then, ': END UNTIL OK DO REPEAT CRT STOR = STOR - FEED FEED = FEED / POPU IF FEED > 20 THEN FEED = EXP((2 * LN(FEED) + LN(20)) / 3) END VITA = (VITA + FEED) / 2 ERR1 = 0 ERR2 = 0 PLANT = ACRE IF PLANT > 2 * STOR THEN PLANT = 2 * STOR ERR1 = 1 END CHK = INT(VITA * POPU / 2) IF PLANT > CHK THEN PLANT = CHK ERR2 = 1 END BEGIN CASE CASE ERR1 CRT 'You are short of grain. ': CRT 'You may only plant ' : PLANT : ' acres.' CASE ERR2 CRT 'Your people cannot plant all your land. ' CRT 'You may only plant ' : PLANT : ' acres.' CASE 1 CRT 'You may plant all ' : PLANT : ' acres.' END CASE LOOP OK = 0 LOOP CRT 'How many acres do you wish to plant ? ': GOSUB 100 WHILE CMD = 'REPEAT' DO REPEAT PLANT = CMD BEGIN CASE CASE PLANT LE 0 OK = 1 CASE PLANT LE ACRE IF INT(PLANT / 2) LE STOR THEN IF PLANT LE VITA * POPU / 2 THEN OK = 1 END ELSE CRT 'But you have only ' : POPU: CRT ' people to tend the fields !' CRT 'Now then, ': END END ELSE CRT 'Hamurabi, think again ! You have only ' : STOR: CRT ' bushels of grain.' CRT 'Now then, ': END CASE 1 CRT 'Hamurabi, think again ! You only own ' : ACRE : ' acres.' CRT 'Now then, ': END CASE UNTIL OK DO REPEAT STOR = STOR - INT(PLANT / 2) BUSH = INT((VITA / 10) * (RND(5) + 1)) HARV = PLANT * BUSH RATS = 0 IF RND(2) = 0 THEN RATS = INT(STOR / (RND(5) + 1)) STOR = STOR - RATS + HARV INCR = INT((RND(5) + 1) * (20 * ACRE + STOR) / POPU / 100 + 1) INCR = INCR - INT(RND(100) * DECR / 1000) NEWPOP = INT((POPU * VITA) / 15) PLAG = RND(3) - 0.5 NODEAD = 1 IF POPU GE NEWPOP THEN NODEAD = 0 DEAD = POPU - NEWPOP IF DEAD > 0.45 * POPU THEN CRT CRT 'You starved ' : DEAD : ' people in 1 year !!!!' QUIT = 1 END TOTPERC = ((YEAR - 1) * TOTPERC + DEAD * 100 / POPU) / YEAR POPU = NEWPOP TOTDEAD = TOTDEAD + DEAD END END REPEAT IF QUIT THEN CRT CRT 'Hamurabi, I cannot continue to serve you !' CRT 'Get yourself another steward !' CRT VALU = 0 END ELSE VALU = STOR + ACRE * COSTREF CRT 'You started with ' : START : ' bushels worth of property.' CRT CRT 'In your 10 year term of office, ' : INT(10 * TOTPERC) / 10: CRT ' % of the' CRT 'population starved per year on average.' CRT 'That is, ' : TOTDEAD : ' people died.' CRT VALU = VALU * 10 / START END BEGIN CASE CASE TOTPERC > 33 OR VALU < 8 CRT 'Due to extreme mismanagement you have not only' CRT 'been impeached and thrown out of office, but you' CRT 'have also been declared national fink !!!!' CASE TOTPERC > 10 OR VALU < 12 CRT 'Your heavy hand is your ruin !' CRT 'You are worse than Bolger !!!!' CASE TOTPERC = 0 IF VALU < 18 THEN CRT 'Not too bad !' IF DEAD THEN TMP = INT(POPU * RND(10) * 0.04) IF TMP THEN CRT TMP : ' people say get hung !' END END ELSE CRT 'A fantastic performance !!!!' END CASE 1 CRT 'Not too bad !' IF DEAD THEN TMP = INT(POPU * RND(10) * 0.08) IF TMP THEN CRT TMP : ' people say get hung !' END END CASE CRT CRT 'Do you wish to play again ? ': XIT = 0 LOOP IN KBD KBD = OCONV(CHAR(KBD), 'MCU') IF KBD = 'Y' OR KBD = 'N' THEN CRT KBD XIT = 1 END ELSE CRT BELL: END UNTIL XIT DO REPEAT IF KBD = 'N' THEN STOP UNTIL 0 DO REPEAT 100 ! Input numeric ONLY DONE = 0 CMD = '' LOOP IN KBD BEGIN CASE CASE KBD = CTRLX OR KBD = ESCAPE CRT CRT CRT 'Are you sure you want to quit ? ': XIT = 0 LOOP IN KBD KBD = OCONV(CHAR(KBD), 'MCU') IF KBD = 'Y' OR KBD = 'N' THEN CRT KBD XIT = 1 END ELSE CRT BELL: END UNTIL XIT DO REPEAT IF KBD = 'Y' THEN STOP CMD = 'REPEAT' DONE = 1 CRT CASE KBD = RETRN AND CMD # '' DONE = 1 CASE KBD = BSPCE AND CMD # '' CRT @(-9) : @(-4): CMD = CMD[1, LEN(CMD)-1] CASE KBD > 47 AND KBD < 58 AND LEN(CMD) < 10 CRT CHAR(KBD): CMD = CMD : CHAR(KBD) CASE 1 CRT BELL: END CASE UNTIL DONE DO REPEAT CRT RETURN ! END