Questions tagged [tic-tac-toe]

Tic Tac Toe is a popular exercise for beginning coders, as the finite resources and game mechanics can be easily grasped and represented in many ways. As it is a short game, it is possible to create an algorithm that never loses.

The X player usually goes first. The player who succeeds in placing three respective marks in a horizontal, vertical, or diagonal row wins the game. The following example game is won by the first player, X.

screenshot

1551 questions
6
votes
1 answer

tic tac toe using alpha beta prunning in java

I am trying to play tic tac toe using iterative Alpha-Beta prunning, I have one second limit for a move but for some reason it doesnt work well. I modified the regular alpha-beta code so instead of returning alpha or beta, it returns a state (which…
Lena
6
votes
4 answers

Make the computer never lose at Tic-Tac-Toe

I am working on a simple game of Tic Tac Toe code for C. I have most of the code finished, but I want the AI to never lose. I have read about the minimax algorithm, but I don't understand it. How do I use this algorithm to enable the computer to…
C_Intermediate_Learner
  • 1,800
  • 3
  • 18
  • 22
6
votes
4 answers

Tic Tac Toe - Detecting win, lose, or draw

This is a tic tac toe generator. Computer vs. Computer only, a little different than the usual Player vs. Computer. I have most of my code written for this, but the issue I am having is sometimes when I generate the game, the whole board fills up…
6
votes
2 answers

Twist on tic tac toe

i'm writing a tictactoe program but its not your traditional tictactoe First of all the board is 4x4 and the way to win is to get 3 of a kind and 1 of your opponents in a row, column, or diagonal. So the following would be a win for "O" via first…
rage
  • 1,777
  • 5
  • 25
  • 36
6
votes
1 answer

Bug in Minimax Algorithm for Tic Tac Toe

I am currently trying to teach myself the Minimax algorithm and I have tried to implement it in java in tic tac toe. There is a bug in my algorithm however and I can't figure out what's causing it. Below is the complete source code (Sorry for wall…
ScoobyD
  • 63
  • 1
  • 4
5
votes
6 answers

Suggestion on Tic Tac Toe

I am designing my implementation strategy for Tic-Tac-Toe game. Since this is my 1st game implementation, I am a bit confused and need some general pointers. Now, the total number of winning combinations in a Tic-Tac-Toe are 8. Currently, I plan to…
name_masked
  • 9,544
  • 41
  • 118
  • 172
5
votes
3 answers

What is wrong with my minimax algorithm for tictactoe

I'm building a tic tac toe game for a fun learning experience. I have constructed a minimax algorithm to return the optimal move for the computer, but somehow I am going wrong and get wierd output like this TIC TAC TOE V1.0 --- --- --- Enter row,…
shane
  • 1,742
  • 2
  • 19
  • 36
5
votes
2 answers

How to change text size in basic text window win32 c++

I am making a very basic tic tac toe game as my first ever attempt at anything windows. I have only a small amount of basic c++ experience as well. At the top of my program i want it to display in a large font "WELCOME TO TIC-TAC-TOE!", and then…
Riley
  • 391
  • 1
  • 2
  • 11
5
votes
1 answer

Clojure: Iterating over a vector of vectors to find the first vector that meets a certain condition

To learn Clojure I'm working on a little Tic Tac Toe game. After completing the first part of the game with relative ease, I've struggled trying to build an intelligent computer player. For the test I'm writing to help guide this, I want to check…
rzv
  • 2,022
  • 18
  • 22
5
votes
3 answers

Tic Tac Toe with Minimax: Computer sometimes losing when Player goes first; works otherwise

I am working on a Minimax algorithm for unbeatable Tic Tac Toe. I need it to work both for when the Computer goes first as well as when the Player goes first. With the current version, the Computer will never lose when going first. However, it seems…
jneander
  • 1,150
  • 14
  • 34
4
votes
4 answers

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

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…
icepopo
  • 1,617
  • 4
  • 16
  • 13
4
votes
0 answers

Minimax algorithm AI not picking the correct choice

I have tried to impliment the minimax algorithm with alpha/beta pruning for a TicTacToe game I'm making in the Godot Engine, however, it doesn't seem to work as expected. The AI seems to always pick the next available spot on the board from left to…
4
votes
2 answers

Python turtle tic tac toe

I'm new to python and I programed a tic tac toe with an AI that plays against you. Everything is working but I used textboxes to inform the AI what the player chose. Now I want to upgrade my game so that the player can click on the box he wants to…
twinnxx
  • 49
  • 5
4
votes
2 answers

Android App gets crashed on clicking button

I am making a TIC TAC TOE game in ANDROID STUDIO 3.1.3 using Java. So when I am clicking button, the apps crashes. I am not able to find the reason why this is happening. Please, help. Code for button is as follows : public void playAgain(View…
Lone Wolf
  • 41
  • 4
4
votes
1 answer

find best move using alphabeta TicTacToe

Trying to find the best move as well as the score. I have gotten my program to correctly return the score of the game, but I want it to return the move as well. How can I change my code so that it does this? Similar to this and this. See my failed…
PAS
  • 149
  • 1
  • 8