Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- def init_board():
- """Returns an empty 3-by-3 board (with zeros)."""
- board = [[1,2,3],[4,5,6],[7,8,9]]
- return board
- def get_move(board, player):
- """Returns the coordinates of a valid move for player on board."""
- row, col = 0, 0
- return row, col
- def get_ai_move(board, player):
- """Returns the coordinates of a valid move for player on board."""
- row, col = 0, 0
- return row, col
- def mark(board, player, row, col):
- """Marks the element at row & col on the board for player."""
- pass
- def has_won(board, player):
- """Returns True if player has won the game."""
- return False
- def is_full(board):
- """Returns True if board is full."""
- return False
- def print_board(board):
- """Prints a 3-by-3 board on the screen with borders."""
- print("\n")
- for i in board:
- for j in i:
- print(j, end = " ")
- print()
- def print_result(winner):
- """Congratulates winner or proclaims tie (if winner equals zero)."""
- pass
- def tictactoe_game(mode='HUMAN-HUMAN'):
- board = init_board()
- # use get_move(), mark(), has_won(), is_full(), and print_board() to create game logic
- print_board(board)
- row, col = get_move(board, 1)
- mark(board, 1, row, col)
- winner = 0
- print_result(winner)
- def main_menu():
- os.system("clear")
- print(f"""
- Welcome to our Tic-Tac-Toe game!
- Please select a game mode:
- 1. Human vs Human
- 2. Human vs AI
- 3. AI vs AI1
- 4. Quit Game
- """)
- x = input("")
- if x == "1":
- tictactoe_game('HUMAN-HUMAN')
- if __name__ == '__main__':
- main_menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement