#need suggestions on how to tackle this coding project

1 messages · Page 1 of 1 (latest)

signal ruin
#

Not sure what's your level, so I'm not sure what would be good advice for you.
Please share what you have thought about so far.

In any case, I would split the code to

  1. representing the maze (with a class assuming you already learned about classes)
  2. parsing the maze from the text file (and returning an instance of the mentioned class)
  3. solving a maze using the basic algorithm
  4. solving a maze using the "shortest path" algorithm
tall hornet
signal ruin
#

great, make sure to split between these 2 things you mentioned:
traversing the maze in general (going from one point to the next one)
and using the traversing capabilities to implement the shortest path algorithm.

I think they gave you the simpler algorithm at first so it will be easier for you to make sure that the traversal logic works. so I would definitely start with the simple "always left" algorithm, and after making sure it works then continue to the shortest path algorithm.

sharp pebble
#

What language are you using ?

tall hornet
tall hornet
signal ruin
#

sort of - you need to specify what the "left path" means in each case, because it depends on where you're facing.

tall hornet
signal ruin
#

that's a really question.
I have an idea, but I'm sure there are other options.
I would try to model it by adding a variable (to the PuzzleSolver class or whatever it is) named something like current_facing_direction, and then you can have a functions that looks a bit like that:

def find_next_block_on_the_left_wall(...):
    one_left_direction = get_one_left(self.current_facing_direction)
    if puzzle.is_move_possible(one_left_direction):
        self.current_facing_direction = one_left_direction
        return <new_position_moving_left>
    elif puzzle.is_move_possible(self.current_facing_direction):
        # means we still facing the same direction so no need to update the current_facing_direction
        return <new_position_moving_forward>
    else:
        # turn back or something
signal ruin
#

or in other words - you'll have to check each time if turning left from the current facing direction is possible, and if so - go there. if not - go ahead in the same facing direction. and if neither are possible - go back