Giter Site home page Giter Site logo

adversarial-search's Introduction

Build Monte Carlo Tree search for an Adversarial Game Playing Agent

This is my assginment solution for Udacity AI fundamental course.

Adversarial search techniques for building an agent to play knights Isolation.

Isolation

In the game Isolation, two players each control their own single token and alternate taking turns moving the token from one cell to another on a rectangular grid.

Finally, agents have a fixed time limit (150 milliseconds by default) to search for the best move and respond. The search will be automatically cut off after the time limit expires, and the active agent will forfeit the game if it has not chosen a move.

Instructions

Agent is implemented in the CustomPlayer class defined in the game_agent.py file. The interface definition for game agents only requires .get_action() method, but you can add any other methods to the class that you deem necessary. You can build a basic agent by combining minimax search with alpha-beta pruning and iterative deepening But i implemented MCTS.

The get_action() Method

This function is called once per turn for each player. The calling function handles the time limit and

def get_action(self, state):
    import random
    self.queue.put(random.choice(state.actions()))
  • DO NOT use multithreading/multiprocessing (the isolation library already uses them, so using them in your agent may cause conflicts)

Saving Information Between Turns

The CustomPlayer class can pass internal state by assigning the data to the attribute self.context. An instance of your agent class will carry the context between each turn of a single game, but the contents will be reset at the start of any new game.

def get_action(...):
    action = self.mcts()
    self.queue.put(action)
    self.context = object_you_want_to_save  # self.context will contain this object on the next turn

Default oponent is MINMAX but you can select based available other openents as mentioned in run_match.py

TEST_AGENTS = { "RANDOM": Agent(RandomPlayer, "Random Agent"), "GREEDY": Agent(GreedyPlayer, "Greedy Agent"), "MINIMAX": Agent(MinimaxPlayer, "Minimax Agent"), "SELF": Agent(CustomPlayer, "Custom TestAgent") }

example of command to run:

$ python run_match.py -o RANDOM

other parameters which can be setted are: NUM_PROCS, NUM_ROUNDS = 10, TIME_LIMIT = 100 , number on epochs.

adversarial-search's People

Contributors

alishams8 avatar

Watchers

James Cloos 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.