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
-2
votes
1 answer

Why my TicTacToe game doesn't complete running the codes? (Python 2.7.9)

When I run my codes,it gets stuck after I choose wether to play first or not. So, here is the codes: #TicTacToe game import random null = '' new = ['','','','','','','','',''] Player = '' Computer = '' #X or O signs def sign(Player, Computer): …
Naity
  • 11
  • 3
-2
votes
1 answer

Tic-Tac-Toe VS. CPU Mode stopping after 3-4 turns played (JAVA SWING)

I've made a Tic-Tac-Toe game, and yes some of you probably think my program is not very good. I am a new programmer and have never used swing or anything related to a JAVA GUI before this game. The program works, MOSTLY. When you compile and run it,…
Sam Mitchell
  • 194
  • 2
  • 18
-2
votes
1 answer

Minimax Algorithm behaving unexpectedly

I am trying to implement the Minimax algorithm for Tic Tac Toe, and just can't seem to get it run correctly. I have tried re-writing it several times, but it is not giving correct output. Here is the code for MinimaxGame.java, that implements the…
-2
votes
3 answers

Trouble with my brackets

I am coding in Java and I have a final project due friday and I've done the whole thing but I can't fix my brackets at the end so the whole thing is messed up. Also for some reason the tag List won't work in my code. Please see below. I know they…
-2
votes
2 answers

tic tac toe assignment in Python 3.3.5

I'm almost done with an assignment to make a tic-tac-toe game, but for the life of me I can't work through an error I'm encountering in it upon execution. Any advice would be immensely appreciated. Code link: http://pastebin.com/k7deVCAD error upon…
AndyM3
  • 183
  • 1
  • 4
  • 13
-2
votes
2 answers

Need explanation for Javascript TicTacToe-Game

I'm looking for an explanation why this code in Javascript works. Idea looks as follow: * 273 84 * \ / * 1 | 2 | 4 = 7 * …
-2
votes
1 answer

Best algorithm for implementing Tic Tac Toe - Generic (3X3 or 4x4 or 9x9 etc)

Can anyone help me. Which is the best algorithm to implement a TicTacToe game. I need to write the code in a way that it should be generic and should be able to handle more complex levels in easier way (generic way) from wher can I start? I read…
Deniz
  • 12,332
  • 10
  • 44
  • 62
-2
votes
1 answer

Java Tic Tac Toe AI not working

My AI code for a computer player is not working as expected. I want it to play a random move, but block an opponent's incoming winning turn. However, it sometimes stops working altogether, and other times plays a specific move even though there is…
-2
votes
1 answer

tic-tac-toe program in cpp not running

I wanted to implement tic-tac-toe in c++ using alpha beta pruning.I used this link for helping me out. http://www.ntu.edu.sg/home/ehchua/programming/java/JavaGame_TicTacToe_AI.html I wrote this code in c++.But this is not running. Everytime the…
user3660655
  • 45
  • 1
  • 7
-2
votes
3 answers

Tic-Tac-Toe in Java using 2-D arrays

I've run into some trouble while trying to code a simple tic-tac-toe program. My issue lies in the checkForWinner method, which was provided to us as part of the exercise. When I try to compile the program gives me the following error…
user3385542
  • 59
  • 1
  • 4
  • 12
-2
votes
4 answers

Tic Tac Toe program: expected identifier and expected constant errors

I have a tic tac toe game worked up here, but i keep getting these errors: [Error] expected declaration before '}' token [Error] expected unqualified-id before numeric constant [Error] expected '}' before numeric constant [Error] expected identifier…
-2
votes
2 answers

c++ tic tac toe with coard.h board.cpp player.h player.cpp game.h game.cpp and main.cpp I want to make some changes

I've been using this code for my TicTacToe game but I want to make some changes: first I want to introduce the name of the players, and when one of them wins, it appears on the message. second, I want to introduce a ranking table of records,…
-2
votes
1 answer

Tic-Tac-Toe AI picks wrong position

I am making a C program of Tic-Tac-Toe. I am trying to make the AI invincible at the moment but I have encountered a problem. The problem is that the AI just prints the symbol in the next available question. Why? And how can I fix it? Here's my…
-2
votes
2 answers

Tic Tac Toe invincible AI code issue

I have decided to make a C program of Tic-Tac-Toe. I am trying to make the AI invincible at the moment but I have encountered a problem. And I wrote this: int getFutureScoreOfMove(char square[][columns], char turn) { int row, column,…
-2
votes
2 answers

Need help in creating a tic-tac-toe game

I am creating a tic-tac-toe game in PHP. I take value from user as integer position in a grid like- 1 | 2 | 3 ---|---|--- 4 | 5 | 6 ---|---|--- 7 | 8 | 9 I store the value entered by user as a CVS in session. Like if user creates X in Ist row…
1 2 3
99
100