mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2024-11-27 06:10:28 +01:00
DroidFish: When displaying tablebase info, only display the best score for pawn promotions.
This commit is contained in:
parent
25ce2e990f
commit
72b93358af
|
@ -19,6 +19,7 @@
|
||||||
package org.petero.droidfish;
|
package org.petero.droidfish;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.petero.droidfish.gamelogic.Move;
|
import org.petero.droidfish.gamelogic.Move;
|
||||||
|
@ -54,13 +55,22 @@ public class ChessBoard extends View {
|
||||||
List<Move> moveHints;
|
List<Move> moveHints;
|
||||||
|
|
||||||
/** Decoration for a square. Currently the only possible decoration is a number. */
|
/** Decoration for a square. Currently the only possible decoration is a number. */
|
||||||
public final static class SquareDecoration {
|
public final static class SquareDecoration implements Comparable<SquareDecoration> {
|
||||||
int sq;
|
int sq;
|
||||||
int number;
|
int number;
|
||||||
public SquareDecoration(int sq, int number) {
|
public SquareDecoration(int sq, int number) {
|
||||||
this.sq = sq;
|
this.sq = sq;
|
||||||
this.number = number;
|
this.number = number;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public int compareTo(SquareDecoration another) {
|
||||||
|
int M0 = 100000;
|
||||||
|
int n = number;
|
||||||
|
int s1 = (n > 0) ? M0 - n : ((n == 0) ? 0 : -M0-n);
|
||||||
|
n = another.number;
|
||||||
|
int s2 = (n > 0) ? M0 - n : ((n == 0) ? 0 : -M0-n);
|
||||||
|
return s2 - s1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private ArrayList<SquareDecoration> decorations;
|
private ArrayList<SquareDecoration> decorations;
|
||||||
|
|
||||||
|
@ -695,6 +705,8 @@ public class ChessBoard extends View {
|
||||||
}
|
}
|
||||||
if (!equal) {
|
if (!equal) {
|
||||||
this.decorations = decorations;
|
this.decorations = decorations;
|
||||||
|
if (this.decorations != null)
|
||||||
|
Collections.sort(this.decorations);
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -702,10 +714,14 @@ public class ChessBoard extends View {
|
||||||
private final void drawDecorations(Canvas canvas) {
|
private final void drawDecorations(Canvas canvas) {
|
||||||
if (decorations == null)
|
if (decorations == null)
|
||||||
return;
|
return;
|
||||||
|
long decorated = 0;
|
||||||
for (SquareDecoration sd : decorations) {
|
for (SquareDecoration sd : decorations) {
|
||||||
int sq = sd.sq;
|
int sq = sd.sq;
|
||||||
if ((sd.sq < 0) || (sd.sq >= 64))
|
if ((sd.sq < 0) || (sd.sq >= 64))
|
||||||
continue;
|
continue;
|
||||||
|
if (((1L << sq) & decorated) != 0)
|
||||||
|
continue;
|
||||||
|
decorated |= 1L << sq;
|
||||||
int xCrd = getXCrd(Position.getX(sq));
|
int xCrd = getXCrd(Position.getX(sq));
|
||||||
int yCrd = getYCrd(Position.getY(sq));
|
int yCrd = getYCrd(Position.getY(sq));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user