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

Tic-tac-toe ANN player with TensorFlow learn?

I am experimenting with ANNs as tic-tac-toe players using TensorFlow learn (formerly Scikit Flow) The simulator code is here. My current simple nn-based player scores around 90% vs. a random player, but cannot defend at all, as I don't know how to…
Bachi
  • 6,408
  • 4
  • 32
  • 30
4
votes
1 answer

Tic tac toe machine learning - valid moves

I am toying around with Machine learning. Especially Q-Learning where you have a state and actions and give rewards depending on how well the network did. Now for starters I set myself a simple goal: Train a network so it emits valid moves for…
4
votes
3 answers

Android Java Minimax implementation in a tic-tac-toe game

I'm trying to make a Tic-Tac-Toe Android application, of course in Java. After debugging for maybe a few hours, fixing things here and there, I have come upon a problem that I can not solve by myself at this time, with this knowledge. I have…
Filip Markoski
  • 333
  • 3
  • 19
4
votes
2 answers

Tic-Tac-Toe minimax algorithm doesn't work with 4x4 board

So I've been working on this project for the past 3 weeks now. I managed to get the minimax function to work early on for a 3x3 board, however problems started arising when I tried using it for a 4x4 board, namely Java heap space errors. Since then,…
Omar Sharaki
  • 360
  • 9
  • 34
4
votes
1 answer

Obtain the best move from MiniMax algorithm in Tic-Tac-Toe game

I'm trying to implement MiniMax algorithm based on Wikipedia pseudocode in Tic-Tac-Toe game written in C. However, I can't manage to obtain the best possible move. Here's my code: #include #include #include //…
user3812733
  • 165
  • 1
  • 9
4
votes
1 answer

Debugging Recursive MinMax in TicTacToe

I'm trying to get the minmax algorithm (computer AI) to work in my game of tic-tac-toe. I've been stuck on this for days. Essentially, I don't understand why the computer AI simply places it's marker ("O") in sequential order from board pieces 0-8.…
funfuntime
  • 261
  • 1
  • 8
4
votes
2 answers

TicTacToe resizable board, WIN method error

Hi just attempted a TicTacToe project and was stuck about an error. My error has to do with checking for win solutions specifically diagonals. What I need: Create nested loop to loop down the array diagonally, then incrementing it so it would scan…
Alex oh
  • 465
  • 1
  • 4
  • 6
4
votes
1 answer

An Issue in my Tic Tac Toe game code

I made a Tic Tac Toe game in C++. I did not know how to output a proper board, so I made a grid with an array labelled 1-9 to let the user punch in the number to tell the computer where to put his shot. The second player is the computer. I'm very…
4
votes
2 answers

Using the value of a computed function for a proof in agda

I'm still trying to wrap my head around agda, so I wrote a little tic-tac-toe game Type data Game : Player -> Vec Square 9 -> Set where start : Game x ( - ∷ - ∷ - ∷ - ∷ - ∷ - ∷ - ∷ - ∷ - ∷ [] ) xturn : {gs : Vec…
user833970
  • 2,729
  • 3
  • 26
  • 41
4
votes
3 answers

Reference clicked JButton inside ActionListener

I'm trying to write a Tic Tac Toe program using swing, but I seem to having some trouble. In my anonymous inner classes I attempt to set up the actionListener for each of my buttons, but I'm having trouble finding the type or the variable which will…
Amloelxer
  • 752
  • 2
  • 8
  • 20
4
votes
1 answer

Implementing a Minimax Algorithm in Clojure - conditional function with multiple recursive calls

This question and another question of mine sort of merged into one after I figured a few things out, so I revised this question. What I'm trying to accomplish with my function is outlined below. Iterate over all of the spots. If it's open, select…
rzv
  • 2,022
  • 18
  • 22
4
votes
2 answers

I have an identical codes in every buttons in my tictactoe game. How to make this short?

This tictactoe program is a 2player game. The GUI i made are frame and buttons after that i started coding. Actually my program is working in this kind of coding. private String letter= " "; private int count= 0; private void…
Jayseer
  • 189
  • 2
  • 7
  • 15
4
votes
1 answer

Hackerrank.com tic tac toe challenge

I want to ask is it possible to win at tic tac toe challenge? Because the judgebot knows each and every trick and he knows how to fail the trick moves . I am only able to tie the game in both turns . If it is possible , can you guys please just give…
4
votes
3 answers

TypeError: 'int' object is not callable' in Python 3.2?

so i'm coding a tic tac toe game in python 3.2 and i have spent night and day trying to fix this and going over my code, script, or whatever you want to call it, so many times and still can't find it. i've googled it and all the answers are all to…
Ali Lewis
  • 47
  • 1
  • 1
  • 6
4
votes
1 answer

Updates in Temporal Difference Learning

I read about Tesauro's TD-Gammon program and would love to implement it for tic tac toe, but almost all of the information is inaccessible to me as a high school student because I don't know the terminology. The first equation here,…