English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Right now I have a program that will play tic tac toe between 2 people, but I am confused on how to turn it into a program that plays between the computer and the player. The computer doesn't have to be smart. import java.io.*; import java.util.*; class TTT { public static void main(String args[]) { int a,b,x,y; int person,row,col,count=0; char pl; char[][] array= { {' ',' ',' '}, {' ',' ',' '}, {' ',' ',' '}, }; do { for(a=0;a<4;a++) { System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); for(b=0;b<2;b++) { if(b==1) { pl='O'; } else { pl='X'; } if(b==1) { person=1; } else { person=2; } System.out.println(" 0 1 2"); for(x=0;x<3;x++) { System.out.print(x); for(y=0;y<3;y++) { System.out.print("["+array[x][y] +"]"); } System.out.println(); } boolean invalidcoordinates = false; do{ count=count+1; System.out.println("Enter Row(0,1,2)"); Scanner scan = new Scanner(System.in); row=scan.nextInt(); System.out.println("Enter Column(0,1,2)"); col=scan.nextInt();
*not all of code*

2007-03-17 20:41:36 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

3 answers

hi
programing a game for 2 users in java can be easy.. but when it comes to challenging the computer, u should use artificial intelligence techniques..
i advise u to study A.I. for developping ur techniques

good luck :)

2007-03-17 20:49:41 · answer #1 · answered by abd 5 · 0 0

Inside JDK folder ... Demo --> Applets --> TicTacToe. In the Bruce Eckels book "Thinking in Java", available online, is another version of TicTacToe.

2007-03-17 20:53:57 · answer #2 · answered by Anonymous · 0 0

you stepping to AI (synthetic intelligence) :) study finding algorithms like alpha-beta, minimax, and so on. those algorithms are utilized in chess interest too. under, hyperlinks to start to nicely known little bit approximately those algorithms

2016-10-02 07:46:43 · answer #3 · answered by ? 4 · 0 0

fedest.com, questions and answers