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
2 answers

Simple C Tic Tac Toe Input Errors

I'm currently attempting to learn C, and decided to make a simple Tic Tac Toe "game". I'm not trying to do anything fancy, I only want to take a user's position and their given character and put it in my grid. I haven't started with arrays or…
2
votes
1 answer

X is not defined in Tic-Tac-Toe

I am using the code below to play Tic-Tac-Toe. However, when I run it I get this error: PS C:\python33> python tictactoe.py Welcome to Tic Tac Toe! Do you want to be X or O? 0 Traceback (most recent call last): File "tictactoe.py", line 145, in…
Robert Birch
  • 251
  • 2
  • 4
  • 16
2
votes
1 answer

Tic Tac Toe (Conditional)

For Some reason when I programmed getWinner() it only works in 2 cases (for the last row). I have everything else as far as diagonals and columns, but row 2 (well, three, but arrays, so 2) only works with o's basically. x's only win when o's are in…
2
votes
2 answers

Better design to evaluate Goal States for Tic-Tac-Toe using Numpy

I am trying to build a m*n Tic-Tac-Toe using numpy to maintain my game-state. To evaluate a win, we need atleast 'q' continuous blocks of an element in either row, columns or along the diagonals. (3 in case of the original tic-tac-toe). One crude…
Darshan Pandit
  • 178
  • 2
  • 8
2
votes
3 answers

Tic tac Toe javascript stop switching turns after winner has been announced

i'm stuck with my tic tac toe program for what seems like the 100th time. I am running my program through selenium and everything works fine except that if there is a winner announced it will still switch turns and click another box. for example if…
user3025364
  • 35
  • 1
  • 7
2
votes
2 answers

How to I add numbers to the top of my tic tac toe program?

I wrote a tic-tac-toe program. The board I made looks like this: 1 __|__|__ 2 __|__|__ 3 | | The way I have set up the coordinates is that the first box is (1,1), the second (1,2), the third (1,3), the forth (2,1) etc. I wrote the 1, 2, and…
user2759592
  • 261
  • 1
  • 2
  • 10
2
votes
2 answers

Display a tic-tac-toe board with image icons in labels

My problem is this: (Game: display a tic-tac-toe board) Display a frame that contains nine labels. A label may display an image icon for X or and image icon for O. What to display is randomly decided. Use the Math.random() method to generate…
Khilmarsen
  • 107
  • 4
  • 5
  • 10
2
votes
0 answers

jQuery tick-tac-toe clearboard issue

i have tried to make tictactoe using jQuery its working fine but issue is when clear board one of the field fill automatically,is there any way to prevent it after clear board. here is my code.Just need to prevent element filled automatically…
user2477139
  • 608
  • 1
  • 6
  • 21
2
votes
1 answer

Tic Tac Toe MiniMax in C#?

I'm sorry if this sounds very simplistic, but I've been researching for a couple of days now on how to implement AI into my Tic Tac Toe game. I have a two player game already made that I am very happy about but I have no idea how to put the AI into…
Rowan
  • 57
  • 1
  • 6
2
votes
7 answers

Pruning Tic Tac Toe Moves

I've written a tic tac toe code that fine to a point. I have Alpha-Beta Pruning working also. I've ran across a problem that I need ideas, NOT CODE. How can I choose a move that will win in 4 moves versus a move that will win in 8 moves. The problem…
John
2
votes
1 answer

Accepting only integers for TIC TAC TOE

Here's this TIC TAC TOE Game i have created using Python.. import os os.system('cls') i = 0 #Exiter def exithoja(): import sys raw_input sys.exit() #Displays Win or Draw def diswin(name,grid): i = checkwin(grid) …
Kunal Gupta
  • 449
  • 3
  • 22
2
votes
5 answers

C++ character array holding integer values

I'm trying to create a dynamic char array which will contain numbers then change these to either a X or 0, I'm creating a tic tac toe game which creates a grid to a specific number you want, the array needs to contain all numbers for the squares and…
nats0128
  • 509
  • 5
  • 18
2
votes
2 answers

JavaScript Tic Tac Toe - Finding All Possible Combinations of Numbers within an Array

I am currently writing a basic Tic Tac Toe game (multiplayer, no AI) using web (HTML, CSS, Javascript). The game logic obviously is all within the Javascript. I have a question. The following is my code. window.onload = function () { …
jeet.m
  • 553
  • 4
  • 15
2
votes
2 answers

not able to check if a square is empty tictactoe game jquery

I'm coding a tictactoe game but the code which I'm using to check whether the user is clicking on an empty square or already filled is not working for me please see what mistake I am doing function startgame(){ var $board=$('#board'); …
decoder
  • 137
  • 3
  • 12
2
votes
1 answer

How do I get one client thread to sleep, in order for the another client to execute?

I am working on a client/server Tic-Tac-Toe game that consists of one server, and a client that consists of two threads. The entire program includes a TicTacToeServer class, TicTacToeService class, and TicTacToeClientPanel (which is the GUI and the…