tic-tac-toe

Tic Tac Toe perfect AI algorithm: deeper in “create fork” step

♀尐吖头ヾ 提交于 2019-12-02 18:20:25
I've already read many Tic Tac Toe topics on StackOverflow. And I found the strategy on Wikipedia is suitable for my presentation project: A player can play perfect tic-tac-toe if they choose the move with the highest priority in the following table[3]. 1) Win: If you have two in a row, play the third to get three in a row. 2) Block: If the opponent has two in a row, play the third to block them. 3) Fork: Create an opportunity where you can win in two ways. 4) Block Opponent's Fork: Option 1: Create two in a row to force the opponent into defending, as long as it doesn't result in them

C++ Tic Tac Toe Game

不想你离开。 提交于 2019-12-02 14:39:34
I am so confused. I am trying to create a tic tac toe game using windows c++ visual. So far I was doing good until I kept getting errors. I tried looking for help but none of the answers seemed right. This is my practice problem. Implement displayBoard to display Tic Tac Toe board. Prompt User for a box on the board to select, i.e. a number between 1 and 9 with 1 being the upper left corner. use cin.get(box) to get the box number and isdigit to verify it is a number; 1 | 2 | 3 4 | 5 | 6 7 | 8 | 9 If the box is available put the appropriate X or O in there and switch players, i.e. X becomes O

Generate a list of all unique Tic Tac Toe boards

久未见 提交于 2019-11-30 20:06:32
I would like to generate a text file containing all 19,683 Tic-Tac-Toe board layouts in the structure of 0 = Blank, 1 = X, and 2 = O. Unfortunately math is not my strong suit and I cannot seem to find any examples of this anywhere. This isn't for homework I assure you. I intend to run this data through a Minimax calculator in order to generate an image that contains RGB values representing the optimal move based on the board setup. I am developing Tic-Tac-Toe for a platform that does not support functions (it's event-driven) so I will convert the board to a number in my game and then lookup

Generate a list of all unique Tic Tac Toe boards

随声附和 提交于 2019-11-29 19:33:50
问题 I would like to generate a text file containing all 19,683 Tic-Tac-Toe board layouts in the structure of 0 = Blank, 1 = X, and 2 = O. Unfortunately math is not my strong suit and I cannot seem to find any examples of this anywhere. This isn't for homework I assure you. I intend to run this data through a Minimax calculator in order to generate an image that contains RGB values representing the optimal move based on the board setup. I am developing Tic-Tac-Toe for a platform that does not

Hello I am creating a TicTacToe game for myself to understand Java better

三世轮回 提交于 2019-11-29 13:05:50
however I am not sure where I am supposed to enter the whoWins() method. Do I enter this method in the actionperformed Method of the buttons or do i need to something different. Please help. public class TTT extends JFrame implements ActionListener { private JButton buttons[] = new JButton[9]; private JButton exitButton; public JLabel title; public JPanel titlePanel, panel; private int count = 0; int symbolCount = 0; private boolean win = false; public TTT() { title = new JLabel("Welcome to my Tic Tac Toe Game!"); titlePanel = new JPanel(); title.setFont(new Font(Font.SERIF, 0, 30));

Tic-Tac-Toe minimax algorithm doesn't work with 4x4 board

本秂侑毒 提交于 2019-11-29 11:13:26
So I've been working on this project for the past 3 weeks now. I managed to get the minimax function to work early on for a 3x3 board, however problems started arising when I tried using it for a 4x4 board, namely Java heap space errors. Since then, with the help of Alpha beta pruning, I've managed to bring down the number of required minimax calls within the minimax function from aprox. 59000 to 16000 to 11000 and then finally to 8000 calls(This is assuming an initial minimax call for a board with one slot already filled). The problem now however, is that the method just keeps running for 4x4

How to determine game end, in tic-tac-toe?

一世执手 提交于 2019-11-28 06:07:21
I'm developing tic-tac-toe game, and I need algorithm to check when game ends(and who win). In 3x3 game I would check each possible win-situation(there is 8 capabilities). But in 7x7(needed 4 signs in a row or collumn, or diagonal)is a lot of possible win patterns. While a very basic approach is to look at runs in all the directions from every single cell, here are an approach then only ever checks a cell in a single "line" once. A "line" is a row, column, or diagonal that can possibly win, like in a Vegas slot machine :) For each "line", move to start of that "line" and; Set counter to 0. For

Tic-Tac-Toe minimax algorithm doesn't work with 4x4 board

帅比萌擦擦* 提交于 2019-11-28 04:38:44
问题 So I've been working on this project for the past 3 weeks now. I managed to get the minimax function to work early on for a 3x3 board, however problems started arising when I tried using it for a 4x4 board, namely Java heap space errors. Since then, with the help of Alpha beta pruning, I've managed to bring down the number of required minimax calls within the minimax function from aprox. 59000 to 16000 to 11000 and then finally to 8000 calls(This is assuming an initial minimax call for a

Minimax explained for an idiot

无人久伴 提交于 2019-11-27 14:44:16
问题 I've wasted my entire day trying to use the minimax algorithm to make an unbeatable tictactoe AI. I missed something along the way (brain fried). I'm not looking for code here, just a better explanation of where I went wrong. Here is my current code (the minimax method always returns 0 for some reason): from copy import deepcopy class Square(object): def __init__(self, player=None): self.player = player @property def empty(self): return self.player is None class Board(object): winning_combos

Code Golf: Tic Tac Toe

混江龙づ霸主 提交于 2019-11-27 11:06:57
Post your shortest code, by character count, to check if a player has won, and if so, which. Assume you have an integer array in a variable b (board), which holds the Tic Tac Toe board, and the moves of the players where: 0 = nothing set 1 = player 1 (X) 2 = player 2 (O) So, given the array b = [ 1, 2, 1, 0, 1, 2, 1, 0, 2 ] would represent the board X|O|X -+-+- |X|O -+-+- X| |O For that situation, your code should output 1 to indicate player 1 has won. If no-one has won you can output 0 or false . My own (Ruby) solution will be up soon. Edit : Sorry, forgot to mark it as community wiki. You