def step(self, direction, hall_type = Hallways.TRIFURC): if direction not in self.position.adjacent: #Not visited new_pos = MazeComponent(hall_type) new_pos.last_pos = self.position if self.position.is_choice_room: #In a choice room new_pos.is_choice_room = False self.assign_possible_prize(new_pos, direction) new_pos.depth = 1 new_pos.options = ReadFile.get_option(new_pos.prize[0]) self.set_has_prize(new_pos) #Winner? else: #In a `straight' choiceless room if direction in [Directions.LEFT, Directions.RIGHT]: #the user turns new_pos.is_choice_room = True #Determine order o' prizes new_pos.set_prize_order(self.generate_prize_order()) elif direction == Directions.FORWARDS: #User proceeds forward #default of is_choice_room is false new_pos.prize[0] = self.position.prize[0] new_pos.depth = self.position.depth + 1 new_pos.options = self.position.options self.set_has_prize(new_pos) #Winner? self.position.adjacent[direction] = new_pos #Allow yourself to go backwards if direction == Directions.FORWARDS: new_pos.adjacent[Directions.BACKWARDS] = self.position elif direction == Directions.BACKWARDS: new_pos.adjacent[Directions.FORWARDS] = self.position elif direction == Directions.LEFT: new_pos.adjacent[Directions.BACKWARDS] = self.position elif direction == Directions.RIGHT: new_pos.adjacent[Directions.BACKWARDS] = self.position self.position = new_pos elif self.position.adjacent[direction] != None: self.position.adjacent[direction].last_pos = self.position self.position = self.position.adjacent[direction] self.position.prize = [self.position.prize[0], 0, False]
def step(self, direction, choice_room = False): if direction not in self.position.adjacent: #Not visited new_pos = MazeComponent(Hallways.STRAIGHT) new_pos.last_pos = self.position if self.position.is_choice_room: #In a choice room new_pos.is_choice_room = False self.assign_possible_prize(new_pos, direction) new_pos.depth = 1 #print 'Got to get option' #new_pos.options = ReadFile.get_option(new_pos.prize[0]) print 'Options: ' + str(new_pos.options) self.set_has_prize(new_pos) #Winner? new_pos.set_prize_order(self.generate_prize_order(new_pos)) new_pos.prize_order[1] = None #Centre column is none because you already followed a prize (this does not apply to first choice room) new_pos.prize_infos[1] = None print('i got here1') else: #In a `straight' choiceless room if direction in [Directions.LEFT, Directions.RIGHT]: #the user turns new_pos.is_choice_room = False #Determine order o' prizes new_pos.set_prize_order(self.generate_prize_order(new_pos)) new_pos.prize_order[1] = None#Centre column is none new_pos.prize_infos[1] = None self.assign_possible_prize(new_pos, direction) new_pos.depth = 1 #new_pos.options = ReadFile.get_option(new_pos.prize[0]) self.set_has_prize(new_pos) #Winner? print('i got here2') elif direction == Directions.FORWARDS: #User proceeds forward #default of is_choice_room is false new_pos.prize[0] = self.position.prize[0] print("PRIZE0", self.position.prize) new_pos.depth = self.position.depth + 1 new_pos.options = self.position.options new_pos.set_prize_order(self.generate_prize_order(new_pos)) new_pos.prize_order[1] = None #Centre column is none new_pos.prize_infos[1] = None self.set_has_prize(new_pos) #Winner? print('i got here3') self.position.adjacent[direction] = new_pos #Allow yourself to go backwards if direction == Directions.FORWARDS: new_pos.adjacent[Directions.BACKWARDS] = self.position elif direction == Directions.BACKWARDS: new_pos.adjacent[Directions.FORWARDS] = self.position elif direction == Directions.LEFT: new_pos.adjacent[Directions.BACKWARDS] = self.position elif direction == Directions.RIGHT: new_pos.adjacent[Directions.BACKWARDS] = self.position self.position = new_pos #still for going backwards elif self.position.adjacent[direction] != None: self.position.adjacent[direction].last_pos = self.position self.position = self.position.adjacent[direction] self.position.prize = [self.position.prize[0], 0, False] print("PRIZE1", self.position.prize)