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

Coding tic tac toe in C

I'm coding a game of tic tac toe in C. Here's the logic. The User goes first, selects a slot. The positions of the slot are calculated using simple formulae. Then the selected slot is filled. Next, the computer selects a slot, randomly. For this,…
Mahesh Kumar
  • 9
  • 1
  • 1
  • 2
-3
votes
1 answer

TicTacToe - generating solutions

Given a grid of nxn squares, where each square has an id, the first(top left) square has id 0 (so a 5x5 grid will have ids 0-24) like below: 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 I need to generate all…
-3
votes
1 answer

Function expected ) on tic tac toe game

iam making a tic tac toe on QBasic but I have a problem with a function and i don't know fix it The error is "Expected ) on current line" but i don't know where put ) FUNCTION HayGanador() as string 'the error is on this line FOR i = 1 TO 3 …
-3
votes
1 answer

TicTacToe using 2D array in java

public static void main(String[] args) { Scanner sc = new Scanner(System.in); char[][] board = { {'?','?','?'}, {'?','?','?'}, {'?','?','?'} }; System.out.print("Type any key to play the game and…
-3
votes
2 answers

Tic Tac Toe why is the script not working

Im trying to write a tic tac toe game with javascript and there is a mistake in the code that doesn't get displayed in the console can someone please tell me what is wrong with the script. var box = document.getElementById("box"); var subBox =…
-3
votes
1 answer

Issues with threads in game

I have been trying to make a basic tic-tac-toe game with some basic multithreading, but somehow both threads gain access to the synchronized statements, which is really confusing to me. Here is the code: import java.util.*; public class TicTacToe…
-3
votes
2 answers

Numerical Tic-Tac-Toe winning condition

This is a Numerical Tic Tac Toe game. I try to make the winning condition which is a row, a column or a diagonal add up to 15. However, the ' ' cannot be changed to integer. What can I do to avoid this? Here is the main problem part: local_board =…
Hu Jack
  • 65
  • 6
-3
votes
3 answers

How can I solve the cannot find symbol error in the isWon() & isFull() in my Tic Tac Toe program?

I am trying to compile this tic tac toe program but I keep getting cannot find symbol errors from the isWon() & isFull(). This is the class which contains the isWon() & isFull() import java.awt.*; import java.awt.event.*; import…
kinghabz 14
  • 7
  • 1
  • 2
-3
votes
2 answers

How to randomize two players to "X" and to "O?

I'm making a tic tac toe game and I have randomily assign player 1 one to either "X" or "O" and same with player 2. I have no clue how to start the code It should make player one either X or O and make player 2 whatever is left over from player 1
-3
votes
1 answer

Why is the char array empty after requesting another input from user?

I'm developing a TicTacToe in C, but I'm having trouble displaying the name of the players. Every time a player has to make a move, I display "It's your turn, %s!". But from the second iteration, the player name is empty. After some tests I figured…
Edson Passos
  • 117
  • 10
-3
votes
2 answers

Tic tac toe RNG

import random a = 1 b = 2 c = 3 d = 4 # I would like the random_number to be 5 random_number = random.randint(1,5) def function(): global random_number while True: random_number = random.randint(1,5) if random_number !=…
Kilianix
  • 1
  • 1
-3
votes
1 answer

x and o game java for loop

I am making a tic tac toe game. I have a class to implement few methods here is the code: package test; public class test { private String[][] board = new String[3][3]; public test() { } public void move(int x, int y) { …
john mac
  • 59
  • 1
  • 9
-3
votes
1 answer

Can a tic tac toe AI Minmax function be unbeatable at a depth of 3?

So, my assignment was to think of a good evaluation function so that the Tic Tac Toe AI we have designed using the Minimax algorithm would be unbeatable. The limits we had were to not change the source code for the rest of the game, and that the…
-3
votes
3 answers

Tictactoe game code

I created this game for many hours. I finished it without any syntax error. I try to play it but it doesn't work. I don't know why? Is there any problem with my code?