Java - Busco codigo de Tic Tac Toe

 
Vista:

Busco codigo de Tic Tac Toe

Publicado por Pulpull (1 intervención) el 02/01/2001 00:00:00
Busco el codigo del tic tac toe (parecido al 3 en raya). Es urgente. Ahh otra cosa es en modo texto(no applet). Gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Busco codigo de Tic Tac Toe

Publicado por ban (15 intervenciones) el 02/01/2001 00:00:00
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.net.*;
import java.applet.*;

public class TicTacToe extends Applet implements MouseListener {
int white;
int black;
final static int moves[] = {4, 0, 2, 6, 8, 1, 3, 5, 7};
static boolean won[] = new boolean[1 << 9];
static final int DONE = (1 << 9) - 1;
static final int OK = 0;
static final int WIN = 1;
static final int LOSE = 2;
static final int STALEMATE = 3;
static void isWon(int pos) {
for (int i = 0 ; i < DONE ; i++) {
if ((i & pos) == pos) {
won[i] = true;
}
}
}

static {
isWon((1 << 0) | (1 << 1) | (1 << 2));
isWon((1 << 3) | (1 << 4) | (1 << 5));
isWon((1 << 6) | (1 << 7) | (1 << 8));
isWon((1 << 0) | (1 << 3) | (1 << 6));
isWon((1 << 1) | (1 << 4) | (1 << 7));
isWon((1 << 2) | (1 << 5) | (1 << 8));
isWon((1 << 0) | (1 << 4) | (1 << 8));
isWon((1 << 2) | (1 << 4) | (1 << 6));
}

int bestMove(int white, int black) {
int bestmove = -1;

loop:
for (int i = 0 ; i < 9 ; i++) {
int mw = moves[i];
if (((white & (1 << mw
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar