14 Commits

Author SHA1 Message Date
Sourcery AI
71d02673a9 'Refactored by Sourcery' 2024-08-19 03:46:27 +03:00
Ethan Dicks
a46a2576e5 Corrected typo in Hamurabi summary report 2022-10-17 00:10:55 -04:00
Martin Thoma
ae0b6a5015 BUG: Hangman (Python) had a List-vs-Str comparison
MAINT: Add type annotations to find such issues
2022-03-31 10:33:11 +02:00
Martin Thoma
17a75813b1 Remove tests and alternative Python implementations
Ad discussed here:
https://github.com/coding-horror/basic-computer-games/issues/548#issuecomment-1081008471
2022-03-29 07:02:10 +02:00
Martin Thoma
83b3dc402c Python: Add type annotations 2022-03-20 19:16:39 +01:00
Martin Thoma
f52d9a0e54 Clean Code: Python
Fix issues found by flake8-bugbear:

* Unused loop variables
* assert statements in non-test code
* mixing test code with production code
* mark one excessive test which takes ~10min to run
  as 'slow'
2022-03-18 14:59:08 +01:00
Martin Thoma
af88007734 Python: Fix Flake8 E722 and E741
Additionally:

* Use functions to group blocks of code
* Use variable names (not just one character...)
2022-03-12 08:17:03 +01:00
Martin Thoma
4adb34f25c Python: Fix code style issues 2022-03-11 07:44:56 +01:00
Martin Thoma
e64fb6795c MAINT: Apply pre-commit
Remove byte-order-marker pre-commit check as there would be
many adjustments necessary
2022-03-05 09:29:23 +01:00
Stephen Childs
94a65239d5 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.
2022-01-13 11:04:43 -05:00
Stephen Childs
6c1adde205 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.
2022-01-13 10:56:50 -05:00
Bill Cruise
a360ca17ca Return a value from gen_random function. 2022-01-08 13:18:09 -05:00
Bill Cruise
d5a2260796 Reformat to make code more Pythonic and (hopefully) readable. 2022-01-08 12:56:44 -05:00
Chris Reuter
d26dbf036a Removed spaces from top-level directory names.
Spaces tend to cause annoyances in a Unix-style shell environment.
This change fixes that.
2021-11-21 18:30:21 -05:00