diff --git a/honoring_the_code/001 - Space Maze/README.md b/honoring_the_code/001 - Space Maze/README.md index 6d7debd..15db501 100644 --- a/honoring_the_code/001 - Space Maze/README.md +++ b/honoring_the_code/001 - Space Maze/README.md @@ -41,3 +41,12 @@ How does the program check if the spaceship has hit a wall ? My intuition was th Here's a representation of the 16 rectangle zones the maze is made of. ![rectangle zones](./htc3.png) + +The main problem is that the code goes through ALL of the coordinates testing for EACH rectangle zone EVERY time, even if it has found already found the zone where the spaceship is. Each of these tests is made of 4 conditions (testing 2 limits of X and then 2 limits of Y). That's 4x16=64 conditions in a row ... and this is killing the game. + +16 lines like this one will kill the game: +```basic +100 IF (X > = 10 AND X < = 80) AND (Y > = 80 AND Y < = 100) THEN Z = 1 +``` + +It should be noted that although Z holds the zone number where the spaceship is, this variable is not used for anything else but testing if it's non-zero (in which case the spaceship is in none of the zones, thus out of the maze) and also that Z is not even properly set as lines 135 to 142 all set Z to 6 as if it was the same zone. Also, the comments indicate that there are 11 zones when in fact there are 16. It looks like during the development the maze was modified from 11 to 16 zones. And one last thing, some zones limits overlap but that's ok.