GithubHelp home page GithubHelp logo

lasaro-dumer-adversarial-search's Introduction

Adversarial Search

Adversarial search assignment

Assignment description is here! Requires Pygame ๐Ÿ Tested with Python 2.7.6 Check out this Python tutorial!

Getting Started

Source:

The following are the files required to build your Tic-tac-toe player. Minimax and Alpha-Beta are the incomplete ones.

Execution

Player โญ• is the first to play, followed by โŒ, but your players can behave differently from each other using different arguments:

Argument Player Type
human Human ๐Ÿšป
random Random โ‰๏ธ
minimax Minimax ๐Ÿ”ฝ๐Ÿ”ผ
alphabeta Alpha-Beta ๐Ÿš€

Use --quiet flag to disable verbose output of movements during the game.

  • Execute interface with default players
python interface.py [--quiet] [playerO playerX]
  • Execute terminal with default players
python tictactoe.py [--quiet] [playerO playerX]
  • Execute tests
python test_tictactoe.py

Questions

Questions are in the readme.txt to be sent together with the code.

Player Interface

Players require a minimal interface to play the game. They receive their symbol (O or X) in the initialization. Just remember to use self.symbol to compare with the other cells in the board to see how you are going. The hard part is to select the best cell in the board, get_next_move(self, board) is the method that must return a valid cell during the player turn. Cells must be an integer between 0 and 8. Let us take our friend Bob as an example. Somebody told him to start in the center, but he never got the rest of the message to understand how to continue the game:

from player import Player

class BobPlayer(Player):

    def __init__(self, symbol):
        super(BobPlayer, self).__init__(symbol)

    def get_next_move(self, board):
        return 4

The board is represented by a 1D list, filled with None, 'X' or 'O'. If we consider Bob as the X player the board would be modified like this:

# 0 1 2
# 3 4 5
# 6 7 8

from common import *

player = Player_Bob('X')
board = [ None, None, None ,
          None, None, None ,
          None, None, None ]
move = player.get_next_move(board)
# check_valid_move
board[move] = X

Hints

  • Use the methods from util.py to help the development:
    • find_empty_cells(board) helps you see where is available to play.
    board = [ None,  'X',  'O' ,
               'O',  'X',  'O' ,
              None, None, None ]
    find_empty_cells(board) # Returns [ 0, 6, 7, 8 ]
    • find_winner(board) helps you check if there is a winner. It returns a tuple, with the winner (None for none) and the list of the winner movement.
    board = [ None,  'X',  'O' ,
               'O',  'X',  'O' ,
              None,  'X', None ]
    winner, move_sequence = find_winner(board)
    print winner # Prints 'X'
    print move_sequence # Prints [1, 4, 7]
  • Do not try to mark several cells at once, the game provides a copy of the board for you to observe and only the position returned will make any difference.
  • Start with a successor method that generates (yields?) different scenarios for you.
  • Take a look at our random player or the questions if you get stuck.
  • Printing is a slow process. Use it just for development/debug, and remove it before handing the assignment.
  • Python creates a lot of .pyc files if not called with -B flag, python -B script.py arguments

lasaro-dumer-adversarial-search's People

Contributors

anibalsolon avatar joaopauloaires avatar lasaro-dumer avatar maumagnaguagno avatar meneguzzi avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.