Beispiel #1
0
def main():

    # initialise state
    state = [[0 for j in range(8)] for i in range(8)]

    # read input; done this way to make the board notation for the game
    # match up with the board notation in the program
    squares = sys.stdin.read()

    y = 0
    x = 0
    for char in squares:
        if char == " ":
            x += 1
        elif char == "\n":
            y += 1
            x -= 7
            if y > 7:
                break
        else:
            state[y][x] = char

    # extract mode indicator
    mode = squares[128:].strip("\n")

    white, black = Board.Board.produce_piece_list(state)

    # execute analysis
    if mode == "Moves":
        moves(state)
    elif mode == "Massacre":
        # extract move list that solves board configuration
        solution = Player.ArtificialPlayer(Board.Board(
            white, black)).calculate_strategy()

        # iterate through moves and print
        for i in solution:
            if i:
                print(i)