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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
54 views

Shortest possible tic-tac-toe in java? [closed]

I have been trying to make the classic game of tic-tac-toe in as few lines as possible, my current code is: import java.util.*; public class XXX { static char[] a = "---------"....
HiJello's user avatar
-2 votes
0 answers
20 views

Incorporating Sockets into Game [closed]

I coded a TICTACTOE game with a twist of having to guess the name of a song before claiming a tile. I just need to incorporate sockets into it, but I have no clue how. This is for a school project so ...
Santi Pastor's user avatar
0 votes
0 answers
53 views

My minimax function is not working properly (tic tac toe) How do I fix it? [closed]

Whenever I run my code and play the tic tac toe game against the computer and the computer can obviously win by placing one more X to get a win, it doesn't place it and instead places it somewhere ...
gem 1234's user avatar
-3 votes
1 answer
89 views

How do I make an output like this using Java for-loops? [closed]

1 2 3 4 5 6 7 8 9 I'm making a tic-tac-toe game with this;-; I tried a formula but it only turned out as 0 0 0 1 1 1 2 2 2 Would also really ...
akari's user avatar
  • 9
-1 votes
1 answer
43 views

Why is it that my program registers when X has three in a row but not when O does?

I am creating a tic tac toe game, and when three X's are in a row, I get a message that X won but when three O's are in a row, no message pops up. I can't seem to spot the problem. Can you point me in ...
DurianDragon's user avatar
0 votes
0 answers
37 views

Python tic-toc-toe ai doesn't choose the best move

I have an tic-tac-toe game and i would like to add an ai to it. I also would like to use minmax so it always chooses the best move to win the game, i added the minmax formula but it doesn't work, it ...
OsmanBurcu's user avatar
0 votes
0 answers
42 views

How to make a label in tkinter, at an angle?

I'm writing a tic-tac-toe game. When winning, I use the label as a line, but please tell me how to make the label at an angle? In this case I need a diagonal line I was looking for a solution to ...
AV Postol's user avatar
-1 votes
1 answer
87 views

Tic-Tac-Toe with minimax can be beaten in middle row or middle column. How to fix it so it becomes unbeatable?

As part of a course, I tried to implement minimax in a game of Tic-Tac-Toe in which the human player plays first (marker 'X', adds 1 to array) and the computer plays second (marker 'O', adds -1 to ...
Adrian's user avatar
  • 31
-2 votes
1 answer
46 views

How to create Infinitely scrolling grid board for tic tac toe game?

I'm new to unity and I have been searching all over the internet for about 5 days now about how to create an infinity board for the Tic Tac Toe game and what the winning combination would be in the ...
Ombeni Tango's user avatar
0 votes
1 answer
22 views

MInimax function not working properly in next js

SO i wrote this code in next js. For some reason, it is not working properly. I've tried almost everything but still it's not working properly. I even tried using alpha beta pruning but it still isn't ...
Animesh Acharya's user avatar
0 votes
2 answers
98 views

How to properly implement Minimax AI for Tic Tac Toe?

I want to implement Minimax AI for Tic Tac Toe of orders 3, 4, 5. Rules of the game: For an order n Tic Tac Toe game, there is a board comprising of n rows and n columns, for a total of n2 cells. The ...
Ξένη Γήινος's user avatar
0 votes
1 answer
32 views

Creating a Responsive Tic Tac Toe Field Layout in Flutter

I'm currently working on implementing a responsive Tic Tac Toe field in Flutter, and I've encountered a layout issue. I've managed to display the "cross" and "circle" symbols, but ...
dracule22's user avatar
2 votes
2 answers
92 views

Efficient way to implement Minimax AI for Tic Tac Toe orders 3, 4, 5?

I want to create an artificial intelligence that plays Tic Tac Toe better than any human. I have already written a completely working GUI Tic Tac Toe game with AI players, but all those AI players are ...
Ξένη Γήινος's user avatar
0 votes
0 answers
77 views

Why does utilizing a simple strategy of Tic Tac Toe lower the AI's win rate?

I have a huge project that is a GUI Tic Tac Toe game, it has 6 AI players and offers you the opportunity to customize the UI. I have completed what I originally intended and posted it on Code Review, ...
Ξένη Γήινος's user avatar
0 votes
0 answers
50 views

Problem with Q-learning/TD(0) for Tic-Tac-Toe

I have some bug in my code that apparently prevents my actors from learning the game properly. The code is an implementation of tabular q-learning, where the intention is to simultaneously train two ...
John Klint's user avatar
-2 votes
0 answers
38 views

pygame adds more than it should [duplicate]

I am making a simple game but pygame is not working as it should. here is the code: import pygame from sys import exit from debug15 import debug15 pygame.init() CROSIRCLE = 1 def layoutdraw(): ...
CyanK's user avatar
  • 5
0 votes
1 answer
29 views

X takes two turns before switching to O

I've added a restart function to my tic tac toe game but when X wins and I hit restart, X is the first move by default but it takes two turns to switch to O. const board = document.getElementById('...
Joe.sexton's user avatar
0 votes
0 answers
54 views

Title: Unpredictable "You Win" / "You Lose" Outcome in Tic Tac Toe Game

I'm looking for guidance on how to approach debugging this issue and ensuring that the displayed message accurately reflects the game's outcome. What I've Tried: I've reviewed my code for any logical ...
Mamtaganesh Gupta's user avatar
0 votes
0 answers
42 views

Validating inputs for a 2D- Character Array

I have some code that I am working on, and I am stuck. How do I check a 2D character array for correct character(s) input? I am simulating a tic-tac-toe game, and only want 'x' and 'o' for my inputs, ...
Adrian Pena's user avatar
0 votes
0 answers
56 views

Issue with first move of tic tac toe game

this is my first post here, and would like to ask for some help with my coding project my partner and I have been working on. I'm new to programming and C in general, and am having an issue with this ...
birdawesome's user avatar
-2 votes
1 answer
69 views

TicTacToe game in java, X's not showing up

I am working on a java assignment. It is a follow along with a video. After adding in the isGameFinished method, my board no longer shows the X's. ( I have been running it as I go along, and haven't ...
Puddy Dub's user avatar
0 votes
1 answer
81 views

How can I alternate between 2 players in a Tic-Tac-Toe game in Python Turtle?

I am taking a computer science class and our first project in Python (turtle) is a little Tic-Tac-Toe game. The project is nearly complete BUT I am struggling to figure out how to alternate between 2 ...
cvoz's user avatar
  • 9
-1 votes
2 answers
50 views

onClick event isn't working in SVG Tic Tac Toe

I am currently working on creating a Tic Tac Toe game and have the code to make the x and o's appear. However, the onclick event isn't always being called when the squares are clicked, and randomly ...
Maddy Young's user avatar
0 votes
1 answer
91 views

How to make a 3 in a row detection system in tic tac toe?

I'm making a tic tac toe game, I've implemented marking down the fields that aren't taken. There is a turn based system, which switches the players mark after one of the fields is marked. The problem ...
Miloš Milosavljević's user avatar
0 votes
0 answers
50 views

Issue with win calculation when the computer wins in my 'TicTacToe' app

I am currently developing a Swift-based app to play Tic-Tac-Toe, and I've encountered an issue with correctly calculating wins when playing against the computer. In my app, I've implemented logic to ...
AranAli's user avatar
  • 21
2 votes
0 answers
59 views

Debugging AI Tie Logic in NegaMax Algorithm for Tic Tac Toe in p5.js [closed]

Question: I'm currently working on a Tic Tac Toe game using the minimax algorithm in p5.js, and I've encountered an issue with the AI's behavior. Despite my efforts, I can't seem to get the AI to work ...
VkQuads's user avatar
  • 31
0 votes
1 answer
25 views

How to "Connect" two variables between two React Components?

import Board from './components/Board'; import Header from './components/Header'; function App() { return ( <div className="App"> <Header /> <Board /> ...
Bashov's user avatar
  • 1
0 votes
0 answers
46 views

Making the reset function for Tic Tac Toe game to work

I've been working on a short Tic Tac Toe game in Javascript, and all looks good. However, when I try to add the reset function, it either creates a new table or an element in the button area. My goal ...
meii18's user avatar
  • 11
0 votes
1 answer
108 views

Depth never reaching 0 in depth-limited minimax algorithm

I have been trying to code an AI for a traditional Turkish game "3 Stones" ("3 Taş" in Turkish), a variant of Three Men's Morris. Background: The game The game is played as follows....
senessenes's user avatar
0 votes
2 answers
82 views

How do I change the colour of a player in tic-tac-toe game?

I'm making a tic-tac-toe game in JS. Code is below. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-...
user40414's user avatar
-1 votes
1 answer
63 views

TicTacToe game not taking users input

Im making a tictactoe game, everything works fine so far but its not taking my coordinates, I need the icon that is given to me to be put where im writing it to go on the board. Here's my code: Main ...
daniell e's user avatar
0 votes
0 answers
68 views

Tic Tac Toe vs Bot game - After a sequence has been made the bot still makes a move

I'm creating a tictactoe game with a bot in react Problem statement: Design a basic 1 player TicTacToe game in React. Functionality: ● Player opens the app(site), selects his symbol (‘X’, ‘O’) and ...
Aman Shrivastava's user avatar
0 votes
1 answer
49 views

TicTacToe react - sequence highlighting

Can anybody study my code and tell me how to get the sequence highlighted in the Tic Tac Toe game? Below is my code. Board.jsx import React, {useState } from "react"; import Square from &...
Aman Shrivastava's user avatar
0 votes
1 answer
57 views

How to reset board for tic tac toe in javascript?

function resetBoard() { currentPlayer = 1; isGameStarted = false; gameBoard = [ [null, null, null], [null, null, null], [null, null, null] ]; const ...
anonimous23's user avatar
0 votes
0 answers
24 views

Whenever I am removing the already existing text from the button tag or adding a txt to an empty button tag, the button element's position is changing

So, I have this code written in react for a simple tic tac toe game where i am creating the grid squares using 9 button tags. My issue is that whenever i am removing the X / O (these are x and o from ...
Saeed Ahmed's user avatar
0 votes
1 answer
62 views

MVVM - Grid not updating when directly updating collection in WPF

I'm trying to implement a Tic Tac Toe game in WPF using the MVVM design pattern. The game works fine right now, but the problem appears when I try to reset the game to start over. In that case what I ...
magmyr01's user avatar
0 votes
1 answer
37 views

Why is the game ending a draw when player wins in python Tic Tac Toe

I've been creating a tic-tac-toe game, the game works fine. The player can win, lose and tie. The problem is when all 9 tiles have been used and there's a win or loss, the draw messagebox appears ...
twigMURR's user avatar
1 vote
1 answer
54 views

How can I disable clicks after winning status

I have tried so many concepts but finally not able to conclude the answer. I have made a tic-tac-toe game, which is fully functioning but I have a problem where, when I my winning status is displayed ...
Ujjawal's user avatar
  • 51
3 votes
1 answer
71 views

Have 2 array with 5 number between 0-8,go through array if any possible combo match the numbers in array. if yes say winner. Combos = given in my ans

Ans : var p1arr = []; var p2arr = []; const GameBoard = (() => { const PlayerFactory = (name, mark, turn) => { return { name, mark, turn } }; const player1 = PlayerFactory(&...
Ujjawal's user avatar
  • 51
3 votes
1 answer
89 views

My minimax algorithm loses to me, but seems flawless

I'm trying to code a tic-tac-toe bot using the minimax algorithm in python. My code seems like it should work to me, but misevaluates positions, searches too many or too few nodes and loses to me ...
Alexand's user avatar
  • 31
0 votes
0 answers
20 views

How to flush print statement to Button in Android Studio?

I am making a simple tic tac toe game and I want to immediately print the X's and O's when a player presses a button. Just like how you could flush a print statement and immediately have the buffer ...
Ahmed Salman's user avatar
0 votes
1 answer
108 views

Tic Tac Toe game -Udemy python milestone project 1 issues

I am learning to use Python from Udemy Zero to Hero course and am really struggling with the milestone#1 project. I am creating a very simple tic tac toe game and I have gotten only has far as ...
Josh Fellus's user avatar
0 votes
1 answer
73 views

Minimax Algorithm for Tic-Tac-Toe not responding as expected

I recently decided to try and implement a very basic API to return the best move for a game of tic-tac-toe. I wanted to, as much as possible, write and implement the code myself. I have what I thought ...
Danyal Ahmed's user avatar
-1 votes
2 answers
54 views

Having trouble with my Draw function for tictactoe

ive been learning javascript for several months and i started creating small projects to the best of my ability , i still struggle a lot but i feel like im improving. I'm creating a tictactoe game ...
Gzus24's user avatar
  • 31
1 vote
2 answers
34 views

How do I pick position of tictactoe field by number input (0-8)?

So I'm trying to refine my high school project by trying to restart at making a Tic-Tac-Toe Neural Network. However I can't wrap my head around how to set a cross or a circle at a position in the tic-...
tryg's user avatar
  • 13
0 votes
0 answers
196 views

gym.error.NameNotFound: Environment `tic_tac_toe:tictactoe doesn't exist

I am following a tutorial to create my own openAI gym environment for Tic Tac Toe but have run into the following error: Traceback (most recent call last): File "c:\Users\geniu\tictactoeproj\...
Skipper1504's user avatar
0 votes
1 answer
51 views

JavaFX: Why doesn't my MinMax algorithm make a move when it starts a TicTacToe game?

I have a working MinMax algorithm, tested in other situations, the JavaFX implementation doesn't work when the computer (MinMax) has to make the first move, I have to click first. There is a bug in ...
reizorwins's user avatar
-1 votes
1 answer
52 views

How to break the while loop?

So I have been coding tic tac toe, but the issue is once one side gets 3, the function won't register and the code continues. Can anyone give me insight to why this is happening? I ran the code ...
Joel Joseph's user avatar
0 votes
4 answers
171 views

Tic Tac Toe Board

I am doing The Odin Project right now and I am on the Tic Tac Toe project. I am sure this will be very difficult for me but I am looking forward to it. However, I am here to ask for help with setting ...
Natsu's user avatar
  • 49
0 votes
0 answers
16 views

trouble with minimax tree in the CS50 tictactoe [duplicate]

after watching https://learning.edx.org/course/course-v1:HarvardX+CS50AI+1T2020 (CS50 course) I was assigned to create an AI that could play tic-tac-toe via a minimax tree. However I'm having trouble ...
jake is the coolest's user avatar

1
2 3 4 5
32