Class reversi

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--reversi
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class reversi
extends java.applet.Applet

reversi.java is an applet for playing the reversi othello board game against the computer. Designed by bluering software development . You can send questions about this source to sieuwert@bluering.nl

class overview

This applet consists of several classes.We have put all the classes in one file for easy downloading. To get the right javadoc documentation, we had to make all classes, and many methods public. You might want to put each class in a separate file with the filename equal to the class name. You can also make all classes except reversi non-public (just remove the word public) to avoid errors. The drawback is that you will not see those classes in the documentation.

the javadoc files contain much of the comment, but not all of it. Check the sourcecode for the last details. The list of all classes is:

reversi
the toplevel applet class. It contains and handles the buttons.
newgamewindow
the window that allows you to set up a new game. It appears when you press new game
boardview
the class that paints the pieces. It also handles the mouse clicks.
board
The class containing the state of the board. This class knows the rules of the game. Designers say it contains the game logic. It is in some way the most pure, and basic class, where all others rely on.
player
the functions to calculate what move to do. This class contains the minimax algorithm with the alpha-beta heuristic. With these techniques a search is done to find the best position it can reach. The other classes are needed for estimating the winning value of positions.
weightvector
This class contains the adjustable parameters that are needed for determining the values of positions.
genetictrain
This class contains the genetic algorithm that can search the best weight vector. If you want to search a good weight vector, you must run this class, and in a few minutes it will select good weight vectors by letting them play against each other.
file
This is just a utility class for reading and writing files in an easy way.

See Also:
Serialized Form

Inner classes inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Inner classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
reversi()
          constructor for running this applet as an application
 
Method Summary
 boolean action(java.awt.Event ev, java.lang.Object O)
          the action method is called when a button is pressed.
 void init()
          the init method is called when the applet is loaded by the browser.
static void main(java.lang.String[] ps)
          this method is quick & dirty trick for running this applet as an application.
 void message(java.lang.String s)
          sets a given text in the message label.
 void newgame()
          this method is called by newgamewindow.
 void start()
          the start method of the applet.
 void stop()
          here we stop the animation
 void undo()
          this method undoes a move, if possible.
 
Methods inherited from class java.applet.Applet
destroy, getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

reversi

public reversi()
constructor for running this applet as an application
Method Detail

init

public void init()
the init method is called when the applet is loaded by the browser.
Overrides:
init in class java.applet.Applet

start

public void start()
the start method of the applet. It is called any time the window re-appears on the screen. All we do here is start the animation.
Overrides:
start in class java.applet.Applet

stop

public void stop()
here we stop the animation
Overrides:
stop in class java.applet.Applet

action

public boolean action(java.awt.Event ev,
                      java.lang.Object O)
the action method is called when a button is pressed. It first checks whether bview might be busy. In that case, it does nothing. Else it undoes a move or launches a new game window.
Overrides:
action in class java.awt.Component
Returns:
true to indicate success

newgame

public void newgame()
this method is called by newgamewindow.

undo

public void undo()
this method undoes a move, if possible.

message

public void message(java.lang.String s)
sets a given text in the message label.
Parameters:
s - the message to display.

main

public static void main(java.lang.String[] ps)
this method is quick & dirty trick for running this applet as an application. It is not used when a browser runs this class as an applet.