self.position = new_position
return True
return False
+
+ def set_position(self, new_position):
+ if new_position in self.legal_moves():
+ self.position = new_position
+ return True
+ return False
+
+ def legal_moves(self):
+ positions = [self.position]
+ for direction in [BITS.NORTH, BITS.SOUTH, BITS.EAST, BITS.WEST]:
+ position = self.get_adjacent_position(direction)
+ if position is not None and self.bits.check_bit(direction):
+ positions.append(position)
+ return positions