FileDocCategorySizeDatePackage
ChessPlayer.javaAPI DocExample1505Tue Jan 20 21:11:06 GMT 1998dcj.examples.message

ChessPlayer

public class ChessPlayer extends Object implements Serializable
Source code from "Java Distributed Computing", by Jim Farley. Class: ChessPlayer Example: 6-3 Description: An class representing a player in a chess game. The player maintains its own copy of the board state.

Fields Summary
public static final int
CHECK
public static final int
CHECKMATE
public static final int
NO_CHECK
Constructors Summary
public ChessPlayer()


    
    // Initialize chess board
  
Methods Summary
public booleanacceptMove(ChessMove m)

    // Check validity of requested move.
    // If valid, apply to chess board and return true.
    // If invalid, return false.
    //             .
    //             .
    //             .
    return true;
  
public voidconceded()

    // We've won!
  
public voidmoveAccepted(ChessMove m)

    // Our move was accepted as valid, apply it to the
    // game board...
    //             .
    //             .
    //             .
  
public ChessMovenextMove()

    String from = "";
    String to = "";
    int checkFlag = NO_CHECK;

    // Generate our next move based on the current
    // state of the game board...
    //             .
    //             .
    //             .
    return new ChessMove(from, to, checkFlag);