Beispiel #1
0
def play():
    while not variables.finish:
        if variables.curPlayer == 1:
            variables.curChess = "*"
            print("\033[1;37;40m * - Enter the coords of the chess (e.g. A0): \033[0m")
        else:
            variables.curChess = "o"
            print("\033[1;30;42m o - Enter the coords of the chess (e.g. A0): \033[0m")
        user_input = input()
        ch = user_input[0]
        x = ord(ch.upper()) - 65
        y = int(user_input[1])
        if exist(x, y) and len(user_input) == 2:
            flag = update_board(x, y)
            if flag == 0:
                print("\033[31m****** The place has been taken! Please try again! \033[0m")
                continue
            f = check_win(x, y)
            if f == 1:
                win()
                break
            swap_player()
            show_board()
        else:
            print("\033[31m*** Invalid coords! Please try again! ***\033[0m")
Beispiel #2
0
def win():
    """
    print out the final board and show a message to winner
    """
    print("The final board is shown below:")
    board.show_board()
    if variables.curPlayer == 1:
        print("\033[32m * has won the game! ***\033[0m")
    else:
        print("\033[32m o has won the game! ***\033[0m")
Beispiel #3
0
def put_in_start_position(pieces, color, board):
    """Put the pieces into the board based on their respective positions"""
    if color == "black":
        board.obj[0] = pieces[0]
        board.obj[1] = pieces[1]
    else:
        board.obj[7] = pieces[0]
        board.obj[6] = pieces[1]
    return board.show_board(board.obj)
def play_cli():
    deck = CARDS.make_deck()
    CARDS.shuffle_deck(deck)
    board = BOARD.new_board(deck)

    while True:
        moves = MOVES.find_moves(board)
        BOARD.show_board(board)
        print('------------')

        if not moves:
            print('No moves. Game over.')
            break

        for i in range(len(moves)):
            print('{}: {}'.format(i + 1, moves[i]))

        print()
        g = input('Move: ')

        MOVES.make_move(moves[int(g) - 1], board)
        print()
Beispiel #5
0
def run_game(board, agents):
    grave = ships_state.copy()
    attack_state = (0, None, None)  # (Type, xy_under_attack, XYs)
    color = 'white'
    state = (color, attack_state, board, grave)
    turn = 0

    while not end_of_game(state, turn):
        action = agents[color].get_action(state)
        print turn, "color: ", color, "   action: ", action
        #board.show_board()
        if board.action_illegal(attack_state, action):
            board.terminate(color, grave)
        else:
            attack_state, grave = board.apply_action(action, attack_state,
                                                     grave)
        board.show_board()

        color = change_color(color)
        state = (color, attack_state, board, grave)
        turn += 1

    #board.print_ships()
    print grave
Beispiel #6
0
    deck.nth_card(23).color(),
    deck.nth_card(23).value(),
)
print(deck.draw_by_number(1).show_card())
print(deck.show_deck())
print(deck.draw_by_name("AS").show_card())
print(deck.show_deck())
print(board.Board(deck.make_board()).show_board())
print(hand.Hand(deck.make_hand()).show_hand())
print(len(deck.show_deck()))
print(deck.show_deck())
print(deck.nth_card(66).show_card())

board = board.Board(deck.make_board())

print(board.show_board())
print(deck.show_deck())
print(board.flop())
print(board.flop1())
print(board.flop2())
print(board.flop3())
print(board.turn())
print(board.river())

hand1 = hand.Hand(deck.make_hand())

print(deck.show_deck())
print(hand1.show_hand())
print(hand1.show_hand_obj()[0].show_card())
print(hand1.show_hand_obj()[0].value())
print(hand1.show_hand_obj()[0].color())
Beispiel #7
0
import board
from play import play

if __name__ == '__main__':
    board.init_board()
    board.show_board()
    play()