Squeak Class Documentation category index | class index  
 
ChessPlayer
  category: Morphic-Games-Chess
  superclass: Object
  subclasses:

This class represents a player in the game, including its pieces and the current value of the player's position.

instance methods
  accessing
  board
board:
castlingRookSquare
castlingStatus
enpassantSquare
materialValue
numPawns
opponent
opponent:
pieceAt:
pieces
userAgent

  adding/removing
  addBlackPieces
addPiece:at:
addWhitePieces
movePiece:from:to:
removePiece:at:
replacePiece:with:at:

  copying
  copy
copyPlayer:
postCopy

  evaluation
  evaluate
evaluateMaterial
evaluatePosition
positionalValue

  initialize
  initialize
prepareNextMove

  moves-general
  findPossibleMoves
findPossibleMovesAt:
findQuiescenceMoves
findValidMoves
findValidMovesAt:

  moving
  applyCastleKingSideMove:
applyCastleQueenSideMove:
applyDoublePushMove:
applyEnpassantMove:
applyMove:
applyNormalMove:
applyPromotion:
applyResign:
applyStaleMate:
updateCastlingStatus:

  testing
  canCastleKingSide
canCastleQueenSide
isValidMove:
isValidMoveFrom:to:
isWhitePlayer

  undo
  undoCastleKingSideMove:
undoCastleQueenSideMove:
undoDoublePushMove:
undoEnpassantMove:
undoMove:
undoNormalMove:
undoPromotion:
undoResign:
undoStaleMate:

class methods
  accessing
  king
rook

  class initialization
  initialize
initializeBishopMoves
initializeCastlingConstants
initializeCenterScores
initializeConstants
initializeKingMoves
initializeKnightMoves
initializeMoves
initializePieceValues
initializeRookMoves

instance methods
  accessing top  
 

board


 

board:


 

castlingRookSquare


 

castlingStatus


 

enpassantSquare


 

materialValue


 

numPawns


 

opponent


 

opponent:


 

pieceAt:

Return the piece at the given square


 

pieces


 

userAgent


  adding/removing top  
 

addBlackPieces


 

addPiece:at:


 

addWhitePieces


 

movePiece:from:to:


 

removePiece:at:


 

replacePiece:with:at:


  copying top  
 

copy

Answer another instance just like the receiver. Subclasses typically
override this method; they typically do not override shallowCopy.


 

copyPlayer:

Copy all the volatile state from aPlayer


 

postCopy


  evaluation top  
 

evaluate


 

evaluateMaterial

Compute the board's material balance, from the point of view of the side
player. This is an exact clone of the eval function in CHESS 4.5


 

evaluatePosition

Compute the board's positional balance, from the point of view of the side player.


 

positionalValue

Evaluate our current position


  initialize top  
 

initialize

ChessPlayer initialize


 

prepareNextMove

Clear enpassant square and reset any pending extra kings


  moves-general top  
 

findPossibleMoves

Find all possible moves. This method does not check if the move is legal, e.g., if the king of the player is under attack after the move. If the opponent is check mate (e.g., the king could be taken in the next move) the method returns nil. If the game is stale mate (e.g., the receiver has no move left) this method returns an empty array.


 

findPossibleMovesAt:

Find all possible moves at the given square. This method does not check if the move is legal, e.g., if the king of the player is under attack after the move. If the opponent is check mate (e.g., the king could be taken in the next move) the method returns nil. If the game is stale mate (e.g., the receiver has no move left) this method returns an empty array.


 

findQuiescenceMoves

Find all possible moves. This method does not check if the move is legal, e.g., if the king of the player is under attack after the move. If the opponent is check mate (e.g., the king could be taken in the next move) the method returns nil. If the game is stale mate (e.g., the receiver has no move left) this method returns an empty array.


 

findValidMoves

Find all the valid moves


 

findValidMovesAt:

Find all the valid moves


  moving top  
 

applyCastleKingSideMove:


 

applyCastleQueenSideMove:


 

applyDoublePushMove:


 

applyEnpassantMove:


 

applyMove:

Apply the given move


 

applyNormalMove:


 

applyPromotion:


 

applyResign:

Give up.


 

applyStaleMate:

Itsa draw.


 

updateCastlingStatus:

Cannot castle when king has moved


  testing top  
 

canCastleKingSide


 

canCastleQueenSide


 

isValidMove:

Is the given move actually valid for the receiver?
If the receiver's king can't be taken after applying the move, it is.


 

isValidMoveFrom:to:


 

isWhitePlayer


  undo top  
 

undoCastleKingSideMove:


 

undoCastleQueenSideMove:


 

undoDoublePushMove:


 

undoEnpassantMove:


 

undoMove:

Undo the given move


 

undoNormalMove:


 

undoPromotion:


 

undoResign:


 

undoStaleMate:


class methods
  accessing top  
 

king


 

rook


  class initialization top  
 

initialize

ChessPlayer initialize


 

initializeBishopMoves

ChessPlayer initialize


 

initializeCastlingConstants

ChessPlayer initialize


 

initializeCenterScores

ChessPlayer initialize


 

initializeConstants

ChessPlayer initialize


 

initializeKingMoves

ChessPlayer initialize


 

initializeKnightMoves

ChessPlayer initialize


 

initializeMoves

ChessPlayer initialize


 

initializePieceValues


 

initializeRookMoves

ChessPlayer initialize