FileDocCategorySizeDatePackage
MoveNode.javaAPI DocExample3401Sat Sep 12 03:01:00 BST 1998borland.samples.apps.chess.client

MoveNode

public class MoveNode extends Object

Fields Summary
Boardsquares
pieceColor
Boardsquares
pieceValue
String
movetext
String
comment
int
nestlevel
int
prevsub
int
movenum
boolean[]
qCastleForfeited
boolean[]
kCastleForfeited
int
enpassantFile
Constructors Summary
public MoveNode()


    
    for (int i = 0;i < 2;i++) {
      this.qCastleForfeited[i] = false;
      this.kCastleForfeited[i] = false;
    }
  
Methods Summary
public voidassign(int file, int rank, int piece, int clr)

    pieceValue.assign(file,rank,piece);
    pieceColor.assign(file,rank,clr);
  
public voidcopy(borland.samples.apps.chess.client.MoveNode from)

    this.pieceColor.init(from.pieceColor);
    this.pieceValue.init(from.pieceValue);
    for (int i = 0;i < 2;i++) {
      this.qCastleForfeited[i] = from.qCastleForfeited[i];
      this.kCastleForfeited[i] = from.kCastleForfeited[i];
    }
    this.enpassantFile = from.enpassantFile;
  
public booleanequals(borland.samples.apps.chess.client.MoveNode x)

    if (pieceColor.equals(x.pieceColor) &&
        pieceValue.equals(x.pieceValue) &&
        qCastleForfeited[0] == x.qCastleForfeited[0]   &&
        kCastleForfeited[0] == x.kCastleForfeited[0] &&
        qCastleForfeited[1] == x.qCastleForfeited[1]   &&
        kCastleForfeited[1] == x.kCastleForfeited[1] &&
        enpassantFile < 0 &&
        x.enpassantFile < 0 )
      return true;
    else
      return false;
  
public booleanmatchingPawnSkeleton(borland.samples.apps.chess.client.MoveNode x)

    int ourSquare;
    int theirSquare;
    for (int file = 0;file < 8;file++)
      for (int rank = 0;rank < 8;rank++) {
        ourSquare = pieceValue.value(file,rank);
        theirSquare = x.pieceValue.value(file,rank);
        if (ourSquare == theirSquare);
        else
          if (ourSquare == Chessboard.PAWN ||
            theirSquare == Chessboard.PAWN)
            return false;
      }
    return true;
  
public intpieceCount()

    return pieceValue.nonZeroElementCount();
  
public intpieceValues(int Color)

    int sum = 0;
    for (int column=0;column<8;column++)
      for (int row=0;row<8;row++)
        if (pieceColor.value(column,row) == Color)
          sum = sum + pieceValue.value(column,row);
    return sum;