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

How to access public methods from a const reference to a class object

I'm trying to debug an issue within this c++ code that plays tic-tac-toe on a given game state using minimax to find best moves between the min (o) and maxer (x). I'm able to get the position of the move from the minimax function but when I try to…
Proxied
  • 31
  • 1
  • 3
2
votes
3 answers

checking for a down diagonal win in tic tac toe?

sorry if this is really basic! i'm in first year computer science. i am trying to write a function to check if there is a win on a tictactoe board of NxN size (so i can't hardcode any values); the win has to be from the top left, to the bottom…
spaced
  • 21
  • 2
2
votes
1 answer

IndexError: index 3 is out of bounds for axis 0 with size 3 pygame

working on a tic tac toe game, since I'm new to pygame, I don't know much so I'm using this project as a way to learn about pygame, anyhow I get this error randomly and don't know how to fix it, I tried looking on google but didn't find anything…
2
votes
1 answer

How do I fix an uncaught reference error for this TicTacToe

I am doing a HTML, CSS, JSS tictactoe project, and I have run into an error where the console ribbon/section (when right clicking and going to "inspect" in browser) has stated the following when I tried using the console.log in my text editor: …
2
votes
1 answer

I am having some problems checking the winner in a tic tac toe game using Turtle graphics

def isWinner (square) : (square[0] and square[1] and square[2]) (square[3] and square[4] and square[5]) (square[6] and square[7] and square[8]) (square[0] and square[3] and square[6]) (square[1] and square[4] and square[7]) …
Loui
  • 21
  • 3
2
votes
2 answers

3x3 Tic-Tac-Toe in C using Minimax

Note #1 - There is a similar question but that is in Python, and I can't figure out this in C. Note #2 - This is a human vs. AI game and I will call the AI as 'cpu'. The cpu symbol is 'O' and human symbol is 'X' always. Note #3 - I want to design…
Divyanshu Varma
  • 122
  • 3
  • 17
2
votes
2 answers

Sign not displaying on Pygame window when clicking (tictactoe)

I am coding a tictactoe game and I have something similar to the code in this link. When the board is clicked, it doesn't write anything (X or O). I can't seem to figure out what is the problem after trying multiple times. How could that be…
2
votes
2 answers

Solving TicTacToe with minimax algorithm in Javascript

let _board = [[null, null, null], [null, null, null], [null, null, null]]; let _flag = true; let _AIrowIndex = null; let _AIcellIndex = null; const _wrapper = document.querySelector(".wrapper"); const _changeTurn = function () { …
2
votes
2 answers

Button Moves Weirdly when text is filled in

That is the missalignmentSo, I wanted to program TicTacToe on a Webpage, using plain JavaScript, HTML, and CSS. I've made some logic, so the board can update based on the entries in an array, but when I do that, the buttons aren't in a line anymore,…
af2111
  • 301
  • 3
  • 12
2
votes
1 answer

Tic tac toe game in Discord (javascript) using classes, works first time around, then breaks in a weird way

I am quite new to javascript, and programming in general, and I am creating a Discord bot for my server for people to play games of tic tac toe against each other. With my limited knowledge of how javascript works and how this game is supposed to…
Max
  • 31
  • 1
  • 5
2
votes
1 answer

How to copy, print list and store values in function each time the function is called (Tic tac toe game)

I am a little confused on how parameters work and calling functions with return statements. I am trying to create a new graph from the old one so that if I play again it will start over. I have tried copying the list in the run function and printing…
user14128659
2
votes
1 answer

Reloading another user's page

Assume you have made an internet game of tic-tac-toe or sth that is played between players. So, when a player inputs 'x' or 'o' or whatever is the input, the opponent must receive it on his pc. I know how to make this with timer. But I'm interested…
Tsvetan
  • 289
  • 2
  • 15
2
votes
0 answers

How to correct the following one player tictactoe game?

I have made the following tic tac toe game which reads the current state of the board, stores it in entries, then I read a text file which has data in the format XOXXXO O:6where the part after : is the number of box the AI should choose on the basis…
2
votes
1 answer

IndexErrors in Tic-Tac-Toe program I'm having issues with

I've pasted the code here: X = "X" O = "O" board = [] EMPTY = "" def instructions_prompt (): print "\t\t\tNoughts and Crosses" print \ """Foolish human. Now that you've entered this Python program, there is no exit. None!…
Louis93
  • 3,843
  • 8
  • 48
  • 94
2
votes
5 answers

Change global variable from event function

I am trying to learn Javascript. I watched some Javascript course on Youtube and am trying to create my first project. Project should be simple tic-tac-toe game. Functionality: First click on box should fill with "X" Second click on another box…