author | Markus Bröker <mbroeker@largo.homelinux.org> |
Fri, 17 Dec 2010 22:30:33 +0100 | |
changeset 13 | f83884cc7d2f |
parent 11 | 1afe167876fb |
child 14 | f12f77aa13b2 |
permissions | -rw-r--r-- |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
1 |
/** |
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
2 |
* $Id: ChessBoard.java 152 2008-04-27 02:04:31Z mbroeker $ |
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
3 |
* $URL: http://localhost/svn/eclipse/Schachspiel/trunk/org/homelinux/largo/games/board/chessboard/ChessBoard.java $ |
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
4 |
*/ |
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
5 |
|
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
6 |
package org.homelinux.largo.games.board.chessboard; |
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
7 |
|
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
8 |
import java.awt.Image; |
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
9 |
|
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
10 |
import org.homelinux.largo.games.board.Board; |
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
11 |
import org.homelinux.largo.games.board.Piece; |
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
12 |
import org.homelinux.largo.utils.ImgComponent; |
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
13 |
|
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
14 |
public class ChessBoard extends Board { |
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
15 |
static final long serialVersionUID = 140208; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
16 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
17 |
static final int ROOK = 1; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
18 |
static final int KNIGHT = 2; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
19 |
static final int BISHOP = 3; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
20 |
static final int QUEEN = 4; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
21 |
static final int KING = 5; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
22 |
static final int PAWN = 6; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
23 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
24 |
final Piece white_queen = new Piece(new ImgComponent("images/white_queen.png").getImage(), "white", QUEEN, 90); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
25 |
final Piece black_queen = new Piece(new ImgComponent("images/black_queen.png").getImage(), "black", QUEEN, 90); |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
26 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
27 |
boolean white_rochades_small; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
28 |
boolean white_rochades_big; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
29 |
boolean black_rochades_small; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
30 |
boolean black_rochades_big; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
31 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
32 |
void initBoard() { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
33 |
add(new ImgComponent("images/black_rook.png").getImage(), 0, "black", ROOK); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
34 |
add(new ImgComponent("images/black_knight.png").getImage(), 1, "black", KNIGHT); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
35 |
add(new ImgComponent("images/black_bishop.png").getImage(), 2, "black", BISHOP); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
36 |
add(new ImgComponent("images/black_queen.png").getImage(), 3, "black", QUEEN); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
37 |
add(new ImgComponent("images/black_king.png").getImage(), 4, "black", KING); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
38 |
add(new ImgComponent("images/black_bishop.png").getImage(), 5, "black", BISHOP); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
39 |
add(new ImgComponent("images/black_knight.png").getImage(), 6, "black", KNIGHT); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
40 |
add(new ImgComponent("images/black_rook.png").getImage(), 7, "black", ROOK); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
41 |
|
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
42 |
for (int i = 0; i < 8; i++) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
43 |
add(new ImgComponent("images/black_pawn.png").getImage(), 8 + i, "black", PAWN); |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
44 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
45 |
add(new ImgComponent("images/white_rook.png").getImage(), 56, "white", ROOK); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
46 |
add(new ImgComponent("images/white_knight.png").getImage(), 57, "white", KNIGHT); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
47 |
add(new ImgComponent("images/white_bishop.png").getImage(), 58, "white", BISHOP); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
48 |
add(new ImgComponent("images/white_queen.png").getImage(), 59, "white", QUEEN); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
49 |
add(new ImgComponent("images/white_king.png").getImage(), 60, "white", KING); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
50 |
add(new ImgComponent("images/white_bishop.png").getImage(), 61, "white", BISHOP); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
51 |
add(new ImgComponent("images/white_knight.png").getImage(), 62, "white", KNIGHT); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
52 |
add(new ImgComponent("images/white_rook.png").getImage(), 63, "white", ROOK); |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
53 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
54 |
for (int i = 0; i < 8; i++) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
55 |
add(new ImgComponent("images/white_pawn.png").getImage(), 55 - i, "white", PAWN); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
56 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
57 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
58 |
/** |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
59 |
* The init method initializes a complete chess board with figures and a |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
60 |
* history. |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
61 |
*/ |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
62 |
public void init() { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
63 |
super.init(); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
64 |
initBoard(); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
65 |
board_pieces = getPieces(); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
66 |
repaint(); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
67 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
68 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
69 |
public ChessBoard(int w, int h) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
70 |
super(w, h); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
71 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
72 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
73 |
void add(Image img, int i, String c, int t) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
74 |
int v = 0; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
75 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
76 |
switch (t) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
77 |
case ROOK: |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
78 |
v = 80; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
79 |
break; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
80 |
case KNIGHT: |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
81 |
v = 30; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
82 |
break; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
83 |
case BISHOP: |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
84 |
v = 30; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
85 |
break; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
86 |
case QUEEN: |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
87 |
v = 90; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
88 |
break; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
89 |
case KING: |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
90 |
v = 120; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
91 |
break; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
92 |
case PAWN: |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
93 |
v = 10; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
94 |
break; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
95 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
96 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
97 |
setPiece(i, new Piece(img, c, t, v)); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
98 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
99 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
100 |
/** |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
101 |
* returns true, when the white king is at pieces[i] |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
102 |
*/ |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
103 |
public boolean isWhiteKing(int i) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
104 |
if (isWhite(i) && getType(i) == KING) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
105 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
106 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
107 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
108 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
109 |
/** |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
110 |
* returns true, when the black king is at pieces[i] |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
111 |
*/ |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
112 |
public boolean isBlackKing(int i) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
113 |
if (isBlack(i) && getType(i) == KING) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
114 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
115 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
116 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
117 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
118 |
/** |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
119 |
* Returns the score of the current position Every field controlled by |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
120 |
* [color] gives one point A King, controlled by [color], gives 10 extra |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
121 |
* points |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
122 |
*/ |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
123 |
public int controls(String color) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
124 |
int t, o; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
125 |
int value = 0; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
126 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
127 |
for (o = 0; o < 64; o++) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
128 |
if (color.equals(getColor(o))) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
129 |
for (t = 0; t < 64; t++) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
130 |
if (validMove(t, o)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
131 |
if (getType(t) == KING) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
132 |
value += 10; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
133 |
value++; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
134 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
135 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
136 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
137 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
138 |
return value; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
139 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
140 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
141 |
/** |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
142 |
* Checks, wether this move is possible or not. |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
143 |
*/ |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
144 |
public boolean validMove(int t, int o) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
145 |
int steps; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
146 |
int rows; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
147 |
int dx; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
148 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
149 |
/* Must be here */ |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
150 |
white_rochades_small = false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
151 |
white_rochades_big = false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
152 |
black_rochades_small = false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
153 |
black_rochades_big = false; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
154 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
155 |
if (t == o) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
156 |
return false; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
157 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
158 |
if (isSamePiece(t, o)) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
159 |
return false; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
160 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
161 |
if (getType(o) == EMPTY) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
162 |
return false; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
163 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
164 |
/* |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
165 |
* 00 01 02 03 04 05 06 07 |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
166 |
* 08 09 10 11 12 13 14 15 |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
167 |
* 16 17 18 19 20 21 22 23 |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
168 |
* 24 25 26 27 28 29 30 31 |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
169 |
* 32 33 34 35 36 37 38 39 |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
170 |
* 40 41 42 43 44 45 46 47 |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
171 |
* 48 49 50 51 52 53 54 55 |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
172 |
* 56 57 58 59 60 61 62 63 |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
173 |
*/ |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
174 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
175 |
steps = Math.abs(t - o); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
176 |
rows = Math.abs(t / 8 - o / 8); |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
177 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
178 |
switch (getType(o)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
179 |
case ROOK: |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
180 |
if (steps < 8 && rows == 0) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
181 |
if (t > o) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
182 |
for (dx = o + 1; dx < t; dx++) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
183 |
if (getColor(dx) != null) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
184 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
185 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
186 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
187 |
else |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
188 |
for (dx = o - 1; dx > t; dx--) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
189 |
if (getColor(dx) != null) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
190 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
191 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
192 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
193 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
194 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
195 |
if (steps % 8 == 0) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
196 |
if (t > o) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
197 |
for (dx = o + 8; dx < t; dx += 8) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
198 |
if (getColor(dx) != null) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
199 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
200 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
201 |
} else { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
202 |
for (dx = o - 8; dx > t; dx -= 8) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
203 |
if (getColor(dx) != null) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
204 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
205 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
206 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
207 |
if (steps == 8 && rows == 1) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
208 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
209 |
if (steps == 16 && rows == 2) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
210 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
211 |
if (steps == 24 && rows == 3) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
212 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
213 |
if (steps == 32 && rows == 4) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
214 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
215 |
if (steps == 40 && rows == 5) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
216 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
217 |
if (steps == 48 && rows == 6) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
218 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
219 |
if (steps == 56 && rows == 7) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
220 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
221 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
222 |
break; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
223 |
case KNIGHT: |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
224 |
/* works fine */ |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
225 |
if (steps == 6 && rows == 1) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
226 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
227 |
if (steps == 10 && rows == 1) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
228 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
229 |
if (steps == 15 && rows == 2) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
230 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
231 |
if (steps == 17 && rows == 2) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
232 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
233 |
break; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
234 |
case BISHOP: |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
235 |
if (steps % 7 == 0) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
236 |
if (t > o) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
237 |
for (dx = o + 7; dx < t; dx += 7) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
238 |
if (getColor(dx) != null) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
239 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
240 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
241 |
} else { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
242 |
for (dx = o - 7; dx > t; dx -= 7) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
243 |
if (getColor(dx) != null) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
244 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
245 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
246 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
247 |
if (steps == 7 && rows == 1) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
248 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
249 |
if (steps == 14 && rows == 2) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
250 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
251 |
if (steps == 21 && rows == 3) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
252 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
253 |
if (steps == 28 && rows == 4) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
254 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
255 |
if (steps == 35 && rows == 5) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
256 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
257 |
if (steps == 42 && rows == 6) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
258 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
259 |
if (steps == 49 && rows == 7) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
260 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
261 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
262 |
if (steps % 9 == 0) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
263 |
if (t > o) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
264 |
for (dx = o + 9; dx < t; dx += 9) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
265 |
if (getColor(dx) != null) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
266 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
267 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
268 |
} else { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
269 |
for (dx = o - 9; dx > t; dx -= 9) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
270 |
if (getColor(dx) != null) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
271 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
272 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
273 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
274 |
if (steps == 9 && rows == 1) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
275 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
276 |
if (steps == 18 && rows == 2) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
277 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
278 |
if (steps == 27 && rows == 3) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
279 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
280 |
if (steps == 36 && rows == 4) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
281 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
282 |
if (steps == 45 && rows == 5) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
283 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
284 |
if (steps == 54 && rows == 6) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
285 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
286 |
if (steps == 63 && rows == 7) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
287 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
288 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
289 |
break; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
290 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
291 |
case QUEEN: |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
292 |
if (steps < 8 && rows == 0) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
293 |
if (t > o) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
294 |
for (dx = o + 1; dx < t; dx++) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
295 |
if (getColor(dx) != null) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
296 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
297 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
298 |
else |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
299 |
for (dx = o - 1; dx > t; dx--) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
300 |
if (getColor(dx) != null) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
301 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
302 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
303 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
304 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
305 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
306 |
if (steps % 8 == 0) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
307 |
if (t > o) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
308 |
for (dx = o + 8; dx < t; dx += 8) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
309 |
if (getColor(dx) != null) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
310 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
311 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
312 |
} else { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
313 |
for (dx = o - 8; dx > t; dx -= 8) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
314 |
if (getColor(dx) != null) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
315 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
316 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
317 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
318 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
319 |
if (steps == 8 && rows == 1) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
320 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
321 |
if (steps == 16 && rows == 2) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
322 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
323 |
if (steps == 24 && rows == 3) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
324 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
325 |
if (steps == 32 && rows == 4) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
326 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
327 |
if (steps == 40 && rows == 5) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
328 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
329 |
if (steps == 48 && rows == 6) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
330 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
331 |
if (steps == 56 && rows == 7) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
332 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
333 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
334 |
if (steps % 7 == 0) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
335 |
if (t > o) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
336 |
for (dx = o + 7; dx < t; dx += 7) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
337 |
if (getColor(dx) != null) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
338 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
339 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
340 |
} else { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
341 |
for (dx = o - 7; dx > t; dx -= 7) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
342 |
if (getColor(dx) != null) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
343 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
344 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
345 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
346 |
if (steps == 7 && rows == 1) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
347 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
348 |
if (steps == 14 && rows == 2) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
349 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
350 |
if (steps == 21 && rows == 3) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
351 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
352 |
if (steps == 28 && rows == 4) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
353 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
354 |
if (steps == 35 && rows == 5) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
355 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
356 |
if (steps == 42 && rows == 6) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
357 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
358 |
if (steps == 49 && rows == 7) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
359 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
360 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
361 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
362 |
if (steps % 9 == 0) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
363 |
if (t > o) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
364 |
for (dx = o + 9; dx < t; dx += 9) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
365 |
if (getColor(dx) != null) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
366 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
367 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
368 |
} else { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
369 |
for (dx = o - 9; dx > t; dx -= 9) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
370 |
if (getColor(dx) != null) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
371 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
372 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
373 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
374 |
if (steps == 9 && rows == 1) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
375 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
376 |
if (steps == 18 && rows == 2) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
377 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
378 |
if (steps == 27 && rows == 3) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
379 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
380 |
if (steps == 36 && rows == 4) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
381 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
382 |
if (steps == 45 && rows == 5) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
383 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
384 |
if (steps == 54 && rows == 6) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
385 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
386 |
if (steps == 63 && rows == 7) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
387 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
388 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
389 |
break; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
390 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
391 |
case KING: |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
392 |
if ((steps == 1) && (rows == 0)) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
393 |
return true; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
394 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
395 |
if ((steps == 8) && (rows == 1)) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
396 |
return true; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
397 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
398 |
if ((steps == 7) && (rows == 1)) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
399 |
return true; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
400 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
401 |
if ((steps == 9) && (rows == 1)) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
402 |
return true; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
403 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
404 |
if ((steps == 2) && (rows == 0)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
405 |
if (isWhiteKing(o)) { /* White: Rochade */ |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
406 |
if (isWhiteKing(60) && isEmpty(61) && isEmpty(62) && (t == 62)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
407 |
if ((getType(63) == ROOK) && isWhite(63)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
408 |
white_rochades_small = true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
409 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
410 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
411 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
412 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
413 |
if (isWhiteKing(60) && isEmpty(59) && isEmpty(58) && isEmpty(57) && (t == 58)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
414 |
if ((getType(56) == ROOK) && isWhite(56)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
415 |
white_rochades_big = true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
416 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
417 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
418 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
419 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
420 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
421 |
if (isBlackKing(o)) { /* Black: Rochade */ |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
422 |
if (isBlackKing(4) && isEmpty(5) && isEmpty(6) && (t == 6)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
423 |
if ((getType(7) == ROOK) && isBlack(7)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
424 |
black_rochades_small = true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
425 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
426 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
427 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
428 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
429 |
if (isBlackKing(4) && isEmpty(3) && isEmpty(2) && isEmpty(1) && (t == 2)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
430 |
if ((getType(0) == ROOK) && isBlack(0)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
431 |
black_rochades_big = true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
432 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
433 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
434 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
435 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
436 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
437 |
break; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
438 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
439 |
case PAWN: |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
440 |
if (getColor(o).equals("white")) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
441 |
if (steps == 7 && rows == 1 && isEnemy(t, o) && t < o) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
442 |
return true; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
443 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
444 |
if (steps == 9 && rows == 1 && isEnemy(t, o) && t < o) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
445 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
446 |
} else { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
447 |
if (steps == 7 && rows == 1 && isEnemy(t, o) && t > o) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
448 |
return true; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
449 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
450 |
if (steps == 9 && rows == 1 && isEnemy(t, o) && t > o) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
451 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
452 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
453 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
454 |
if (steps % 8 == 0) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
455 |
if (t > o) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
456 |
for (dx = o + 8; dx <= t; dx += 8) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
457 |
if (getColor(dx) != null) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
458 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
459 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
460 |
} else { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
461 |
for (dx = o - 8; dx >= t; dx -= 8) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
462 |
if (getColor(dx) != null) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
463 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
464 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
465 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
466 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
467 |
if (steps == 8 && rows == 1) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
468 |
if (getColor(o).equals("white") && t < o) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
469 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
470 |
if (getColor(o).equals("black") && t > o) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
471 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
472 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
473 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
474 |
if (steps == 16 && rows == 2 && (o >= 8 && o <= 15)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
475 |
if (getColor(o).equals("white") && t < o) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
476 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
477 |
if (getColor(o).equals("black") && t > o) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
478 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
479 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
480 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
481 |
if (steps == 16 && rows == 2 && (o >= 48 && o <= 55)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
482 |
if (getColor(o).equals("white") && t < o) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
483 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
484 |
if (getColor(o).equals("black") && t > o) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
485 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
486 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
487 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
488 |
break; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
489 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
490 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
491 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
492 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
493 |
/** |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
494 |
* This method must be called immediately after isValidMove(t, o) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
495 |
*/ |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
496 |
boolean rochade() { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
497 |
if (white_rochades_small) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
498 |
setPiece(61, getPiece(63)); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
499 |
setPiece(63, new Piece(null, null, EMPTY, 0)); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
500 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
501 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
502 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
503 |
if (white_rochades_big) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
504 |
setPiece(59, getPiece(56)); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
505 |
setPiece(56, new Piece(null, null, EMPTY, 0)); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
506 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
507 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
508 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
509 |
if (black_rochades_small) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
510 |
setPiece(5, getPiece(7)); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
511 |
setPiece(7, new Piece(null, null, EMPTY, 0)); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
512 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
513 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
514 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
515 |
if (black_rochades_big) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
516 |
setPiece(3, getPiece(0)); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
517 |
setPiece(0, new Piece(null, null, EMPTY, 0)); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
518 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
519 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
520 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
521 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
522 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
523 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
524 |
/** |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
525 |
* checks, whether color is in check or not. |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
526 |
*/ |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
527 |
public boolean isCheck(String color) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
528 |
int i; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
529 |
int wking; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
530 |
int bking; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
531 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
532 |
wking = bking = -1; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
533 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
534 |
for (i = 0; i < 64; i++) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
535 |
if (isWhiteKing(i)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
536 |
wking = i; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
537 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
538 |
if (isBlackKing(i)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
539 |
bking = i; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
540 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
541 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
542 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
543 |
// returns 64 false positives |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
544 |
if (wking == -1 || bking == -1) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
545 |
return true; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
546 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
547 |
if (color.equals("white")) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
548 |
for (i = 0; i < 64; i++) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
549 |
if (validMove(wking, i)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
550 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
551 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
552 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
553 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
554 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
555 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
556 |
if (color.equals("black")) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
557 |
for (i = 0; i < 64; i++) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
558 |
if (validMove(bking, i)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
559 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
560 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
561 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
562 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
563 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
564 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
565 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
566 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
567 |
/** |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
568 |
* simulates a "valid" move or returns false. all changes are relative to |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
569 |
* pieces and will not be painted. This method sets internal variables for |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
570 |
* the rochade() method, which will be overwritten. |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
571 |
*/ |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
572 |
public boolean simulateMove(int t, int o) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
573 |
if (!validMove(t, o)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
574 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
575 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
576 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
577 |
push(getPiece(t), t, getPiece(o), o); |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
578 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
579 |
if (getType(o) == PAWN) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
580 |
if (isBlack(o) && t >= 56) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
581 |
setPiece(o, new Piece(black_queen)); |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
582 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
583 |
if (isWhite(o) && t <= 7) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
584 |
setPiece(o, new Piece(white_queen)); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
585 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
586 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
587 |
setPiece(t, new Piece(getPiece(o))); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
588 |
setPiece(o, new Piece(null, null, EMPTY, 0)); |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
589 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
590 |
if (isCheck(getColor(t))) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
591 |
/* restore current position */ |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
592 |
if (UNDO_DEBUG) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
593 |
print("UNDO", t, o, 0); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
594 |
undo(); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
595 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
596 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
597 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
598 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
599 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
600 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
601 |
/** |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
602 |
* performs a "valid" move or returns false. all changes are relative to |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
603 |
* board_pieces and will be painted. |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
604 |
*/ |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
605 |
public boolean doMove(int t, int o) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
606 |
if (!validMove(t, o)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
607 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
608 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
609 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
610 |
push(getPiece(t), t, getPiece(o), o); |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
611 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
612 |
if (getType(o) == PAWN) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
613 |
if (isBlack(o) && t >= 56) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
614 |
setPiece(o, new Piece(black_queen)); |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
615 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
616 |
if (isWhite(o) && t <= 7) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
617 |
setPiece(o, new Piece(white_queen)); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
618 |
} |
5
42da09368d71
Platform Independend Newlines
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
0
diff
changeset
|
619 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
620 |
setPiece(t, new Piece(getPiece(o))); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
621 |
setPiece(o, new Piece(null, null, EMPTY, 0)); |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
622 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
623 |
if (rochade()) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
624 |
System.out.println("Rochade"); |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
625 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
626 |
if (isCheck(getColor(t))) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
627 |
// restore current positions |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
628 |
if (UNDO_DEBUG) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
629 |
print("UNDO", t, o, 0); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
630 |
undo(); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
631 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
632 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
633 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
634 |
board_pieces = getPieces(); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
635 |
repaint(); |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
636 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
637 |
moveNr = stack.size(); |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
638 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
639 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
640 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
641 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
642 |
/** |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
643 |
* converts the internal representation into normal chess notation and |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
644 |
* writes it to stdout |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
645 |
*/ |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
646 |
public void print(String s, int t, int o, int value) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
647 |
int row1, col1, row2, col2; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
648 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
649 |
row1 = o / 8; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
650 |
col1 = o - (8 * row1); |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
651 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
652 |
row2 = t / 8; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
653 |
col2 = t - (8 * row2); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
654 |
|
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
655 |
System.out.printf("%s: %C%d-%c%d = %3d%n", s, ('A') + col1, 8 - row1, ('A') + col2, 8 - row2, value); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
11
diff
changeset
|
656 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
657 |
} |