author | Markus Bröker <mbroeker@largo.homelinux.org> |
Fri, 17 Dec 2010 22:33:17 +0100 | |
changeset 14 | f12f77aa13b2 |
parent 13 | f83884cc7d2f |
child 15 | d4b2b9a87d80 |
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: CheckersBoard.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/checkersboard/CheckersBoard.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.checkersboard; |
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.History; |
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
12 |
import org.homelinux.largo.games.board.Piece; |
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
13 |
import org.homelinux.largo.utils.ImgComponent; |
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
14 |
|
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
15 |
public class CheckersBoard extends Board { |
14
f12f77aa13b2
serialVersionUID starts with 1L...
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
13
diff
changeset
|
16 |
static final long serialVersionUID = 1L; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
17 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
18 |
static final int PIECE = 1; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
19 |
static final int QUEEN = 2; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
20 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
21 |
final Piece white_super_sun = new Piece(new ImgComponent("images/white_super_sun.png").getImage(), "white", QUEEN, |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
22 |
50); |
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:
7
diff
changeset
|
24 |
final Piece black_super_sun = new Piece(new ImgComponent("images/black_super_sun.png").getImage(), "black", QUEEN, |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
25 |
50); |
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:
7
diff
changeset
|
27 |
void initBoard() { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
28 |
for (int i = 1; i < 8; i += 2) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
29 |
add(new ImgComponent("images/black_sun.png").getImage(), i, "black", PIECE); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
30 |
for (int i = 8; i < 15; i += 2) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
31 |
add(new ImgComponent("images/black_sun.png").getImage(), i, "black", PIECE); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
32 |
for (int i = 17; i <= 23; i += 2) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
33 |
add(new ImgComponent("images/black_sun.png").getImage(), i, "black", PIECE); |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
34 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
35 |
for (int i = 40; i < 47; i += 2) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
36 |
add(new ImgComponent("images/white_sun.png").getImage(), i, "white", PIECE); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
37 |
for (int i = 49; i <= 55; i += 2) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
38 |
add(new ImgComponent("images/white_sun.png").getImage(), i, "white", PIECE); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
39 |
for (int i = 56; i < 63; i += 2) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
40 |
add(new ImgComponent("images/white_sun.png").getImage(), i, "white", PIECE); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
41 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
42 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
43 |
/** |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
44 |
* The init method initializes a complete checkers board with figures and a |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
45 |
* history. |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
46 |
*/ |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
47 |
public void init() { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
48 |
super.init(); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
49 |
initBoard(); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
50 |
board_pieces = getPieces(); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
51 |
repaint(); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
52 |
} |
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:
7
diff
changeset
|
54 |
public CheckersBoard(int w, int h) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
55 |
super(w, h); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
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:
7
diff
changeset
|
58 |
void add(Image img, int i, String c, int t) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
59 |
int v = 0; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
60 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
61 |
switch (t) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
62 |
case PIECE: |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
63 |
v = 10; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
64 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
65 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
66 |
setPiece(i, new Piece(img, c, t, v)); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
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:
7
diff
changeset
|
69 |
/** |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
70 |
* Checks, wether this move is possible or not. |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
71 |
*/ |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
72 |
public boolean validMove(int t, int o) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
73 |
int steps; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
74 |
int rows; |
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:
7
diff
changeset
|
76 |
if (t == o) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
77 |
return false; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
78 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
79 |
if (isSamePiece(t, o)) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
80 |
return false; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
81 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
82 |
if (getType(o) == EMPTY) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
83 |
return false; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
84 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
85 |
/* |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
86 |
* 00 01 02 03 04 05 06 07 |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
87 |
* 08 09 10 11 12 13 14 15 |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
88 |
* 16 17 18 19 20 21 22 23 |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
89 |
* 24 25 26 27 28 29 30 31 |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
90 |
* 32 33 34 35 36 37 38 39 |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
91 |
* 40 41 42 43 44 45 46 47 |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
92 |
* 48 49 50 51 52 53 54 55 |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
93 |
* 56 57 58 59 60 61 62 63 |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
94 |
*/ |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
95 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
96 |
steps = Math.abs(t - o); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
97 |
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
|
98 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
99 |
switch (getType(o)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
100 |
case PIECE: |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
101 |
if (steps % 7 == 0) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
102 |
if (steps == 7 && rows == 1 && isEmpty(t)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
103 |
if (isBlack(o) && (t > o)) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
104 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
105 |
if (isWhite(o) && (t < o)) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
106 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
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:
7
diff
changeset
|
109 |
if (steps == 14 && rows == 2 && isEmpty(t)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
110 |
if (isBlack(o) && (t > o) && isEnemy(o + 7, o)) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
111 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
112 |
if (isWhite(o) && (t < o) && isEnemy(o - 7, o)) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
113 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
114 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
115 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
116 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
117 |
if (steps % 9 == 0) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
118 |
if (steps == 9 && rows == 1 && isEmpty(t)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
119 |
if (isBlack(o) && (t > o)) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
120 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
121 |
if (isWhite(o) && (t < o)) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
122 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
123 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
124 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
125 |
if (steps == 18 && rows == 2 && isEmpty(t)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
126 |
if (isBlack(o) && (t > o) && isEnemy(o + 9, o)) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
127 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
128 |
if (isWhite(o) && (t < o) && isEnemy(o - 9, o)) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
129 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
130 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
131 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
132 |
break; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
133 |
case QUEEN: |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
134 |
if (steps % 7 == 0 && isEmpty(t)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
135 |
if (steps == 7 && rows == 1) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
136 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
137 |
if (steps == 14 && rows == 2) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
138 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
139 |
if (steps == 21 && rows == 3) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
140 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
141 |
if (steps == 28 && rows == 4) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
142 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
143 |
if (steps == 35 && rows == 5) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
144 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
145 |
if (steps == 42 && rows == 6) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
146 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
147 |
if (steps == 49 && rows == 7) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
148 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
149 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
150 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
151 |
if (steps % 9 == 0 && isEmpty(t)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
152 |
if (steps == 9 && rows == 1) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
153 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
154 |
if (steps == 18 && rows == 2) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
155 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
156 |
if (steps == 27 && rows == 3) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
157 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
158 |
if (steps == 36 && rows == 4) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
159 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
160 |
if (steps == 45 && rows == 5) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
161 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
162 |
if (steps == 54 && rows == 6) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
163 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
164 |
if (steps == 63 && rows == 7) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
165 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
166 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
167 |
break; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
168 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
169 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
170 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
171 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
172 |
/** |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
173 |
* pop: undo the push operation. |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
174 |
*/ |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
175 |
public void undo() { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
176 |
History h1 = null; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
177 |
History h2 = null; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
178 |
int size = stack.size(); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
179 |
int pos; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
180 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
181 |
if (size < 2) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
182 |
return; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
183 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
184 |
h1 = stack.elementAt(size - 1); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
185 |
h2 = stack.elementAt(size - 2); |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
186 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
187 |
setPiece(h1.pos(), h1.piece()); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
188 |
setPiece(h2.pos(), h2.piece()); |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
189 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
190 |
if (getType(h2.pos()) != EMPTY) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
191 |
pos = 2 * h2.pos() - h1.pos(); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
192 |
if (pos >= 0 && pos < 64) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
193 |
setPiece(pos, new Piece(null, null, EMPTY, 0)); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
194 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
195 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
196 |
stack.setSize(size - 2); |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
197 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
198 |
/* Reset the current player */ |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
199 |
setBlacksTurn(h2.turn()); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
200 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
201 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
202 |
/** |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
203 |
* 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:
7
diff
changeset
|
204 |
* pieces and will not be painted. |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
205 |
*/ |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
206 |
public boolean simulateMove(int t, int o) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
207 |
int rows = Math.abs(t / 8 - o / 8); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
208 |
int pos; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
209 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
210 |
if (!validMove(t, o)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
211 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
212 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
213 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
214 |
if (rows == 2 && getType(o) == PIECE) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
215 |
pos = (t - o) / 2 + o; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
216 |
push(getPiece(pos), pos, getPiece(o), o); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
217 |
setPiece(pos, new Piece(null, null, EMPTY, 0)); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
218 |
} else |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
219 |
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
|
220 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
221 |
setPiece(t, new Piece(getPiece(o))); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
222 |
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
|
223 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
224 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
225 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
226 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
227 |
/** |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
228 |
* 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:
7
diff
changeset
|
229 |
* board_pieces and will be painted. |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
230 |
*/ |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
231 |
public boolean doMove(int t, int o) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
232 |
int steps = Math.abs(t - o); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
233 |
int rows = Math.abs(t / 8 - o / 8); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
234 |
int pos; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
235 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
236 |
if (!validMove(t, o)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
237 |
return false; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
238 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
239 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
240 |
if (rows == 2 && getType(o) == PIECE) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
241 |
pos = (t - o) / 2 + o; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
242 |
push(getPiece(pos), pos, getPiece(o), o); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
243 |
setPiece(pos, new Piece(null, null, EMPTY, 0)); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
244 |
} else if (rows >= 2 && getType(o) == QUEEN) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
245 |
if (steps % 7 == 0) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
246 |
if (t > o) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
247 |
for (pos = o + 7; pos <= t - 7; pos += 7) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
248 |
if (isEnemy(pos, o)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
249 |
push(getPiece(pos), pos, getPiece(o), o); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
250 |
setPiece(pos, new Piece(null, null, EMPTY, 0)); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
251 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
252 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
253 |
else { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
254 |
for (pos = o - 7; pos >= t + 7; pos -= 7) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
255 |
if (isEnemy(pos, o)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
256 |
push(getPiece(pos), pos, getPiece(o), o); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
257 |
setPiece(pos, new Piece(null, null, EMPTY, 0)); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
258 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
259 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
260 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
261 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
262 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
263 |
if (steps % 9 == 0) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
264 |
if (t > o) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
265 |
for (pos = o + 9; pos <= t - 9; pos += 9) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
266 |
if (isEnemy(pos, o)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
267 |
push(getPiece(pos), pos, getPiece(o), o); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
268 |
setPiece(pos, new Piece(null, null, EMPTY, 0)); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
269 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
270 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
271 |
else { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
272 |
for (pos = o - 9; pos >= t + 9; pos -= 9) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
273 |
if (isEnemy(pos, o)) { |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
274 |
push(getPiece(pos), pos, getPiece(o), o); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
275 |
setPiece(pos, new Piece(null, null, EMPTY, 0)); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
276 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
277 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
278 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
279 |
} |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
280 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
281 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
282 |
if (t <= 7 && getType(o) == PIECE) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
283 |
setPiece(t, new Piece(white_super_sun)); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
284 |
else if (t >= 56 && getType(o) == PIECE) |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
285 |
setPiece(t, new Piece(black_super_sun)); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
286 |
else |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
287 |
setPiece(t, new Piece(getPiece(o))); |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
288 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
289 |
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
|
290 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
291 |
board_pieces = getPieces(); |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
292 |
repaint(); |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
293 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
294 |
moveNr = stack.size(); |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
295 |
|
13
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
296 |
return true; |
f83884cc7d2f
Source Code re-formatted
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
7
diff
changeset
|
297 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
298 |
} |