Giter Site home page Giter Site logo

tic_tac_toe-ai's Introduction

Download notebook ,play it and have fun

Contents:

  • About Special Function

  • About Heuristic

  • How to play Tic Tac Toe(Basic)

  • How to play Tic Tac Toe (open Field)

Special Function:

  • The thing I focussed on in my special Min max are the starting move and optimal depth,in which the first one is far more important,and maximum of the members will make it as random. From the research I did I came to know that if we place the first choice on one of the corners then the chance of winning is ours if the other player wont place in the middle as their first move and for the second one I did trial and error to obtain at a good value.
  • Function that returns all the coordinates of corner elements and choose one randomly   

Non Special Function

Special Function

Heuristic Function:

  •  +100 for EACH 3-in-a-line for computer.
  • +10 for EACH 2-in-a-line (with an empty cell) for the computer.
  • +1 for EACH 1-in-a-line (with two empty cells) for the computer.
  • Negative scores for opponent, i.e., -100, -10, -1 for EACH opponent's 3-in-a-line, 2-in-a-line and 1-in-a-line.
  • 0 otherwise (empty lines or lines with both computer's and opponent's seed).

For explaining let me take a matrix

X | . | .

 . | O| O

 . | O| O

O - computer

X - Human

As Computer has 2 rows and 2 columns with 2 filled is score is +40

As human has a row and a column 1 filled its score is -2

So total score return by my heuristic is 38

This is extended for Open field Tic Tac Toe also as if m are filled pow(10,m) is returned.

**S20180010033 is my roll_number in my college(Not Copied)**

Tic Tac Toe(Basic)

  • Restart and Run All
  • Now check for a new tab that is opened in Background(Tkinter Menu)

  • Now Select the options from dropdown which will appear when you click on the right to the questions

1.Choose your Character : X or O

2.Do you want to start : Y-’yes’ , N-’ no’

3.With which algorithm you want to play? : there will be 5 options

4.Submit : to submit the responses

   

  • Now you can see another pygame pop up window in which you can play the game with the options you opt(sound effects included) and at the bottom left you can see the time taken by the agent

  • At the end you can see a window which represents your status in the game(Win,Lose or Draw) and the tab will close automatically.

Tic Tac Toe(open Field)

  •  Restart and Run All
  • Now check for a new tab that is opened in Background(Tkinter Menu)

  • Now Select the options from dropdown which will appear when you click on the right to the questions

1.Choose your Character : X or O

2.Choose board size (N): Ranges from 3-7

3.Choose Matching Size(K): Ranges from 3-7 [which should be less than Board size]

4.Do you want to start : Y-’yes’ , N-’ no’

5.With which algorithm you want to play? : there will be 5 options

6.Submit : to submit the responses

  • Here there is a trade off for accurate steps and time ,I bent myself towards time hence some steps may be irrelevant(less probability of irrelevance) .Please do choose minmax with depth limit or minmax with depth limit and alpha beta pruning   or Special option in algorithm type for faster responses from agent

 

  • Now you can see another pygame pop up window in which you can play the game with the options you opt(sound effects included) and at the bottom left you can see the time taken by the agent

For N = 3,4 board is different from N = 5,6,7 since as grid   need to be larger

        

         

        

  • At the end you can see a window which represents your status in the game(Win,Lose or Draw) and the tab will close automatically.

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.