Code Monkey home page Code Monkey logo

tic-tac-toe-minimax's People

Contributors

cledersonbc avatar sahil-python avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tic-tac-toe-minimax's Issues

Winning later than it could

Hello,
I've found one issue in your otherwise great project.

If you try moves 1, 3, 7, the AI doesn't play 8 as it should have but instead plays 4.

X O X
O
X

Edit: My fault as it will still win... just later.

Error message in Jupyter

clean()
print(f'Computer turn [{c_choice}]')
render(board, c_choice, h_choice)
if depth == 9:
    x = choice([0, 1, 2])
    y = choice([0, 1, 2])
else:
    move = minimax(board, depth, COMP)
    x, y = move[0], move[1]
set_move(x, y, COMP)
time.sleep(1)

NameError Traceback (most recent call last)
in
1 clean()
----> 2 print(f'Computer turn [{c_choice}]')
3 render(board, c_choice, h_choice)
4 if depth == 9:
5 x = choice([0, 1, 2])

NameError: name 'c_choice' is not defined

suboptimal move

the minimax implementation can't find the optimal move in these input.

Player X input.

  • (0, 1) > (1, 0) > (2, 1)
  • (0, 0) > (2, 0) > (0, 2)

Wrong move by computer

Start with this board position.
board = [
[1, 1, -1],
[ -1, 1, 0],
[ -1, 0, 0],
]

Choose X or O
Chosen: O
First to start?[y/n]: n
Computer turn [X]

---------------
| X || X || O |
---------------
| O || X ||   |
---------------
| O ||   ||   |
---------------

Human turn [O]

---------------
| X || X || O |
---------------
| O || X || X | <--------- Wrong move by computer
---------------
| O ||   ||   |
---------------
Use numpad (1..9): 

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.