I am having trouble figuring out an efficient way to perform the checks for how a winner is determined in a 3D tic tac toe program (that is 3x3x3). Winners can be three spaces in any vertical, horizontal, or diagonal, including those between the 3 "boards." There are over 50 winning possibilities, but I'm not sure exactly how many there are. The grid is represented by the 3D array [COLOR="Red"]char grid[3][3][3][/COLOR]. My intention is to check every possible winning combination by adding up the ASCII values held by each position (which will either be a ' ', 'X', or 'O', …

Member Avatar
Member Avatar
+0 forum 6

I am a beginner in C++ programming and I badly need help. I just need some tips for programming a tic tac toe game that asks the user how many times they want to play, and should track how many times they win. Also, this program should not use arrays. PLEASE HELP?

Member Avatar
Member Avatar
+0 forum 3

**Tic-Tac-Toe without a class** Write a modular program that allows two players to play a game of tic–tac-toe. Use a two-dimensional char array with 3 rows and 3 columns as the game board. Each element of the array should be initialized with an asterisk(*). The program should display the intial board configuration and then start a loop that does the following. · Allow player 1 to select a location on the boardfor an X by entering a row and column number. Then redisplay the board with an X replacing * in the chosenlocation. · If there is no winner yet …

Member Avatar
Member Avatar
+0 forum 3

I am having trouble with writing a tic tac toe program. My code executes just fine if the first move results in a win. If it doesn't the code just stops. It doesn't finish but it does not continue to run. Can someone help? Must start with the game board already at: - x o - - - o - - Here is my code: [CODE] #include <iostream> #include <cstdlib> #include <string> using namespace std; int winner(char tic[][3],int size, bool& finished); //determines winner. void currentGame(char tic[][3], int size); //inputs current game board. void displayGame(char tic[][3],int size); //displays current game board. …

Member Avatar
Member Avatar
+0 forum 2

I have an alpha beta interface and have implemented a tic tac toe class from it. For some reason my AI tends to occasionally make stupid moves (such as making a fork rather than blocking a 2 in a row) I was wondering if anybody can see where I went wrong: StaticTicTacToe class: [CODE]class StaticTicTacToe:public IAlphaBetaPlayer { private: bool isX; LABRandom r; public: StaticTicTacToe(bool isX):isX(isX),r(){} virtual double evaluate(IGameState &gs) { if (gs.ID()!=TICTACTOEID) return 0.0; char *s=(char*)gs.data; char tiars[8][3]={ {s[0],s[1],s[2]},{s[3],s[4],s[5]},{s[6],s[7],s[8]}, {s[0],s[4],s[8]},{s[2],s[4],s[6]},{s[0],s[3],s[6]}, {s[1],s[4],s[7]},{s[2],s[5],s[8]}}; double ret=50.0; for (int i=0; i<8; i++) { //1st check for win if (tiars[i][0]==tiars[i][1]&&tiars[i][1]==tiars[i][2]) { if (isX) { if …

Member Avatar
Member Avatar
+0 forum 12

I have the task of writing a function to determine the outcome of a game of tictactoe, i at first thought use a couple of for loops but that proved pointless, and then the only way i could think of was to write an if...elif...else statement for each row, column and diagonal. which isnt very impressive, so can anyone show me, or hint at a way to do this? below is exactly what it says on the site. [CODE] In the pencil-and-paper game, Tic-tac-toe, 2 players take turns to mark 'X' and 'O' on a board of 3x3 squares. The …

Member Avatar
Member Avatar
+0 forum 1

can anybody help me making this program? i've based my game from this site. [url]http://www.education.com/activity/article/Tick_tack_toe_Added/[/url] hope that someone can help me.. i've been stuck coding that for almost 6hrs but still no progress. thank you!

Member Avatar
Member Avatar
+0 forum 12

Hi! Im a beginner in programming, and I have been given an assignment to program a TicTacToe game. I could not find any programs as such for reference over the Interwebs thus would want the expertise of daniweb users to help. The problem im having: 1. How do i transfer the input from the main method to the getBoard constructor method. Just how do i transfer the input from the main method to userInput in the if statements in the constructor class. 2. when the user enters an input it can replace an input already on the board(That is ofcourse …

Member Avatar
Member Avatar
+0 forum 5

I'm trying to make a Tic Tac Toe game for my Java class. I am not able to use JButtons only JPanels. I'm stuck on the part where my program determines if there are 3 x's or o's in a row. [CODE] public void winner() { if(3 = tictactoe[0].turn + tictactoe[1].turn + tictactoe[2].turn) { System.out.println("X has won"); } } [/CODE] I had established turn as being a 1(x) or a 2(o). If 3 panels in a row [0] + [1] + [2] = 3 then it would mean that "x" had won. I need to add more to it to …

Member Avatar
Member Avatar
+0 forum 2

[CODE] package semBreak; import java.io.*; public class YLingaw { public static void main (String [] args) throws IOException { BufferedReader jill = new BufferedReader (new InputStreamReader (System.in)); char[][] board = { {' ','1','2','3',' '}, {'1',' ',' ',' ','1'}, {'2',' ',' ',' ','2'}, {'3',' ',' ',' ','3'}, {' ','1','2','3',' '}}; YLingaw.ehem(board); int as = 3, o = 3; boolean team = true; boolean win = false; do{ if(team){ boolean empty = true; do{ System.out.print("*: "); String move = jill.readLine(); int a = Integer.parseInt(String.valueOf(move.charAt(0))); int b = Integer.parseInt(String.valueOf(move.charAt(1))); if(board[a][b] == ' '){ board[a][b] = '*'; } else{ empty = false; } }while(!empty); …

Member Avatar
Member Avatar
+0 forum 9

Here version of TicTacToe demo [URL="http://www.daniweb.com/software-development/python/threads/357974/1526474#post1526474"]code by wooeee[/URL] with packing style, which is more familiar for me. Also fixed indents and made it run also with Python 3.

Member Avatar
Member Avatar
+0 forum 3

I've been working on a side project of Tic Tac Toe, it works fine, but I'd like to change the winner function to be dynamic and work for any size board. For example, say I want a 4x3 or a 10x10 board how could I make the one function work for any board size? The board size is changed by changing the values of the global variables BOARD_ROW_NUM and BOARD_COL_NUM. [CODE] #include <iostream> #include <string> #include <fstream> using namespace std; const int BOARD_ROW_NUM=3; const int BOARD_COL_NUM=3; const int EMPTY = -1; const int PLAYER1 = 1; const int PLAYER2 = …

Member Avatar
Member Avatar
+0 forum 2

The program runs but only switches the player once [CODE]#include <iostream> #include <string> #include <cmath> #include <ctime> #include <cstdlib> using namespace std; class TicTacToe{ public: TicTacToe(void);//constructor void playOneGame(void);//member function void switchPlayer(char &);//member function void showBoard(void);// member function void postMove(int, int, char);// member function char determineWinner(void);// member function private: char Board[3][3]; }; int main(void){ //test the class by playing one game TicTacToe Game1; Game1.playOneGame(); } void TicTacToe::playOneGame(void){ //start a game and play until someone wins or a draw occurs const int MaxMoves = 9; char currentPlayer = 'O'; int row = 0; int column = 0; char Winner = ' '; …

Member Avatar
Member Avatar
+0 forum 4

This is what I have so far. This is a two player game. I need to make it a one player game (player vs. computer). I am also trying to make the computer smart.. for example, if there is an open corner, then it should take that spot. Basically, the computer should try to win. The computer's moves should not be random. Please help me! Here is my code: import java.util.Scanner; public class Game1 { public static void main(String[] arg) { Scanner keyboard = new Scanner(System.in); TicTacToe game = new TicTacToe(); game.print(); while ( !game.won() && !game.stalemate() ) { game.move(keyboard); …

Member Avatar
Member Avatar
+0 forum 6

Hey guys~! I am working on a code and I am having some difficulties with it -- Basically I have a 3x3 grid of JButtons that represent the squares on a TicTacToe grid. The code seems to run fine but then after it determines a victor it crashes and says something about AWT Event Dispatch and a class casting error. Does anyone know how to get rid of this? Here is my code so far: [CODE=Java] import javax.swing.JButton; /** * This class was designed to give me extra capabilities for my buttons that the * JButton does not seem to …

Member Avatar
Member Avatar
+0 forum 6

The End.