From 6c1adde2056151fafe330ef9970403db5d372ce0 Mon Sep 17 00:00:00 2001 From: Stephen Childs Date: Thu, 13 Jan 2022 10:56:50 -0500 Subject: [PATCH 1/2] Move harvest calculation outside rat condition. This fixes an error where the harvest was only added to the total bushels if rats ate some. Note in the BASIC file, we check to see if rats eat the grain in line 522 and if not, go to line 530, which is where the `S=S-E+H` calculation is done. --- 43_Hammurabi/python/hamurabi.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/43_Hammurabi/python/hamurabi.py b/43_Hammurabi/python/hamurabi.py index 7c18f892..17c61982 100644 --- a/43_Hammurabi/python/hamurabi.py +++ b/43_Hammurabi/python/hamurabi.py @@ -154,7 +154,8 @@ while Z < 11: # line 270. main loop. while the year is less than 11 if int(C / 2) == C / 2: # even number. 50/50 chance # REM *** RATS ARE RUNNING WILD!! E = int(S / C) # calc losses due to rats, based on previous random number - S = S - E + H # deduct losses from stores + + S = S - E + H # deduct losses from stores C = gen_random() # REM *** LET'S HAVE SOME BABIES From 94a65239d5f6acd9b0817ad77bfb26622e82b676 Mon Sep 17 00:00:00 2001 From: Stephen Childs Date: Thu, 13 Jan 2022 11:04:43 -0500 Subject: [PATCH 2/2] Allow max fields to be worked in python Hamurabi. In the BASIC version the calculation is on line 455: `455 IF D<10*P THEN 510` Which skips over the not enough people message. In the Python version the logic is reversed, and we check to see if there is too few people and then run the message: `elif D >= 10 * P` (in the current code). However, this means that the case where you want to plant the maximum number of acres won't work. e.g. You have 100 people (P) and want to plant 1000 acres (D). `1000 >= 10 * 100` `1000 >= 1000` Which triggers the "not enough people code". Maybe this is a bug in the original program. --- 43_Hammurabi/python/hamurabi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/43_Hammurabi/python/hamurabi.py b/43_Hammurabi/python/hamurabi.py index 17c61982..e7310fc7 100644 --- a/43_Hammurabi/python/hamurabi.py +++ b/43_Hammurabi/python/hamurabi.py @@ -137,7 +137,7 @@ while Z < 11: # line 270. main loop. while the year is less than 11 # REM *** ENOUGH GRAIN FOR SEED? bad_input_710(S) D = -99 - elif D >= 10 * P: + elif D > 10 * P: # REM *** ENOUGH PEOPLE TO TEND THE CROPS? print("BUT YOU HAVE ONLY", P, "PEOPLE TO TEND THE FIELDS! NOW THEN,") D = -99