5 kyu

Amoeba: Blind Maze

Description
Loading description...
Puzzles
  • Please sign in or sign up to leave a comment.
  • dfhwze Avatar

    Good kata but test design is annoying. Each test case should have its own it block, and you could enable allow_raise to exit test cases early on first failure

  • Voile Avatar

    The fixed tests and random tests are currently very unhelpful in debugging, they might as well not exist. At least these two things are needed:

    1. If a random test failed, print out the initial maze state.
    2. Change the sample test setup: it should receive a map and use that map as the initial state. Currently it's impossible to even know what map is being tested because it's hidden inside the opaque function.
    • kee-reel Avatar
      1. Added postmortem log. Looks like this: ``` Amoeba died from starvation :c ~~~~~~HELP IN DEBUGGING~~~~~~

      You've reached maximum amount of iterations: 20 Here is how maze looked like at start: 52 58 64 || :: 46 || 70 || 94 40 || 76 82 88 34 || || || || ~* 22 16 10 04 Here is how it looks at the end: 52 58 64 || :: 46 || 70 || 94 40 || 76 82 88 34 || || || || ~* 22 16 10 04 You could debug this maze by putting following list in "maze" parameter in test_amoeba_brain(): [[0, 0, 0, 1, 3], [0, 1, 0, 1, 0], [0, 1, 0, 0, 0], [0, 1, 1, 1, 1], [2, 0, 0, 0, 0]]

      
      2. Now user able to provide maze map that looks like this:
      

      maze = [ [0, 0, 3], [0, 1, 1], [0, 1, 2] ]

      0 - empty, 1, wall, 2 -amoeba, 3 - food

      ``` More than this - user can copy-paste initial maze structure from postmortem log and try it in sample test.

      Added all this in the description of kata.

    • kee-reel Avatar
      Issue marked resolved by kee-reel 4 years ago
  • Voile Avatar

    Needs more random tests, or at least better fixed/random tests: solutions like this sometimes pass the random tests.

    • kee-reel Avatar

      This comment has been hidden.

    • kee-reel Avatar

      Wow! Because of this even legit but not optimal solutions are invalidated!

      (*・‿・)ノ⌒*:・゚✧・゚✧・゚✧・゚✧・゚✧・゚✧・゚✧
                  ✧・゚✧magic of coding・゚✧・゚
                  ・゚✧・゚✧・゚✧・゚✧・゚✧・゚✧・゚✧
      
    • kee-reel Avatar
      Issue marked resolved by kee-reel 4 years ago
  • Blind4Basics Avatar
    • more sample tests would be good (typically, you could put all the fixed tests of the full test suite in there)
    • an option to be able to print the maze in the fixed tests of the full test suite would be good too, (for those that aren't in the sample tests, if any)
    • you should remove the random thing in the sample test. It's supposed to be a basic debugging tool, so nobody wants something random there

    'later ;o

    • kee-reel Avatar
      • added parameter size_of_maze into test_amoeba_brain_fixed_maze(), so user could try different sizes (from 3 to 50)
      • added print for fixed tests of full suite: there are 5 of them 5x5 - 25x25. Won't add higher sizes because print will be too huge
      • removed test_amoeba_brain_random_maze() method from sample tests

      Thanks!

    • Blind4Basics Avatar

      Hi,

      just actually put the fixed tests in the sample tests. No user will try to debug their code with random parameters in the sample tests, expecially because the user doesn't know what your function helper is doing exactly. So actual fixed test are way more useful.

    • Blind4Basics Avatar
      Suggestion marked resolved by Blind4Basics 2 years ago
  • Blind4Basics Avatar

    :o

    holy... you really need to get your coordinates thing straight and clear:

    surrounding = [[False, False, True],
                   [True, False, True],
                   [False, False, False]]
    positon before move:
    . # . . . 
    . # . # A 
    . . . # . 
    . # # # . 
    X . . # . 
    

    da hell? XD
    I (and I guess anybody else?) would have expected that the surroudning array is actually matching the coordinates around in the maze, but that's not at all what you did.

    That's one of the most confusing choice you could do, imo. I'd strongly "suggest" you rework the kata so that the data in surrounding lists are actually matching what is viewed in the maze. Keeping things that way is just transforming your kata in a pain for the user.

    edit: I mean that the surrounding thing should be this one below, whatever your coordinate system is:

    surrounding = [[True, True, False],
                   [False, False, True],
                   [False, True, False]]
    
    • kee-reel Avatar

      Yes, I've broken something while fixing other issues :c

      I'll unpublish it untill everything neat and clean

      Thank you!

    • kee-reel Avatar

      Whew! What a nice start of the day :D

      Fixed surrounding and direction (for sure). Added in desctiption mentioning of Y axis direction and behaviour when hitting walls. Changed view of debug output, so it's clear when your code is executing.

      And again, thank you so much for feedback! 🤩

    • Blind4Basics Avatar

      that part seems now consistent (I still don't like the y axis going up, but at least it's specified, now)

      Issue marked resolved by Blind4Basics 4 years ago
  • Blind4Basics Avatar

    mmmh... Currently trying the sample tests and I get food_smell values that are always 0 on 2 neighboring positions... is that a bug? Or are some other specifications missing? I'd expect 2 different values, since I moved (and according to the logs, I moved toward the food => expecting something like 0.00x?)

  • Blind4Basics Avatar

    it would help if your testing function would raise an error if the user is trying to move on a wall or outside of the maze. Currently, it looks like you just silent the move and keep going. (is that specified, btw??)

    • kee-reel Avatar

      Yes, it is specified - amoeba just hits the wall and don't move. You could see it in debug print mode. I'll add it in description - thank you for feedback!

    • Blind4Basics Avatar

      I missed the line, sorry.

      Tho, I don't think it's a good idea that your code does nothing "visible" at all in that case. If you don't want to go for the exception thing, at the very least, provide a specific message in your logs.

  • Blind4Basics Avatar

    Hi,

    You showed in the description that axis are y/vertical and x/horizontal, but you didn't specify in what direction you chose to use y axis: natural (up) or indexing (down) direction for positive values? (unless I missed it, but I couldn't see the info)

    Cheers

    • Blind4Basics Avatar

      apparently, you used indexing direction (I profoundly don't like this setup... Personnal taste...)

    • kee-reel Avatar

      Strange, I used indexing direction (at least I show it that way in directions and debug output). I'm looking into it!

    • Blind4Basics Avatar

      Strange

      what part? Me not liking it? x)

    • kee-reel Avatar

      Of course no :D

      I also prefer natural indexing. I've checked direction:

      With constant direction (-1, 0) amoeba moves like this:

      ::::::::::::::::::Start::::::::::::::::::
      . # . . A 
      . # . # . 
      . . . # . 
      . # # # . 
      X . . # . 
      ==============================
      . # . A . 
      . # . # . 
      . . . # . 
      . # # # . 
      X . . # . 
      ==============================
      . # A . . 
      . # . # . 
      . . . # . 
      . # # # . 
      X . . # . 
      

      With constant direction (0, -1) amoeba moves like this:

      ::::::::::::::::::Start::::::::::::::::::
      . # . . A 
      . # . # . 
      . . . # . 
      . # # # . 
      X . . # . 
      ==============================
      . # . . . 
      . # . # A 
      . . . # . 
      . # # # . 
      X . . # . 
      ==============================
      . # . . . 
      . # . # . 
      . . . # A 
      . # # # . 
      X . . # . 
      ==============================
      . # . . . 
      . # . # . 
      . . . # . 
      . # # # A 
      X . . # . 
      ==============================
      . # . . . 
      . # . # . 
      . . . # . 
      . # # # . 
      X . . # A 
      ==============================
      . # . . . 
      . # . # . 
      . . . # . 
      . # # # . 
      X . . # A 
      

      But for surrounding y points down - fixing it.

    • Blind4Basics Avatar

      ok, I got the "strange" part: it seems I mixed up directions somewhere and you actually didn't use indexing direction for positive values... x)

      to make things simple: move = (-1,-1) => where is the A going in that case? left+down?

      edit: crossed messages. Yeah, that's it. => you're using "natural" up direction for positive values of y (which is totally unatural to me in CS context x) ) => just amend the description to make the choice clear

    • kee-reel Avatar

      Fixed surrounding orientation -- now it's natural (y is up). Added mentioning of it in description.

    • Blind4Basics Avatar

      I'll close here, but you might need to rework the description about that again, once the issue above is resolved too (I finally got why I mixed up the things before)

      Issue marked resolved by Blind4Basics 4 years ago
  • Kacarott Avatar

    Does the "food sense" show distance ignoring walls? Or does it show distance of the shortest path to the food? (I am assuming the first option)

    • kee-reel Avatar

      It's "shortest path to the food" I thought to implement first option, but it will make this parameter almost useless (because path to food could be in other direction). Thank you, I'll add it to description.

    • Kacarott Avatar
      Question marked resolved by Kacarott 4 years ago
  • rowcased Avatar
    Fixed cases
    test amoeba navigation in fixed maze 5 x 5
    

    but they are random