#include "gnushogi.h"
#include "pattern.h"
-extern void
-ShowStage(void);
-
/* Hash table for preventing multiple scoring of the same position */
int EADD = 0; /* number of writes to the cache table */
static int
-AttackedPieceValue(short sq, short side)
+AttackedPieceValue(short sq)
{
- short s, ds;
+ short s;
s = 0;
- ds = -fv1[HUNGP] * 2;
hung[c1]++;
shung[sq]++;
if (in_opening_stage)
{
+#ifndef MINISHOGI
+/* FIXME: [HGM] The 3rd-rank Pawn section is meaningless in mini-Shogi,
+ * (which does not have opposing Pawns), and can do out-of-bound access,
+ * as the promotion zone is only 1 rank, so Pawns can be closer than 3 ranks
+ * to the board edge.
+ */
if (crow(c1, sq) == 2) /* pawn on 3d rank */
{
if (board[(c1 == black) ?
}
}
+/* FIXME: calculations below are wrong for minishogi, all done for 9x9
+ * board - and anyway we don't know the stage really :)
+ */
if ((GameType[c1] == STATIC_ROOK) && (sq == csquare(c1, 43)))
{
if ((atk2[csquare(c1, 52)] & CNT_MASK) < 2)
s += (ds = -2 * fv1[ATTACKED]);
}
}
+#endif
}
return s;
*/
static inline int
-LanceValue(short sq, short side)
+LanceValue(short sq)
{
short s = 0, ds, ad;
*/
static inline int
-KnightValue(short sq, short side)
+KnightValue(short sq)
{
short s = 0, ad;
short ds, checked_trapped = false;
*/
static inline int
-SilverValue(short sq, short side)
+SilverValue(short sq)
{
short s= 0, ds, ad;
if (in_opening_stage)
{
+#ifndef MINISHOGI
+/* FIXME: calculations below are wrong for minishogi, all done for 9x9
+ * board - and anyway we don't know the stage really :)
+ */
if (GameType[c1] == STATIC_ROOK)
{
if (csquare(c1, sq) == 12)
}
}
}
+#endif
}
else
{
*/
static inline int
-GoldValue(short sq, short side)
+GoldValue(short sq)
{
short s = 0, ds, ad;
if (in_opening_stage)
{
+#ifndef MINISHOGI
+/* FIXME: calculations below are wrong for minishogi, all done for 9x9
+ * board - and anyway we don't know the stage really :)
+ */
if ((GameType[c1] == STATIC_ROOK) && (GameType[c2] != STATIC_ROOK))
{
if (Mvboard[csquare(c1, 3)])
s += (ds = -2 * fv1[OPENWRONG]);
}
}
+#endif
}
else
{
*/
static inline int
-BishopValue(short sq, short side)
+BishopValue(short sq)
{
short s = 0, ds, ad;
if (in_opening_stage)
{
+#ifndef MINISHOGI
+/* FIXME: calculations below are wrong for minishogi, all done for 9x9
+ * board - and anyway we don't know the stage really :)
+ */
if (GameType[c1] == RANGING_ROOK)
{
/* Bishops diagonal should not be open */
s += (ds = -fv1[OPENWRONG]);
}
}
+#endif
}
else
{
if (in_opening_stage)
{
+#ifndef MINISHOGI
+/* FIXME: calculations below are wrong for minishogi, all done for 9x9
+ * board - and anyway we don't know the stage really :)
+ */
short WRONG = fv1[OPENWRONG], OPOK = WRONG / 3;
if (GameType[c1] == STATIC_ROOK)
}
}
}
+#endif
}
else
{
*/
static inline int
-PPawnValue(short sq, short side)
+PPawnValue(short sq)
{
short s = 0, ds, ad;
*/
static inline int
-PLanceValue(short sq, short side)
+PLanceValue(short sq)
{
short s = 0, ds, ad;
*/
static inline int
-PKnightValue(short sq, short side)
+PKnightValue(short sq)
{
short s = 0, ds, ad;
*/
static inline int
-PSilverValue(short sq, short side)
+PSilverValue(short sq)
{
short s = 0, ds, ad;
*/
static inline int
-PBishopValue(short sq, short side)
+PBishopValue(short sq)
{
short s = 0, ds, ad;
*/
static inline int
-PRookValue(short sq, short side)
+PRookValue(short sq)
{
short s = 0, ds, ad;
*/
static inline int
-KingValue(short sq, short side)
+KingValue(short sq)
{
short s = 0, ds;
if (fv1[KSFTY] != 0)
s += KingScan(sq);
+#ifndef MINISHOGI
+/* FIXME: calculations below are wrong for minishogi, all done for 9x9
+ * board - and anyway we don't know the stage really :)
+ */
if (in_opening_stage)
{
if ((GameType[c1] != UNKNOWN) && (ccolumn(c1, sq) == 4))
s += (ds = -fv1[OPENWRONG] / 2);
}
}
+#endif
/* CHECKME: is this correct? */
if ((ds = fv1[HOPN]))
if (a1 == 0)
{
/* undefended piece */
- s += AttackedPieceValue(sq, side);
+ s += AttackedPieceValue(sq);
}
else
{
if (attack_value < piece_value)
{
/* attacked by a weaker piece */
- s += AttackedPieceValue(sq, side) / 2;
+ s += AttackedPieceValue(sq) / 2;
}
else if (abs(attack_value - piece_value) < 10)
{
#ifndef MINISHOGI
case lance:
- s += LanceValue(sq, side);
+ s += LanceValue(sq);
break;
case knight:
- s += KnightValue(sq, side);
+ s += KnightValue(sq);
break;
#endif
case silver:
- s += SilverValue(sq, side);
+ s += SilverValue(sq);
break;
case gold:
- s += GoldValue(sq, side);
+ s += GoldValue(sq);
break;
case bishop:
- s += BishopValue(sq, side);
+ s += BishopValue(sq);
break;
case rook:
break;
case king:
- s += KingValue(sq, side);
+ s += KingValue(sq);
break;
case ppawn:
- s += PPawnValue(sq, side);
+ s += PPawnValue(sq);
break;
#ifndef MINISHOGI
case plance:
- s += PLanceValue(sq, side);
+ s += PLanceValue(sq);
break;
case pknight:
- s += PKnightValue(sq, side);
+ s += PKnightValue(sq);
break;
#endif
case psilver:
- s += PSilverValue(sq, side);
+ s += PSilverValue(sq);
break;
case pbishop:
- s += PBishopValue(sq, side);
+ s += PBishopValue(sq);
break;
case prook:
- s += PRookValue(sq, side);
+ s += PRookValue(sq);
break;
}
}
if (flag.post)
- ShowPatternCount(side, n);
+ dsp->ShowPatternCount(side, n);
if (os != END_OF_SEQUENCES)
update_advance_bonus(side, os);
ScoreCaptures();
}
+#ifndef MINISHOGI
+# define BLACKHOME_START 0
+# define BLACKHOME_END 26
+# define MIDDLEROW_START 36
+# define MIDDLEROW_END 44
+# define WHITEHOME_START 54
+# define WHITEHOME_END 80
+#else
+# define BLACKHOME_START 0
+# define BLACKHOME_END 4
+# define MIDDLEROW_START 10
+# define MIDDLEROW_END 14
+# define WHITEHOME_START 19
+# define WHITEHOME_END 24
+#endif
for (c1 = black, c2 = white; c1 <= white; c1++, c2--)
{
short n;
fv1 = fvalue[c1];
/* Score fifth rank */
- for (sq = 36, n = 0; sq <= 44; sq++)
+ for (sq = MIDDLEROW_START, n = 0; sq <= MIDDLEROW_END; sq++)
{
if ((color[sq] == c1) || (attack[c1][sq] != 0))
n++;
}
/* Score holes */
- for (sq = ((c1 == black) ? 0 : 54), n = 0;
- sq <= ((c1 == black) ? 26 : 80);
+ for (sq = ((c1 == black) ? BLACKHOME_START : WHITEHOME_START), n = 0;
+ sq <= ((c1 == black) ? BLACKHOME_END : WHITEHOME_END);
sq++)
{
if (board[sq] == no_piece && attack[c1][sq] == 0)
* Try to determine the game type of "side".
*/
+#ifndef MINISHOGI
inline static void
GuessGameType(short side_to_move)
{
}
}
}
+#endif
{
short side;
+#ifndef MINISHOGI
+ /* FIXME: calculations below are wrong for minishogi, all done for 9x9 */
GuessGameType(side_to_move);
+#else
+ GameType[black] = UNKNOWN;
+ GameType[white] = UNKNOWN;
+#endif
array_zero(Mpawn, sizeof(Mpawn));
#ifndef MINISHOGI
}
else
{
- ShowPatternCount(black, -1);
- ShowPatternCount(white, -1);
+ dsp->ShowPatternCount(black, -1);
+ dsp->ShowPatternCount(white, -1);
}
}
+/* FIXME: calculations below are wrong for minishogi, all done for 9x9 */
void
DetermineStage(short side)
{
stage = 0;
if (flag.post)
- ShowStage();
+ dsp->ShowStage();
/* Determine stage dependant weights */
void
UpdateWeights(short stage)
{
+ /* FIXME: this was emptied between 1.1p02 ans 1.2p03, do we keep it ? */
}