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

Troubles positioning layouts to tic tac toe app - falling off screen

I am new to android development. I took a begginer course in Udacity last month. I'm having troubles with positioning my layouts properly cause there is always something which is not shown ot the screen and on diferent devices it is looking…
3
votes
4 answers

How to fix my function that checks for a full board in my tic-tac-toe game

I'm trying to build a tic tac toe game and I'm having trouble with making a working function to check if the board is full. my list for the board is board = [' ',' ',' ',' ',' ',' ',' ',' ',' '] and my function is def fullBoard(): """Returns a…
3
votes
2 answers

Tic-tac-toe rate a board algorithm

I've implemented a tic-tac-toe with ai but now im facing one problem, how to rate a board of tic-tac-toe game ? Maybe at start I will descript how it should work : We have n boards of tic-tac-toe game (with different variants) Our ai should rate…
3
votes
8 answers

In Python, how can I print out a board of numbers representing tic-tac-toe, with a "|" in between each number?

I want to be able to rewrite the code in as few lines as possible, possibly in list comprehension syntax. Here is what the output should be: 1|2|3 4|5|6 7|8|9 This is what I have thought up. The separator doesn't actually print the "|". Any…
Ricky Su
  • 295
  • 1
  • 7
  • 10
3
votes
1 answer

Unable to determine win condition in Tic Tac Toe

I have been trying to get my tic tac toe program to work for a while now. At the moment I'm stuck in the win condition. The game can now end as a draw but no player (human || computer) can win it. I need to determine the winning conditions…
jjimih
  • 89
  • 11
3
votes
2 answers

Clojure pmap returning different results than map

I am learning clojure, and implementing my standard test project, Tic Tac Toe 10. I have written the same AI in many languages before and have had problems scaling it beyond 6 moves ahead in the other languages also. I got the AI algorithm basically…
3
votes
2 answers

Tic Tac Toe Checking winner

Im having problems with the win code. Ive been trying for a really long time and i have no idea what the problem is. Ive tried debugging but i got nothing from that.(Sorry for the Swedish comments) import java.util.Scanner; public class Tictactoe…
Marc
  • 87
  • 7
3
votes
4 answers

Tic Tac Toe Random AI

I am working on building a Tic Tac Toe game with varying AI implementations for a computer opponent for the sake of learning different algorithms and how to implement them. The first I am trying which should be the easiest is just having the…
3
votes
7 answers

What algorithm would you use to solve a very large tic-tac-toe game?

A small (3x3, 4x4) tic-tac-toe can be easily solved by considering all the cases. But for example, you have a 30x30 tic-tac-toe. What algorithm would you use to decide the next best move in that case? Minimax + alpha-beta pruning is one way that I…
Lazer
  • 90,700
  • 113
  • 281
  • 364
3
votes
1 answer

Bug with Minimax Solution for Tic Tac Toe in Coffeescript

(note: this is not CS homework) I've tried implementing the minimax game-tree searching algorithm in Coffeescript, and continue to get errors with my algorithm. There appear to be 2 main issues: 1) the algorithm itself doesn't seem to return the…
Jeff Smith
  • 248
  • 1
  • 7
3
votes
3 answers

How to examine an Array for .Text values

This is for a tic tac toe game where the grid can be sized to any number (3x3 4x4 8x8 etc) When the form loads, a method reads the grid size and populates the form with that many buttons in a 1 dimensional Button Array. The Array is called…
BackDoorNoBaby
  • 1,445
  • 2
  • 13
  • 20
3
votes
0 answers

Python 3.2 Tic-Tac-Toe Artificial Intelligence

I came up with a simple AI for a Tic-Tac-Toe game that should cause the computer opponent to try to block my moves. Running the code brings up no errors, and the computer usually blocks me. However, it sometimes moves in a random spot on the board.…
Short Circuit
  • 43
  • 1
  • 4
3
votes
2 answers

String is overlapping another string

I know my code is a little messy but I will try to be as detailed as possible. The code is creating a TicTacToe game. I am using an array to create the game board which is the gameBoard(). The user is always X while the computer is always O. I've…
Halodoh
  • 53
  • 4
3
votes
3 answers

How to use random to select position in 2d array?

I have created a tic tac toe program that works in that it allows a player to select a move in a 2d array by selecting the cords, then the computer makes a move. The program works, but the computer's move is sequential rather then random and will…
3
votes
0 answers

Java Minimax TicTacToe

I am currently trying to implement a Minimax algorithm for Tic Tac Toe. With the current version, there are some cases, where the computer screws up, and I am not quite sure why. For example if I (as the human player) start with an x in the upper…
user1823479
  • 39
  • 1
  • 3