Class reversi

All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer,

public class reversi
extends java.applet.Applet 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

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:

the toplevel applet class. It contains and handles the buttons.
the window that allows you to set up a new game. It appears when you press new game
the class that paints the pieces. It also handles the mouse clicks.
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.
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.
This class contains the adjustable parameters that are needed for determining the values of positions.
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.
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
Inner classes inherited from class java.awt.Panel
Inner classes inherited from class java.awt.Container
Inner classes inherited from class java.awt.Component
Fields inherited from class java.awt.Component
Fields inherited from interface java.awt.image.ImageObserver
Constructor Summary
          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
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


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


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


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.
start in class java.applet.Applet


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


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.
action in class java.awt.Component
true to indicate success


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


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


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


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.