HumenPlayer.java
import java.util.Random;
import java.io.*;
public class HumenPlayer
{
TicTacToe Frame;
public HumenPlayer(TicTacToe ref)
{
Frame=ref;
}
public void GameMove(int[][] GameTable,int i,int
j)
{
int x,y;
x=i;
y=j;
GameTable[x][y]=1;
Frame.UpdateBoard();
}
}
MessageBox.java
// MessageBox - source from Dr. Kirsh site
import java.awt.*;
import java.awt.event.*;
public class MessageBox extends Frame
{
public MessageBox(String message,
String title)
{
addWindowListener(new ClosingHandler());
addKeyListener(new EscHandler());
setLayout(new BorderLayout(10, 10));
setBackground(Color.lightGray);
Label label = new Label(message, Label.CENTER);
label.addKeyListener(new EscHandler());
add(label, BorderLayout.CENTER);
Panel buttonsPanel = new Panel();
buttonsPanel.addKeyListener(new EscHandler());
Button ok = new Button("OK");
buttonsPanel.add(ok);
ok.addActionListener(new OkHandler());
ok.addKeyListener(new EscHandler());
add(buttonsPanel, BorderLayout.SOUTH);
pack(); // take minimum necessary size.
setLocation(400,300);
setVisible(true);
}
class ClosingHandler extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
dispose();
}
}
class EscHandler extends KeyAdapter
{
public void keyPressed(KeyEvent e)
{
if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
dispose();
}
}
class OkHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
dispose();
}
}
}
Related files:
TicTacToe.java
ANNPlayer.java
NueralNet.java
HumenPlayer.java
MessageBox.java
TurnDialog.java
Applet1.java |