my hero only moves in a certain way and it does not reach the chest, im not sure why
also can someone explain what Vector does
# Find the treasure inside the maze.
# When you get the treasure, move to the exit.
# The exit is marked by the red cross. The level ends when you step on the mark.
# Some doors are blocked, some open when you are near them.
exitPosition = {"x": 150, "y": 120}
distanceBetweenRooms = 16
zeroShift = {"x": 10, "y": 10}
# Escape from the maze!
# Some doors are blocked, some open when you are near them.
distance = 16
move = Vector(distance, 0)
direction = Vector.add(move, hero.pos)
while True:
while not (hero.isPathClear(hero.pos, direction)):
move = Vector.rotate(move, Math.PI / 2)
direction = Vector.add(move, hero.pos)
# hero.say(direction)
hero.moveXY(direction.x, direction.y)
move = Vector.rotate(move, -Math.PI / 2)
direction = Vector.add(move, hero.pos)
inSearch = True
width = 19
height = 15
wall = "X"
unknown = "?"
empty = "."
maze = []
# left border
for i in range(height):
maze.append([wall])
for j in range(width - 1):
maze[0].append(wall)
for i in range(height - 1):
if i % 2:
for j in range(width - 1):
maze[i].append(unknown)
else:
for j in range(width - 1):
if j % 2:
maze[i].append(wall)
else:
maze[i].append(unknown)
for j in range(width - 1):
maze[height-1].append(wall)
for i in range(height):
maze.append([wall])
hero.row = 13
hero.col = 17
exitRow = 13
exitCol = 17
item = hero.findNearest(hero.findItems())
distance = 16
move = Vector(distance, 0)
direction = Vector.add(move, hero.pos)
while True:
while True:
while not (hero.isPathClear(hero.pos, direction)):
move = Vector.rotate(move, Math.PI / 2)
direction = Vector.add(move, hero.pos)
# hero.say(direction)
hero.moveXY(direction.x, direction.y)
move = Vector.rotate(move, -Math.PI / 2)
direction = Vector.add(move, hero.pos)