home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-05-08 | 3.3 KB | 111 lines |
- /*
- * Copyright (c) 1997-1998 Borland International, Inc. All Rights Reserved.
- *
- * This SOURCE CODE FILE, which has been provided by Borland as part
- * of a Borland product for use ONLY by licensed users of the product,
- * includes CONFIDENTIAL and PROPRIETARY information of Borland.
- *
- * USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS
- * OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
- * THE PRODUCT.
- *
- * IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD BORLAND, ITS RELATED
- * COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY CLAIMS
- * OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR DISTRIBUTION
- * OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES ARISING OUT OF
- * OR RESULTING FROM THE USE, MODIFICATION, OR DISTRIBUTION OF PROGRAMS
- * OR FILES CREATED FROM, BASED ON, AND/OR DERIVED FROM THIS SOURCE
- * CODE FILE.
- */
- /*
- * %W% %E%
- *
- * H
- *
- */
- package borland.samples.apps.chess.client;
-
- import borland.samples.apps.chess.client.board.*;
-
- public class MoveNode
- {
- Boardsquares pieceColor = new Boardsquares();
- Boardsquares pieceValue = new Boardsquares();
- String movetext = new String("_");
- String comment = new String(" ");
- int nestlevel = 0;
- int prevsub = -1;
- int movenum = 0;
- boolean [] qCastleForfeited = new boolean [2];
- boolean [] kCastleForfeited = new boolean [2];
- int enpassantFile = -1;
-
- public MoveNode() {
- for (int i = 0;i < 2;i++) {
- this.qCastleForfeited[i] = false;
- this.kCastleForfeited[i] = false;
- }
- }
-
- public void assign(int file,int rank,int piece,int clr) {
- pieceValue.assign(file,rank,piece);
- pieceColor.assign(file,rank,clr);
- }
-
- public boolean equals(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 boolean matchingPawnSkeleton(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 int pieceValues(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;
- }
-
- public int pieceCount() {
- return pieceValue.nonZeroElementCount();
- }
-
- public void copy(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;
- }
- } //end of class
-
-
-
-