示例#1
0
def interpret_game(path):
    game_data = read_game_file(path)

    white_queen = Queen(game_data['white_queen'],
                        Team.WHITE,
                        monkey_stack=game_data['stack'])
    black_queen = Queen(game_data['black_queen'],
                        Team.BLACK,
                        monkey_stack=game_data['stack'])

    board = Board(cols=game_data['cols'], rows=game_data['rows'])
    board.add_entity(white_queen)
    board.add_entity(black_queen)

    board.draw()

    for command in game_data['moves']:
        board.play_command(command)

    return board
示例#2
0
from src.game.entities import Monkey, Queen, Team
from src.game.game_exception import *
from src.game.command import Command
from src.game.geo import Vec2I

ROWS = 8
COLS = 8

white_queen = Queen(Vec2I(3, 0), Team.WHITE, monkey_stack=8)
black_queen = Queen(Vec2I(4, 7), Team.BLACK, monkey_stack=8)

board = Board(cols=COLS, rows=ROWS)
board.add_entity(white_queen)
board.add_entity(black_queen)

board.draw()

while True:
    str_from = input('Piece from (x, y): ')
    str_from = str_from.split(',')
    pos_from = Vec2I.parse_from_list(str_from)

    str_to = input('Piece to (x, y): ')
    str_to = str_to.split(', ')
    pos_to = Vec2I.parse_from_list(str_to)

    command = Command(pos_from, pos_to)

    try:
        board.play_command(command)
    except GameException as exc: