tic-tac-toe

Tic Tac Toe AI Bugs

北慕城南 提交于 2021-02-10 22:27:42
问题 I'm trying to implement an AI for Tic Tac Toe that is smart enough to never lose. I've tried two different algorithms but the AI still makes mistakes. I started with this minimax alpha-beta pruning algorithm. Here's a live demo: http://iioengine.com/ttt/minimax.htm It runs without error, but if you take the bottom left corner first, then either of the other two squares on the bottom row - the AI doesn't see that coming. I'm sure this isn't a flaw in the minimax algorithm - can anyone see an

Tic Tac Toe AI Bugs

江枫思渺然 提交于 2021-02-10 22:26:33
问题 I'm trying to implement an AI for Tic Tac Toe that is smart enough to never lose. I've tried two different algorithms but the AI still makes mistakes. I started with this minimax alpha-beta pruning algorithm. Here's a live demo: http://iioengine.com/ttt/minimax.htm It runs without error, but if you take the bottom left corner first, then either of the other two squares on the bottom row - the AI doesn't see that coming. I'm sure this isn't a flaw in the minimax algorithm - can anyone see an

Im making a simple TicTacToe in pyjama but I am running into some errors

ε祈祈猫儿з 提交于 2021-02-10 18:29:23
问题 The draw Board functions has an if statement to see which colour circle it should draw. But when the mouse button is clicked it draws the circle in the right x coordinate but in the opposite y coordinate. Also, the end is a little bit weird I want to display the winner and then wait using time.wait but it waits and then prints the statement for a second. If you could run it, you would understand. I am also looking for general improvements that I could make. import pygame, sys import numpy as

Identifying state of tic-tac-toe board from image

柔情痞子 提交于 2021-02-07 10:13:38
问题 I'm working on a project where I have to use openCV in java to identify the state of a tic tac toe board. Please see the sample program execution below. input Output X,-,- -,O,- X,-,- I'm trying to solve this by finding contours in the image, but the problem is that the empty unmarked boxes are also being captured and I'm not being able to distinguish between the shapes using contour properties like polygon size and contour area. Below is the code that I have so far. package finalproject;

Identifying state of tic-tac-toe board from image

痞子三分冷 提交于 2021-02-07 10:13:34
问题 I'm working on a project where I have to use openCV in java to identify the state of a tic tac toe board. Please see the sample program execution below. input Output X,-,- -,O,- X,-,- I'm trying to solve this by finding contours in the image, but the problem is that the empty unmarked boxes are also being captured and I'm not being able to distinguish between the shapes using contour properties like polygon size and contour area. Below is the code that I have so far. package finalproject;

Python minimax for tictactoe

拈花ヽ惹草 提交于 2021-01-28 04:46:59
问题 After completely failing the minimax implementation for tic tac toe, I fail to see what's wrong. Right now, my AI just goes around in a circle... import collections class InvalidLocationError(Exception): pass import copy class Board(object): def __init__(self, board=None): if board is None: self.clear() else: self._board = board[:] def place(self, i, row, column): if not ((0 <= row <= 2) and (0 <= column <= 2)): raise InvalidLocationError("Invalid Location.") if self._board[row][column]:

Solving TicTacToe with minimax algorithm in Javascript

空扰寡人 提交于 2020-12-27 06:44:12
问题 let _board = [[null, null, null], [null, null, null], [null, null, null]]; let _flag = true; let _AIrowIndex = null; let _AIcellIndex = null; const _wrapper = document.querySelector(".wrapper"); const _changeTurn = function () { if (_flag == true) { _flag = false; return playerOne.getSign(); } else { _flag = true; return playerTwo.getSign(); } }; const _displayTurn = function () { let turn = document.querySelector(".playerInfo__turn") if (_flag == true) { turn.innerHTML = `${playerOne.getName

Tic-Tac-Toe AI: How to Make the Tree?

爷,独闯天下 提交于 2020-06-24 03:16:20
问题 I'm having a huge block trying to understand "trees" while making a Tic-Tac-Toe bot. I understand the concept, but I can't figure out to implement them. Can someone show me an example of how a tree should be generated for such a case? Or a good tutorial on generating trees? I guess the hard part is generating partial trees. I know how to implement generating a whole tree, but not parts of it. 回答1: Imagine that at any point in a tic-tac-toe board, every single possible move is a branch. The

Game AI works powerfully on one side and becomes dumb on the other in Tic-Tac-Toe

笑着哭i 提交于 2020-06-23 18:06:08
问题 I am trying to make a Tic-Tac-Toe game in Python using PyGame and the MiniMax algorithm. The AI plays really well when given the first chance (playing as 'X'), but becomes dumb enough to help the user win when not given the first chance (playing as 'O'). I think I know what the problem is but changing it is messing with the whole program and is not going by the given docstrings. I've made two python files - one for the GUI (runner.py) and the other for the logic behind the game and the AI

Game AI works powerfully on one side and becomes dumb on the other in Tic-Tac-Toe

跟風遠走 提交于 2020-06-23 18:05:29
问题 I am trying to make a Tic-Tac-Toe game in Python using PyGame and the MiniMax algorithm. The AI plays really well when given the first chance (playing as 'X'), but becomes dumb enough to help the user win when not given the first chance (playing as 'O'). I think I know what the problem is but changing it is messing with the whole program and is not going by the given docstrings. I've made two python files - one for the GUI (runner.py) and the other for the logic behind the game and the AI