|
2 | 2 | Wa-Tor algorithm (1984)
|
3 | 3 |
|
4 | 4 | @ https://en.wikipedia.org/wiki/Wa-Tor
|
| 5 | +
|
5 | 6 | @ https://beltoforion.de/en/wator/
|
| 7 | +
|
6 | 8 | @ https://beltoforion.de/en/wator/images/wator_medium.webm
|
7 | 9 |
|
8 | 10 | This solution aims to completely remove any systematic approach
|
@@ -97,8 +99,8 @@ class WaTor:
|
97 | 99 |
|
98 | 100 | :attr time_passed: A function that is called every time
|
99 | 101 | time passes (a chronon) in order to visually display
|
100 |
| - the new Wa-Tor planet. The time_passed function can block |
101 |
| - using time.sleep to slow the algorithm progression. |
| 102 | + the new Wa-Tor planet. The `time_passed` function can block |
| 103 | + using `time.sleep` to slow the algorithm progression. |
102 | 104 |
|
103 | 105 | >>> wt = WaTor(10, 15)
|
104 | 106 | >>> wt.width
|
@@ -216,7 +218,7 @@ def get_surrounding_prey(self, entity: Entity) -> list[Entity]:
|
216 | 218 | """
|
217 | 219 | Returns all the prey entities around (N, S, E, W) a predator entity.
|
218 | 220 |
|
219 |
| - Subtly different to the try_to_move_to_unoccupied square. |
| 221 | + Subtly different to the `move_and_reproduce`. |
220 | 222 |
|
221 | 223 | >>> wt = WaTor(WIDTH, HEIGHT)
|
222 | 224 | >>> wt.set_planet([
|
@@ -260,7 +262,7 @@ def move_and_reproduce(
|
260 | 262 | """
|
261 | 263 | Attempts to move to an unoccupied neighbouring square
|
262 | 264 | in either of the four directions (North, South, East, West).
|
263 |
| - If the move was successful and the remaining_reproduction time is |
| 265 | + If the move was successful and the `remaining_reproduction_time` is |
264 | 266 | equal to 0, then a new prey or predator can also be created
|
265 | 267 | in the previous square.
|
266 | 268 |
|
@@ -430,7 +432,7 @@ def perform_predator_actions(
|
430 | 432 |
|
431 | 433 | def run(self, *, iteration_count: int) -> None:
|
432 | 434 | """
|
433 |
| - Emulate time passing by looping iteration_count times |
| 435 | + Emulate time passing by looping `iteration_count` times |
434 | 436 |
|
435 | 437 | >>> wt = WaTor(WIDTH, HEIGHT)
|
436 | 438 | >>> wt.run(iteration_count=PREDATOR_INITIAL_ENERGY_VALUE - 1)
|
@@ -488,6 +490,7 @@ def visualise(wt: WaTor, iter_number: int, *, colour: bool = True) -> None:
|
488 | 490 | the predators and prey.
|
489 | 491 |
|
490 | 492 | (0x60f197) Prey = #
|
| 493 | +
|
491 | 494 | (0xfffff) Predator = x
|
492 | 495 |
|
493 | 496 | >>> wt = WaTor(30, 30)
|
|
0 commit comments