Exemplo n.º 1
0
    def test_game_invalid_path(self, mock_input, mock_output):
        expected = """1 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 2
Where would you like to move?
1. North, 2. East, 3. South, 4. West

You can't go in that direction!
1 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 2
Where would you like to move?
1. North, 2. East, 3. South, 4. West

You can't go in that direction!
1 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 2
Where would you like to move?
1. North, 2. East, 3. South, 4. West

0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 2
Where would you like to move?
1. North, 2. East, 3. South, 4. West

0 0 1 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 2
Where would you like to move?
1. North, 2. East, 3. South, 4. West

0 0 0 1 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 2
Where would you like to move?
1. North, 2. East, 3. South, 4. West

0 0 0 0 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 2
Where would you like to move?
1. North, 2. East, 3. South, 4. West

You can't go in that direction!
0 0 0 0 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 2
Where would you like to move?
1. North, 2. East, 3. South, 4. West

0 0 0 1 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 2
Where would you like to move?
1. North, 2. East, 3. South, 4. West

0 0 0 0 0
0 0 0 1 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 2
Where would you like to move?
1. North, 2. East, 3. South, 4. West

0 0 0 0 0
0 0 0 0 0
0 0 0 1 0
0 0 0 0 0
0 0 0 0 2
Where would you like to move?
1. North, 2. East, 3. South, 4. West

0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 1 0
0 0 0 0 2
Where would you like to move?
1. North, 2. East, 3. South, 4. West

0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 1 2
Where would you like to move?
1. North, 2. East, 3. South, 4. West

You can't go in that direction!
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 1 2
Where would you like to move?
1. North, 2. East, 3. South, 4. West

It took you 10 moves to reach the exit.
"""
        game()
        self.assertEqual(expected, mock_output.getvalue())
Exemplo n.º 2
0
config.read('config.ini')

mainurl = config['CONNECTION']['mainurl']
height = int(config['MAZE']['height'])
width = int(config['MAZE']['width'])
ponyname = config['PONY']['ponyname']
difficulty = int(config['MAZE']['difficulty'])

mazeconnection = conn.connectionPony(height, width, ponyname, difficulty,
                                     mainurl)

maze_id = mazeconnection.new()
#maze_id=json.loads(NewMaze(15,15,'Pinkie Pie').text)['maze_id']
#maze=mazeconnectio.get()
maze_json = mazeconnection.get()
maze = maze.game(maze_json)
maze.shortest_path(maze.endpoint)
for i in range(0, maze.pony):
    maze.makeMovePony()
    direction = conn.MoveDirection(maze.pony_old, maze.pony, maze.size[0])

    mazeconnection.move(direction)  #make move send move to connection

    maze.update(mazeconnection.get())
    print(direction)
    maze.printmaze()
    print(maze.game_state)
    if maze.cells[maze.pony] == 0:
        break
    if maze.game_state['state'] != 'active':
        break
Exemplo n.º 3
0
import os
import maze

rows = 37
coloms = 57


os.system('mode con: cols='+str(coloms + 60)+'lines='+str(rows + 7))
mazeObj = maze.MAZE(rows,coloms)

maze.game(mazeObj)