[You must be registered and logged in to see this link.] [You must be registered and logged in to see this link.]by
[You must be registered and logged in to see this link.] » Mon Dec 03, 2012 1:19 pm
Since I am not allowed to write this at talkchess, I try it here.
I reccomend testers not to waste their time with Bouquet.
Why?
The "authoer" published his version of GreKo here:
[You must be registered and logged in to see this link.] ... 52&t=46205
But his version of GreKo is something hex-edited. He wasn't even able to use a compiler and changed some strings.
The source code he added looks like this:
Code:
[You must be registered and logged in to see this link.]#define VERSION "GreKo 7.2"
out("id name ");
out(VERSION);
out("\n");
out("id author Vladimir Medvedev\n");
out("option name Hash type spin default 1 min 1 max 1024\n");
out("option name MultiPV type spin default 1 min 1 max %d\n", MAX_BRANCH);
out("option name WeightMaterial type spin default 100 min 1 max 999\n");
out("option name WeightPSQ type spin default 100 min 1 max 999\n");
out("option name WeightMobility type spin default 100 min 1 max 999\n");
out("option name WeightKingSafety type spin default 100 min 1 max 999\n");
out("option name WeightPawns type spin default 100 min 1 max 999\n");
out("option name WeightPassedPawns type spin default 100 min 1 max 999\n");
out("option name UCI_LimitStrength type check default false\n");
out("option name UCI_Elo type spin default 2100 min 1200 max 2400\n");
out("option name LimitKNPS type spin default 9999 min 1 max 9999\n");
out("uciok\n");
And the output looks like this:
Code:
[You must be registered and logged in to see this link.]uci
id name Cafelito_1.0, Basado en Greko
id author Jose m velasco, Vladimir Medvedev
option name Hash type spin default 1 min 1 max 1024
option name MultiPV type spin default 1 min 1 max 128
option name UCI_Elo type spin default 3100 min 1200 max 3400
option name PS type spin default 99990 min 1 max 99990
uciok
You
can easily see that the source is not the source of the executeable,
you can even see that it is just a hex edited GreKo, he deleted some
lines, some letters of LimitNPS, added a zero to 9999 and made the
engine 1000 ELO stronger by changing the elo values. Clueless!
The
author is just trying to fool the community. If someone wants to waste
his time with Bouquet, well, his problem... But I want to be allowed to
write the truth, though it is maybe hard for some to recognize that they
got fooled, and especially hard for the author when he recognizes he
got caught...
[You must be registered and logged in to see this link.] Posts: 9
Joined: Wed Jun 09, 2010 3:14 pm
[You must be registered and logged in to see this link.] [You must be registered and logged in to see this link.] [You must be registered and logged in to see this link.]by
[You must be registered and logged in to see this link.] » Wed Dec 05, 2012 9:40 am
In the meantime I did some research about Bouquet and started an own blog for anyone who is interested:
[You must be registered and logged in to see this link.] Posts: 9
Joined: Wed Jun 09, 2010 3:14 pm
[You must be registered and logged in to see this link.] [You must be registered and logged in to see this link.] [You must be registered and logged in to see this link.]by
[You must be registered and logged in to see this link.] » Wed Dec 05, 2012 9:54 am
I think that the author was very forthcoming, at
least with his early versions, that Bouquet is based on the Ippolit
engines. He may have changed his marketing in the meantime.
Is it
any stronger than the generally available Ippo/Robbo/Ivo group?
Presumably it hasn't reached the Houdini 3 level, but Houdart has
convincingly demonstrated that the Robbolito source can be pushed that
far...
jb
[You must be registered and logged in to see this link.] Site Admin
Posts: 1022
Joined: Wed Jun 09, 2010 7:49 am
Location: Berlin, Germany
[You must be registered and logged in to see this link.] [You must be registered and logged in to see this link.] [You must be registered and logged in to see this link.]by
[You must be registered and logged in to see this link.] » Wed Dec 05, 2012 10:31 am
Jeremy Bernstein wrote:I
think that the author was very forthcoming, at least with his early
versions, that Bouquet is based on the Ippolit engines. He may have
changed his marketing in the meantime.
Is it any stronger than
the generally available Ippo/Robbo/Ivo group? Presumably it hasn't
reached the Houdini 3 level, but Houdart has convincingly demonstrated
that the Robbolito source can be pushed that far...
jb
It
is not a legal question. Everyone is allowed to use the sources of this
derivates. The question is: Is it worth to be tested? I think it is a
waste of resources to test engines which are clones with some random
changes by a wannabe programmer. This guy has also the chance to defend
himself, maybe I am wrong and he can show and explain his improvements
here.
[You must be registered and logged in to see this link.] Posts: 9
Joined: Wed Jun 09, 2010 3:14 pm
[You must be registered and logged in to see this link.] [You must be registered and logged in to see this link.] [You must be registered and logged in to see this link.]by
[You must be registered and logged in to see this link.] » Wed Dec 05, 2012 2:05 pm
Alexander Schmidt wrote:Since I am not allowed to write this at talkchess, I try it here.
I reccomend testers not to waste their time with Bouquet.
Why?
The "authoer" published his version of GreKo here:
[You must be registered and logged in to see this link.] ... 52&t=46205
But his version of GreKo is something hex-edited. He wasn't even able to use a compiler and changed some strings.
The source code he added looks like this:
Code: [You must be registered and logged in to see this link.]#define VERSION "GreKo 7.2"
out("id name ");
out(VERSION);
out("\n");
out("id author Vladimir Medvedev\n");
out("option name Hash type spin default 1 min 1 max 1024\n");
out("option name MultiPV type spin default 1 min 1 max %d\n", MAX_BRANCH);
out("option name WeightMaterial type spin default 100 min 1 max 999\n");
out("option name WeightPSQ type spin default 100 min 1 max 999\n");
out("option name WeightMobility type spin default 100 min 1 max 999\n");
out("option name WeightKingSafety type spin default 100 min 1 max 999\n");
out("option name WeightPawns type spin default 100 min 1 max 999\n");
out("option name WeightPassedPawns type spin default 100 min 1 max 999\n");
out("option name UCI_LimitStrength type check default false\n");
out("option name UCI_Elo type spin default 2100 min 1200 max 2400\n");
out("option name LimitKNPS type spin default 9999 min 1 max 9999\n");
out("uciok\n");
And the output looks like this:
Code: [You must be registered and logged in to see this link.]uci
id name Cafelito_1.0, Basado en Greko
id author Jose m velasco, Vladimir Medvedev
option name Hash type spin default 1 min 1 max 1024
option name MultiPV type spin default 1 min 1 max 128
option name UCI_Elo type spin default 3100 min 1200 max 3400
option name PS type spin default 99990 min 1 max 99990
uciok
You
can easily see that the source is not the source of the executeable,
you can even see that it is just a hex edited GreKo, he deleted some
lines, some letters of LimitNPS, added a zero to 9999 and made the
engine 1000 ELO stronger by changing the elo values. Clueless!
The
author is just trying to fool the community. If someone wants to waste
his time with Bouquet, well, his problem... But I want to be allowed to
write the truth, though it is maybe hard for some to recognize that they
got fooled, and especially hard for the author when he recognizes he
got caught...
Alexander, you were not told that you could not write about it at CCC.
As
I told you, the output does make Cafelito look to be the result of hex
editing. Yet, it does not look like a hex edit of the official GreKo
compiles nor JA compiles. Furthermore, Jose has made his own compiles of
GreKo and distributed them in the past. See
[You must be registered and logged in to see this link.] .
Have
you proven that Carelito is not his own compilation of GreKo sources?
You are denouncing Jose strongly, but have not eliminated other
possibilities. The only thing that can definitely said is that the
source he bundled with Cafelito is the wrong source code. They are
identical to GreKo 7.2 source code. And that Cafelito plays more like
GreKo 8.
Also, he has openly stated that Bouquet is derived from
Robbolito (though he has not openly stated how much Bouquet 1.5 is like
Fire). So no one has been fooled by that engine.
[You must be registered and logged in to see this link.] Posts: 91
Joined: Fri Jun 11, 2010 4:29 am
[You must be registered and logged in to see this link.] [You must be registered and logged in to see this link.] [You must be registered and logged in to see this link.]by
[You must be registered and logged in to see this link.] » Wed Dec 05, 2012 3:58 pm
Adam Hair wrote:Alexander, you were not told that you could not write about it at CCC.
My post was deleted. The moderators named 3 different reason why it was deleted.
Cafelito is released with source under GPL, everything is fine with it
My post was not understandable
My post was attacking Bouquet
You
encouraged me to repost with an additional comment which would have not
affected any of the so called reasons above. I think we discussed
enough about it. I won't write what a moderator dictates.
Adam Hair wrote:Have you proven that Carelito is not his own compilation of GreKo sources?
The
UCI output I posted is proof enough. Noone with just a little
programming skills would do something like that deliberately. Discussion
about this is really a waste of time. Of course someone can create a
code that makes this sensless output, but as long as there is no logical
explenation for such sensless changes even a court would base its
decission on a presumptive evidence.
Mr. Velasco is free to
refute the accusation and explain why he changed the option name of
LimitNPS to PS, why he set the default value for it from 9999 to 99990. I
just doubt he can explain that. It is not the task of moderators to
judge an accusation and delete it because someone don't like it. I
insulted nobody, I didn't violate the charter. We would get one step
ahead if you would accept that basic principle of free speech. Of course
you are free to delete whatever you like, but I am free to leave such
kind of forum. Right now the link to the GPL violating copy of GreKo is
still there. Obviously it is better to post a illegal copy of an engine
than to point on it. What a farce.
[You must be registered and logged in to see this link.] Posts: 9
Joined: Wed Jun 09, 2010 3:14 pm
[You must be registered and logged in to see this link.] [You must be registered and logged in to see this link.] [You must be registered and logged in to see this link.]by
[You must be registered and logged in to see this link.] » Thu Dec 06, 2012 12:06 pm
Much attack
Much Honor.
For parties, you can read the readme that comes with Bouquet.
The author, I mean myself, admittedly not a professional programmer.
I'm not looking for profit, the program is for everyone free of charge.
I have a few years in this as chess aficionado and programming.
Ippolit decided to develop sources on my own, create a project and give it stability, no crime and nothing to hide.
Lo cafelito you, Alexander,
know what a Hex edit??,
locate a single executable Greko cafelito resembling, or size or anything, as you can say it is a HEX edit, you have no idea.
Cafelito
not presented as a driver, it was just a joke to another gentleman who
was asking me something else, this project was made more than a year,
remove things and added some different assessment, and I must admit that
I knew much less than now that is little.
As the code is crap cafelito decided to put the author in recognition, it was only a joke.
And you me riding a blog, the honor.
Cafelito eval File:
Code:
[You must be registered and logged in to see this link.]#include "aval.h"
#include "config.h"
EVAL VAL_P = 100;
EVAL VAL_N = 350;
EVAL VAL_B = 370;
EVAL VAL_R = 550;
EVAL VAL_Q = 1100;
int VAL_Pp = 100;
int VAL_Np = 350;
int VAL_Bp = 370;
int VAL_Rp = 550;
int VAL_Qp = 1100;
EVAL LazyEval = 150;
EVAL INICIAL = ((2*VAL_Q)+(4*VAL_R)+(4*VAL_B)+(4*VAL_N)+(16*VAL_P));//9600
EVAL APERTURA = ((VAL_Q)+(4*VAL_R)+(4*VAL_B)+(4*VAL_N)+(12*VAL_P));//8000
EVAL MEDIOJUEGO = ((4*VAL_R)+(3*VAL_B)+(3*VAL_N)+(8*VAL_P));//5800
EVAL FINAL = ((4*VAL_R)+(VAL_B)+(VAL_N)+(4*VAL_P));//3400
EVAL FINALA = ((2*VAL_R)+(VAL_B)+(VAL_N)+(2*VAL_P));//2400
EVAL FINALB = ((VAL_B)+(VAL_N)+(4*VAL_P));//1200
EVAL PawnDoubled = -15;
EVAL PawnIsolated = -15;
EVAL PawnBackwards = -5;
EVAL PawnDuo = 10;
EVAL PawnTrio = 15;
EVAL PawnCenter = 20;
EVAL PawnPassed = 120;
EVAL PawnPassedSquare = 120;
//EVAL KnigthInicio = 20;
EVAL KnightCenter = 30;
EVAL KnightOutpost = 10;
//EVAL BishopPair = 50;
EVAL BishopCenter = 20;
EVAL BishopMobility = 45;
EVAL RookMobility = 30;
EVAL Rook7th = 20;
EVAL RookOpen = 10;
EVAL QueenKingTropism = 40;
EVAL QueenCenterEnd = 30;
EVAL KingCenterMid = -40;
EVAL KingCenterEnd = 40;
EVAL KingPawnShield = 100;
EVAL PSQ_P[64];
EVAL PSQ_P_I[64];
EVAL PSQ_P_END[64];
EVAL PSQ_N[64];
EVAL PSQ_N_I[64];
EVAL PSQ_B[64];
EVAL PSQ_B_I[64];
EVAL PSQ_R[64];
EVAL PSQ_Q_END[64];
EVAL PSQ_Q_MED[64];
EVAL PSQ_K_MID[64];
EVAL PSQ_K_END[64];
EVAL BISHOP_MOBILITY[14];
EVAL ROOK_MOBILITY[15];
EVAL QUEEN_KING_TROPISM[15];
EVAL KING_PAWN_SHIELD[10];
EVAL BISHOP_PAIR[17]={ 60, 55, 55, 50, 50, 45, 45, 40, 40,
35, 35, 30, 30, 25, 25, 20, 20 };
//EVAL ajuste_knight[9] = { -14, -10, -8, -4, -2, 0, 4, 8, 12};
//EVAL ajuste_rook[9] = { 12, 10, 7, 4, 2, 0, -3, -6, -9};
struct PawnEntry
{
U32 m_pawnHash;
int m_ranks[10][2];
EVAL m_score;
U64 m_passed[2];
void Read(const Position& pos);
void Readend(const Position& pos);
};
const int g_pawnHashSize = 16384;
PawnEntry g_pawnHash[g_pawnHashSize];
////////////////////////////////////////////////////////////////////////////////
/*void SetqueenValue(int queenValue)
{
EVAL VAL_Q = (queenValue);
}*/
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
int PawnShieldWhite(const PawnEntry& pentry, FLD K)
{
int r = 0;
int file = Col(K) + 1;
for (int i = file - 1; i <= file + 1; ++i)
{
int rank = pentry.m_ranks[i][WHITE];
if (rank == 6)
;
else if (rank == 5)
r += 1;
else if (rank == 4)
r += 2;
else
r += 3;
}
return r;
}
////////////////////////////////////////////////////////////////////////////////
int PawnShieldBlack(const PawnEntry& pentry, FLD K)
{
int r = 0;
int file = Col(K) + 1;
for (int i = file - 1; i <= file + 1; ++i)
{
int rank = pentry.m_ranks[i][BLACK];
if (rank == 1)
;
else if (rank == 2)
r += 1;
else if (rank == 3)
r += 2;
else
r += 3;
}
return r;
}
////////////////////////////////////////////////////////////////////////////////
EVAL Evaluate(const Position& pos, EVAL alpha, EVAL beta)
{
EVAL totScore = pos.Material(WHITE) + pos.Material(BLACK);
//*************************************************************************** 1
if ((totScore > APERTURA)&&(totScore <= INICIAL))
//*************************************************************************** 1
{
EVAL matScore = pos.Material(WHITE) - pos.Material(BLACK);
EVAL posScore = 0;
if (pos.Count(BW) == 2)
matScore += BISHOP_PAIR[PW+PB];
if (pos.Count(BB) == 2)
matScore -= BISHOP_PAIR[PW+PB];
EVAL lazy = (pos.Side() == WHITE)? matScore : -matScore;
if (lazy <= alpha - LazyEval)
return alpha;
if (lazy >= beta + LazyEval)
return beta;
U64 x, y, occ = pos.BitsAll();
FLD f;
//
// PAWNS
//
int index = pos.PawnHash() % g_pawnHashSize;
PawnEntry& pentry = g_pawnHash[index];
if (pentry.m_pawnHash != pos.PawnHash())
pentry.Read(pos);
posScore += pentry.m_score;
x = pentry.m_passed[WHITE];
while (x)
{
f = PopLSB(x);
posScore += PawnPassed * (7 - Row(f)) / 6;
if (pos.MatIndex(BLACK) == 0)
{
FLD f1 = f;
if (pos.Side() == BLACK)
f1 += 8;
if ((BB_PAWN_SQUARE[f1][WHITE] & pos.Bits(KB)) == 0)
posScore += PawnPassedSquare * (7 - Row(f1)) / 6;
}
}
x = pentry.m_passed[BLACK];
while (x)
{
f = PopLSB(x);
posScore -= PawnPassed * Row(f) / 6;
if (pos.MatIndex(WHITE) == 0)
{
FLD f1 = f;
if (pos.Side() == WHITE)
f1 -= 8;
if ((BB_PAWN_SQUARE[f1][BLACK] & pos.Bits(KW)) == 0)
posScore -= PawnPassedSquare * Row(f1) / 6;
}
}
//
// KNIGHTS
//
static const int outpost[64] =
{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 1, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 0,
0, 0, 1, 1, 1, 1, 0, 0,
0, 0, 1, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
x = pos.Bits(NW);
while (x)
{
f = PopLSB(x);
posScore += PSQ_N_I[f];
if (outpost[f])
{
if (BB_PAWN_ATTACKS[f][BLACK] & pos.Bits(PW))
posScore += KnightOutpost;
}
}
x = pos.Bits(NB);
while (x)
{
f = PopLSB(x);
posScore -= PSQ_N_I[FLIP[f]];
if (outpost[FLIP[f]])
{
if (BB_PAWN_ATTACKS[f][WHITE] & pos.Bits(PB))
posScore -= KnightOutpost;
}
}
//
// BISHOPS
//
x = pos.Bits(BW);
while (x)
{
f = PopLSB(x);
posScore += PSQ_B_I[f];
y = BishopAttacks(f, occ);
posScore += BISHOP_MOBILITY[CountBits(y)];
}
x = pos.Bits(BB);
while (x)
{
f = PopLSB(x);
posScore -= PSQ_B_I[FLIP[f]];
y = BishopAttacks(f, occ);
posScore -= BISHOP_MOBILITY[CountBits(y)];
}
//
// ROOKS
//
x = pos.Bits(RW);
while (x)
{
f = PopLSB(x);
posScore += PSQ_R[f];
y = RookAttacks(f, occ);
posScore += ROOK_MOBILITY[CountBits(y)];
if (Row(f) == 1)
posScore += Rook7th;
int file = Col(f) + 1;
if (pentry.m_ranks[file][WHITE] == 0)
posScore += RookOpen;
if (pentry.m_ranks[file][WHITE && BLACK] == 0)
posScore += RookOpen ;
}
x = pos.Bits(RB);
while (x)
{
f = PopLSB(x);
posScore -= PSQ_R[FLIP[f]];
y = RookAttacks(f, occ);
posScore -= ROOK_MOBILITY[CountBits(y)];
if (Row(f) == 6)
posScore -= Rook7th;
int file = Col(f) + 1;
if (pentry.m_ranks[file][BLACK] == 0)
posScore -= RookOpen;
if (pentry.m_ranks[file][BLACK && WHITE] == 0)
posScore -= RookOpen;
}
//
// QUEENS
//
x = pos.Bits(QW);
while (x)
{
f = PopLSB(x);
posScore += (PSQ_Q_MED[f]/2);
if (Row(f) == 1)
posScore += Rook7th;
int drow = Row(f) - Row(pos.King(BLACK));
int dcol = Col(f) - Col(pos.King(BLACK));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore += QUEEN_KING_TROPISM[dist];
}
x = pos.Bits(QB);
while (x)
{
f = PopLSB(x);
posScore -= (PSQ_Q_MED[FLIP[f]]/2);
if (Row(f) == 1)
posScore -= Rook7th;
int drow = Row(f) - Row(pos.King(WHITE));
int dcol = Col(f) - Col(pos.King(WHITE));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore -= QUEEN_KING_TROPISM[dist];
}
//
// KINGS
//
{
f = pos.King(WHITE);
posScore += PSQ_K_MID[f] * pos.MatIndex(BLACK) / 32;
posScore += PSQ_K_END[f] * (32 - pos.MatIndex(BLACK)) / 32;
int penalty = PawnShieldWhite(pentry, f);
posScore += KING_PAWN_SHIELD[penalty] * pos.MatIndex(BLACK) / 32;
}
{
f = pos.King(BLACK);
posScore -= PSQ_K_MID[FLIP[f]] * pos.MatIndex(WHITE) / 32;
posScore -= PSQ_K_END[FLIP[f]] * (32 - pos.MatIndex(WHITE)) / 32;
int penalty = PawnShieldBlack(pentry, f);
posScore -= KING_PAWN_SHIELD[penalty] * pos.MatIndex(WHITE) / 32;
}
EVAL e = matScore + posScore;
if (pos.Count(PW) == 0 && pos.MatIndex(WHITE) < 5 && e > 0)
e = 0;
if (pos.Count(PB) == 0 && pos.MatIndex(BLACK) < 5 && e < 0)
e = 0;
return (pos.Side() == WHITE)? e : -e;
}
//*************************************************************************** 1
else if ((totScore > MEDIOJUEGO)&&(totScore <= APERTURA))
//*************************************************************************** 1
{
EVAL matScore = pos.Material(WHITE) - pos.Material(BLACK);
EVAL posScore = 0;
if (pos.Count(BW) == 2)
matScore += BISHOP_PAIR[PW+PB];
if (pos.Count(BB) == 2)
matScore -= BISHOP_PAIR[PW+PB];
EVAL lazy = (pos.Side() == WHITE)? matScore : -matScore;
if (lazy <= alpha - LazyEval)
return alpha;
if (lazy >= beta + LazyEval)
return beta;
U64 x, y, occ = pos.BitsAll();
FLD f;
//
// PAWNS
//
int index = pos.PawnHash() % g_pawnHashSize;
PawnEntry& pentry = g_pawnHash[index];
if (pentry.m_pawnHash != pos.PawnHash())
pentry.Read(pos);
posScore += pentry.m_score;
x = pentry.m_passed[WHITE];
while (x)
{
f = PopLSB(x);
posScore += PawnPassed * (7 - Row(f)) / 6;
if (pos.MatIndex(BLACK) == 0)
{
FLD f1 = f;
if (pos.Side() == BLACK)
f1 += 8;
if ((BB_PAWN_SQUARE[f1][WHITE] & pos.Bits(KB)) == 0)
posScore += PawnPassedSquare * (7 - Row(f1)) / 6;
}
}
x = pentry.m_passed[BLACK];
while (x)
{
f = PopLSB(x);
posScore -= PawnPassed * Row(f) / 6;
if (pos.MatIndex(WHITE) == 0)
{
FLD f1 = f;
if (pos.Side() == WHITE)
f1 -= 8;
if ((BB_PAWN_SQUARE[f1][BLACK] & pos.Bits(KW)) == 0)
posScore -= PawnPassedSquare * Row(f1) / 6;
}
}
//
// KNIGHTS
//
static const int outpost[64] =
{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 1, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 0,
0, 0, 1, 1, 1, 1, 0, 0,
0, 0, 1, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
x = pos.Bits(NW);
while (x)
{
f = PopLSB(x);
posScore += PSQ_N_I[f];
if (outpost[f])
{
if (BB_PAWN_ATTACKS[f][BLACK] & pos.Bits(PW))
posScore += KnightOutpost;
}
}
x = pos.Bits(NB);
while (x)
{
f = PopLSB(x);
posScore -= PSQ_N_I[FLIP[f]];
if (outpost[FLIP[f]])
{
if (BB_PAWN_ATTACKS[f][WHITE] & pos.Bits(PB))
posScore -= KnightOutpost;
}
}
//
// BISHOPS
//
x = pos.Bits(BW);
while (x)
{
f = PopLSB(x);
posScore += PSQ_B_I[f];
y = BishopAttacks(f, occ);
posScore += BISHOP_MOBILITY[CountBits(y)];
}
x = pos.Bits(BB);
while (x)
{
f = PopLSB(x);
posScore -= PSQ_B_I[FLIP[f]];
y = BishopAttacks(f, occ);
posScore -= BISHOP_MOBILITY[CountBits(y)];
}
//
// ROOKS
//
x = pos.Bits(RW);
while (x)
{
f = PopLSB(x);
posScore += PSQ_R[f];
y = RookAttacks(f, occ);
posScore += ROOK_MOBILITY[CountBits(y)];
if (Row(f) == 1)
posScore += Rook7th;
int file = Col(f) + 1;
if (pentry.m_ranks[file][WHITE] == 0)
posScore += RookOpen;
if (pentry.m_ranks[file][WHITE && BLACK] == 0)
posScore += RookOpen ;
}
x = pos.Bits(RB);
while (x)
{
f = PopLSB(x);
posScore -= PSQ_R[FLIP[f]];
y = RookAttacks(f, occ);
posScore -= ROOK_MOBILITY[CountBits(y)];
if (Row(f) == 6)
posScore -= Rook7th;
int file = Col(f) + 1;
if (pentry.m_ranks[file][BLACK] == 0)
posScore -= RookOpen;
if (pentry.m_ranks[file][BLACK && WHITE] == 0)
posScore -= RookOpen;
}
//
// QUEENS
//
x = pos.Bits(QW);
while (x)
{
f = PopLSB(x);
posScore += PSQ_Q_MED[f];
if (Row(f) == 1)
posScore += Rook7th;
int drow = Row(f) - Row(pos.King(BLACK));
int dcol = Col(f) - Col(pos.King(BLACK));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore += QUEEN_KING_TROPISM[dist];
}
x = pos.Bits(QB);
while (x)
{
f = PopLSB(x);
posScore -= PSQ_Q_MED[FLIP[f]];
if (Row(f) == 1)
posScore -= Rook7th;
int drow = Row(f) - Row(pos.King(WHITE));
int dcol = Col(f) - Col(pos.King(WHITE));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore -= QUEEN_KING_TROPISM[dist];
}
//
// KINGS
//
{
f = pos.King(WHITE);
posScore += PSQ_K_MID[f] * pos.MatIndex(BLACK) / 32;
posScore += PSQ_K_END[f] * (32 - pos.MatIndex(BLACK)) / 32;
int penalty = PawnShieldWhite(pentry, f);
posScore += KING_PAWN_SHIELD[penalty] * pos.MatIndex(BLACK) / 32;
}
{
f = pos.King(BLACK);
posScore -= PSQ_K_MID[FLIP[f]] * pos.MatIndex(WHITE) / 32;
posScore -= PSQ_K_END[FLIP[f]] * (32 - pos.MatIndex(WHITE)) / 32;
int penalty = PawnShieldBlack(pentry, f);
posScore -= KING_PAWN_SHIELD[penalty] * pos.MatIndex(WHITE) / 32;
}
EVAL e = matScore + posScore;
if (pos.Count(PW) == 0 && pos.MatIndex(WHITE) < 5 && e > 0)
e = 0;
if (pos.Count(PB) == 0 && pos.MatIndex(BLACK) < 5 && e < 0)
e = 0;
return (pos.Side() == WHITE)? e : -e;
}
//*************************************************************************** 1
if ((totScore > FINAL)&&(totScore <= MEDIOJUEGO))
//*************************************************************************** 1
{
EVAL matScore = pos.Material(WHITE) - pos.Material(BLACK);
EVAL posScore = 0;
if (pos.Count(BW) == 2)
matScore += BISHOP_PAIR[PW+PB];
if (pos.Count(BB) == 2)
matScore -= BISHOP_PAIR[PW+PB];
EVAL lazy = (pos.Side() == WHITE)? matScore : -matScore;
if (lazy <= alpha - LazyEval)
return alpha;
if (lazy >= beta + LazyEval)
return beta;
U64 x, y, occ = pos.BitsAll();
FLD f;
//
// PAWNS
//
int index = pos.PawnHash() % g_pawnHashSize;
PawnEntry& pentry = g_pawnHash[index];
if (pentry.m_pawnHash != pos.PawnHash())
pentry.Read(pos);
posScore += pentry.m_score;
x = pentry.m_passed[WHITE];
while (x)
{
f = PopLSB(x);
posScore += PawnPassed * (7 - Row(f)) / 6;
if (pos.MatIndex(BLACK) == 0)
{
FLD f1 = f;
if (pos.Side() == BLACK)
f1 += 8;
if ((BB_PAWN_SQUARE[f1][WHITE] & pos.Bits(KB)) == 0)
posScore += PawnPassedSquare * (7 - Row(f1)) / 6;
}
}
x = pentry.m_passed[BLACK];
while (x)
{
f = PopLSB(x);
posScore -= PawnPassed * Row(f) / 6;
if (pos.MatIndex(WHITE) == 0)
{
FLD f1 = f;
if (pos.Side() == WHITE)
f1 -= 8;
if ((BB_PAWN_SQUARE[f1][BLACK] & pos.Bits(KW)) == 0)
posScore -= PawnPassedSquare * Row(f1) / 6;
}
}
//
// KNIGHTS
//
static const int outpost[64] =
{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 1, 1, 0, 0,
0, 0, 1, 1, 1, 1, 0, 0,
0, 0, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
x = pos.Bits(NW);
while (x)
{
f = PopLSB(x);
posScore += PSQ_N[f];
if (outpost[f])
{
if (BB_PAWN_ATTACKS[f][BLACK] & pos.Bits(PW))
posScore += KnightOutpost;
}
}
x = pos.Bits(NB);
while (x)
{
f = PopLSB(x);
posScore -= PSQ_N[FLIP[f]];
if (outpost[FLIP[f]])
{
if (BB_PAWN_ATTACKS[f][WHITE] & pos.Bits(PB))
posScore -= KnightOutpost;
}
}
//
// BISHOPS
//
x = pos.Bits(BW);
while (x)
{
f = PopLSB(x);
posScore += PSQ_B[f];
y = BishopAttacks(f, occ);
posScore += BISHOP_MOBILITY[CountBits(y)];
}
x = pos.Bits(BB);
while (x)
{
f = PopLSB(x);
posScore -= PSQ_B[FLIP[f]];
y = BishopAttacks(f, occ);
posScore -= BISHOP_MOBILITY[CountBits(y)];
}
//
// ROOKS
//
x = pos.Bits(RW);
while (x)
{
f = PopLSB(x);
posScore += PSQ_R[f];
y = RookAttacks(f, occ);
posScore += ROOK_MOBILITY[CountBits(y)];
if (Row(f) == 1)
posScore += Rook7th;
int file = Col(f) + 1;
if (pentry.m_ranks[file][WHITE] == 0)
posScore += RookOpen;
if (pentry.m_ranks[file][WHITE && BLACK] == 0)
posScore += RookOpen ;
int drow = Row(f) - Row(pos.King(BLACK));
int dcol = Col(f) - Col(pos.King(BLACK));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore += QUEEN_KING_TROPISM[dist];
}
x = pos.Bits(RB);
while (x)
{
f = PopLSB(x);
posScore -= PSQ_R[FLIP[f]];
y = RookAttacks(f, occ);
posScore -= ROOK_MOBILITY[CountBits(y)];
if (Row(f) == 6)
posScore -= Rook7th;
int file = Col(f) + 1;
if (pentry.m_ranks[file][BLACK] == 0)
posScore -= RookOpen;
if (pentry.m_ranks[file][BLACK && WHITE] == 0)
posScore -= RookOpen;
int drow = Row(f) - Row(pos.King(WHITE));
int dcol = Col(f) - Col(pos.King(WHITE));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore -= QUEEN_KING_TROPISM[dist];
}
//
// QUEENS
//
x = pos.Bits(QW);
while (x)
{
f = PopLSB(x);
posScore += PSQ_Q_MED[f];
if (Row(f) == 1)
posScore += Rook7th;
int drow = Row(f) - Row(pos.King(BLACK));
int dcol = Col(f) - Col(pos.King(BLACK));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore += QUEEN_KING_TROPISM[dist*2];
}
x = pos.Bits(QB);
while (x)
{
f = PopLSB(x);
posScore -= PSQ_Q_MED[FLIP[f]];
if (Row(f) == 1)
posScore -= Rook7th;
int drow = Row(f) - Row(pos.King(WHITE));
int dcol = Col(f) - Col(pos.King(WHITE));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore -= QUEEN_KING_TROPISM[dist*2];
}
//
// KINGS
//
{
f = pos.King(WHITE);
posScore += PSQ_K_MID[f] * pos.MatIndex(BLACK) / 32;
posScore += PSQ_K_END[f] * (32 - pos.MatIndex(BLACK)) / 32;
int penalty = PawnShieldWhite(pentry, f);
posScore += KING_PAWN_SHIELD[penalty] * pos.MatIndex(BLACK) / 32;
}
{
f = pos.King(BLACK);
posScore -= PSQ_K_MID[FLIP[f]] * pos.MatIndex(WHITE) / 32;
posScore -= PSQ_K_END[FLIP[f]] * (32 - pos.MatIndex(WHITE)) / 32;
int penalty = PawnShieldBlack(pentry, f);
posScore -= KING_PAWN_SHIELD[penalty] * pos.MatIndex(WHITE) / 32;
}
EVAL e = matScore + posScore;
if (pos.Count(PW) == 0 && pos.MatIndex(WHITE) < 5 && e > 0)
e = 0;
if (pos.Count(PB) == 0 && pos.MatIndex(BLACK) < 5 && e < 0)
e = 0;
return (pos.Side() == WHITE)? e : -e;
}
//*************************************************************************** 1
else if ((totScore > FINALA)&&(totScore <= FINAL))
//*************************************************************************** 2
{
EVAL matScore = pos.Material(WHITE) - pos.Material(BLACK);
EVAL posScore = 0;
if (pos.Count(BW) == 2)
matScore += BISHOP_PAIR[PW+PB];
if (pos.Count(BB) == 2)
matScore -= BISHOP_PAIR[PW+PB];
EVAL lazy = (pos.Side() == WHITE)? matScore : -matScore;
if (lazy <= alpha - LazyEval)
return alpha;
if (lazy >= beta + LazyEval)
return beta;
U64 x, y, occ = pos.BitsAll();
FLD f;
//
// PAWNS
//
int index = pos.PawnHash() % g_pawnHashSize;
PawnEntry& pentry = g_pawnHash[index];
if (pentry.m_pawnHash != pos.PawnHash())
pentry.Readend(pos);
posScore += pentry.m_score;
x = pentry.m_passed[WHITE];
while (x)
{
f = PopLSB(x);
posScore += PawnPassed * (7 - Row(f)) / 6;
if (pos.MatIndex(BLACK) == 0)
{
FLD f1 = f;
if (pos.Side() == BLACK)
f1 += 8;
if ((BB_PAWN_SQUARE[f1][WHITE] & pos.Bits(KB)) == 0)
posScore += PawnPassedSquare * (7 - Row(f1)) / 6;
}
}
x = pentry.m_passed[BLACK];
while (x)
{
f = PopLSB(x);
posScore -= PawnPassed * Row(f) / 6;
if (pos.MatIndex(WHITE) == 0)
{
FLD f1 = f;
if (pos.Side() == WHITE)
f1 -= 8;
if ((BB_PAWN_SQUARE[f1][BLACK] & pos.Bits(KW)) == 0)
posScore -= PawnPassedSquare * Row(f1) / 6;
}
}
//
// KNIGHTS
//
static const int outpost[64] =
{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 1, 1, 0, 0,
0, 0, 1, 1, 1, 1, 0, 0,
0, 1, 1, 1, 1, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
x = pos.Bits(NW);
while (x)
{
// if (pos.Count(x) >= 1)
// posScore += ajuste_knight[pos.Count(PW)];
f = PopLSB(x);
int drow = Row(f) - Row(pos.King(BLACK));
int dcol = Col(f) - Col(pos.King(BLACK));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore += QUEEN_KING_TROPISM[dist];
posScore += PSQ_N[f];
if (outpost[f])
{
if (BB_PAWN_ATTACKS[f][BLACK] & pos.Bits(PW))
posScore += KnightOutpost;
}
}
x = pos.Bits(NB);
while (x)
{
// if (pos.Count(x) >= 1)
// posScore -= ajuste_knight[pos.Count(PB)];
f = PopLSB(x);
int drow = Row(f) - Row(pos.King(WHITE));
int dcol = Col(f) - Col(pos.King(WHITE));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore -= QUEEN_KING_TROPISM[dist];
posScore -= PSQ_N[FLIP[f]];
if (outpost[FLIP[f]])
{
if (BB_PAWN_ATTACKS[f][WHITE] & pos.Bits(PB))
posScore -= KnightOutpost;
}
}
//
// BISHOPS
//
x = pos.Bits(BW);
while (x)
{
f = PopLSB(x);
int drow = Row(f) - Row(pos.King(BLACK));
int dcol = Col(f) - Col(pos.King(BLACK));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore += QUEEN_KING_TROPISM[dist];
posScore += PSQ_B[f];
y = BishopAttacks(f, occ);
posScore += BISHOP_MOBILITY[CountBits(y)];
}
x = pos.Bits(BB);
while (x)
{
f = PopLSB(x);
int drow = Row(f) - Row(pos.King(WHITE));
int dcol = Col(f) - Col(pos.King(WHITE));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore -= QUEEN_KING_TROPISM[dist];
posScore -= PSQ_B[FLIP[f]];
y = BishopAttacks(f, occ);
posScore -= BISHOP_MOBILITY[CountBits(y)];
}
//
// ROOKS
//
x = pos.Bits(RW);
while (x)
{
// if (pos.Count(x) >= 1)
// posScore += ajuste_rook[pos.Count(PW)];
f = PopLSB(x);
y = RookAttacks(f, occ);
posScore += ROOK_MOBILITY[CountBits(y)];
if (Row(f) == 1)
posScore += Rook7th;
int file = Col(f) + 1;
if (pentry.m_ranks[file][WHITE] == 0)
posScore += RookOpen;
if (pentry.m_ranks[file][WHITE && BLACK] == 0)
posScore += RookOpen;
int drow = Row(f) - Row(pos.King(BLACK));
int dcol = Col(f) - Col(pos.King(BLACK));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore += QUEEN_KING_TROPISM[dist];
}
x = pos.Bits(RB);
while (x)
{
// if (pos.Count(x) >= 1)
// posScore -= ajuste_rook[pos.Count(PB)];
f = PopLSB(x);
y = RookAttacks(f, occ);
posScore -= ROOK_MOBILITY[CountBits(y)];
if (Row(f) == 6)
posScore -= Rook7th;
int file = Col(f) + 1;
if (pentry.m_ranks[file][BLACK] == 0)
posScore -= RookOpen;
if (pentry.m_ranks[file][WHITE && BLACK] == 0)
posScore -= RookOpen;
int drow = Row(f) - Row(pos.King(WHITE));
int dcol = Col(f) - Col(pos.King(WHITE));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore -= QUEEN_KING_TROPISM[dist];
}
//
// QUEENS
//
x = pos.Bits(QW);
while (x)
{
f = PopLSB(x);
posScore += PSQ_Q_END[f];
if (Row(f) == 1)
posScore += Rook7th;
int drow = Row(f) - Row(pos.King(BLACK));
int dcol = Col(f) - Col(pos.King(BLACK));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore += QUEEN_KING_TROPISM[dist];
}
x = pos.Bits(QB);
while (x)
{
f = PopLSB(x);
posScore -= PSQ_Q_END[f];
if (Row(f) == 1)
posScore -= Rook7th;
int drow = Row(f) - Row(pos.King(WHITE));
int dcol = Col(f) - Col(pos.King(WHITE));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore -= QUEEN_KING_TROPISM[dist];
}
//
// KINGS
//
{
f = pos.King(WHITE);
posScore += PSQ_K_MID[f] * pos.MatIndex(BLACK) / 32;
posScore += PSQ_K_END[f] * (32 - pos.MatIndex(BLACK)) / 32;
int penalty = PawnShieldWhite(pentry, f);
posScore += KING_PAWN_SHIELD[penalty] * pos.MatIndex(BLACK) / 32;
}
{
f = pos.King(BLACK);
posScore -= PSQ_K_MID[FLIP[f]] * pos.MatIndex(WHITE) / 32;
posScore -= PSQ_K_END[FLIP[f]] * (32 - pos.MatIndex(WHITE)) / 32;
int penalty = PawnShieldBlack(pentry, f);
posScore -= KING_PAWN_SHIELD[penalty] * pos.MatIndex(WHITE) / 32;
}
EVAL e = matScore + posScore;
if (pos.Count(PW) == 0 && pos.MatIndex(WHITE) < 5 && e > 0)
e = 0;
if (pos.Count(PB) == 0 && pos.MatIndex(BLACK) < 5 && e < 0)
e = 0;
return (pos.Side() == WHITE)? e : -e;
}
//***************************************************************************
else if ((totScore > FINALB)&&(totScore <= FINALA))
//*************************************************************************** 2
{
EVAL matScore = pos.Material(WHITE) - pos.Material(BLACK);
EVAL posScore = 0;
if (pos.Count(BW) == 2)
matScore += BISHOP_PAIR[PW+PB];
if (pos.Count(BB) == 2)
matScore -= BISHOP_PAIR[PW+PB];
EVAL lazy = (pos.Side() == WHITE)? matScore : -matScore;
if (lazy <= alpha - LazyEval)
return alpha;
if (lazy >= beta + LazyEval)
return beta;
U64 x, y, occ = pos.BitsAll();
FLD f;
//
// PAWNS
//
int index = pos.PawnHash() % g_pawnHashSize;
PawnEntry& pentry = g_pawnHash[index];
if (pentry.m_pawnHash != pos.PawnHash())
pentry.Readend(pos);
posScore += pentry.m_score;
x = pentry.m_passed[WHITE];
while (x)
{
f = PopLSB(x);
posScore += PawnPassed * (7 - Row(f)) / 5;
if (pos.MatIndex(BLACK) == 0)
{
FLD f1 = f;
if (pos.Side() == BLACK)
f1 += 8;
if ((BB_PAWN_SQUARE[f1][WHITE] & pos.Bits(KB)) == 0)
posScore += PawnPassedSquare * (7 - Row(f1)) / 5;
}
}
x = pentry.m_passed[BLACK];
while (x)
{
f = PopLSB(x);
posScore -= PawnPassed * Row(f) / 5;
if (pos.MatIndex(WHITE) == 0)
{
FLD f1 = f;
if (pos.Side() == WHITE)
f1 -= 8;
if ((BB_PAWN_SQUARE[f1][BLACK] & pos.Bits(KW)) == 0)
posScore -= PawnPassedSquare * Row(f1) / 5;
}
}
//
// KNIGHTS
//
static const int outpost[64] =
{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 1, 1, 0, 0,
0, 0, 1, 1, 1, 1, 0, 0,
0, 1, 1, 1, 1, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
x = pos.Bits(NW);
while (x)
{
// if (pos.Count(x) >= 1)
// posScore += ajuste_knight[pos.Count(PW)];
f = PopLSB(x);
int drow = Row(f) - Row(pos.King(BLACK));
int dcol = Col(f) - Col(pos.King(BLACK));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore += QUEEN_KING_TROPISM[dist];
posScore += PSQ_N[f];
if (outpost[f])
{
if (BB_PAWN_ATTACKS[f][BLACK] & pos.Bits(PW))
posScore += KnightOutpost;
}
}
x = pos.Bits(NB);
while (x)
{
// if (pos.Count(x) >= 1)
// posScore -= ajuste_knight[pos.Count(PB)];
f = PopLSB(x);
int drow = Row(f) - Row(pos.King(WHITE));
int dcol = Col(f) - Col(pos.King(WHITE));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore -= QUEEN_KING_TROPISM[dist];
posScore -= PSQ_N[FLIP[f]];
if (outpost[FLIP[f]])
{
if (BB_PAWN_ATTACKS[f][WHITE] & pos.Bits(PB))
posScore -= KnightOutpost;
}
}
//
// BISHOPS
//
x = pos.Bits(BW);
while (x)
{
f = PopLSB(x);
int drow = Row(f) - Row(pos.King(BLACK));
int dcol = Col(f) - Col(pos.King(BLACK));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore += QUEEN_KING_TROPISM[dist];
posScore += PSQ_B[f];
y = BishopAttacks(f, occ);
posScore += BISHOP_MOBILITY[CountBits(y)];
}
x = pos.Bits(BB);
while (x)
{
f = PopLSB(x);
int drow = Row(f) - Row(pos.King(WHITE));
int dcol = Col(f) - Col(pos.King(WHITE));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore -= QUEEN_KING_TROPISM[dist];
posScore -= PSQ_B[FLIP[f]];
y = BishopAttacks(f, occ);
posScore -= BISHOP_MOBILITY[CountBits(y)];
}
//
// ROOKS
//
x = pos.Bits(RW);
while (x)
{
// if (pos.Count(x) >= 1)
// posScore += ajuste_rook[pos.Count(PW)];
f = PopLSB(x);
y = RookAttacks(f, occ);
posScore += ROOK_MOBILITY[CountBits(y)];
if (Row(f) == 1)
posScore += Rook7th;
int file = Col(f) + 1;
if (pentry.m_ranks[file][WHITE] == 0)
posScore += RookOpen;
if (pentry.m_ranks[file][WHITE && BLACK] == 0)
posScore += RookOpen;
int drow = Row(f) - Row(pos.King(BLACK));
int dcol = Col(f) - Col(pos.King(BLACK));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore += QUEEN_KING_TROPISM[dist];
}
x = pos.Bits(RB);
while (x)
{
// if (pos.Count(x) >= 1)
// posScore -= ajuste_rook[pos.Count(PB)];
f = PopLSB(x);
y = RookAttacks(f, occ);
posScore -= ROOK_MOBILITY[CountBits(y)];
if (Row(f) == 6)
posScore -= Rook7th;
int file = Col(f) + 1;
if (pentry.m_ranks[file][BLACK] == 0)
posScore -= RookOpen;
if (pentry.m_ranks[file][WHITE && BLACK] == 0)
posScore -= RookOpen;
int drow = Row(f) - Row(pos.King(WHITE));
int dcol = Col(f) - Col(pos.King(WHITE));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore -= QUEEN_KING_TROPISM[dist];
}
//
// QUEENS
//
x = pos.Bits(QW);
while (x)
{
f = PopLSB(x);
posScore += PSQ_Q_END[f];
int drow = Row(f) - Row(pos.King(BLACK));
int dcol = Col(f) - Col(pos.King(BLACK));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore += QUEEN_KING_TROPISM[dist*2];
}
x = pos.Bits(QB);
while (x)
{
f = PopLSB(x);
posScore -= PSQ_Q_END[f];
int drow = Row(f) - Row(pos.King(WHITE));
int dcol = Col(f) - Col(pos.King(WHITE));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore -= QUEEN_KING_TROPISM[dist*2];
}
//
// KINGS
//
{
f = pos.King(WHITE);
posScore += PSQ_K_MID[f] * pos.MatIndex(BLACK) / 32;
posScore += PSQ_K_END[f] * (32 - pos.MatIndex(BLACK)) / 32;
}
{
f = pos.King(BLACK);
posScore -= PSQ_K_MID[FLIP[f]] * pos.MatIndex(WHITE) / 32;
posScore -= PSQ_K_END[FLIP[f]] * (32 - pos.MatIndex(WHITE)) / 32;
}
EVAL e = matScore + posScore;
if (pos.Count(PW) == 0 && pos.MatIndex(WHITE) < 5 && e > 0)
e = 0;
if (pos.Count(PB) == 0 && pos.MatIndex(BLACK) < 5 && e < 0)
e = 0;
return (pos.Side() == WHITE)? e : -e;
}
//***************************************************************************
else if (totScore <= FINALB)
//*************************************************************************** 2
{
EVAL matScore = pos.Material(WHITE) - pos.Material(BLACK);
EVAL posScore = 0;
EVAL lazy = (pos.Side() == WHITE)? matScore : -matScore;
if (lazy <= alpha - LazyEval)
return alpha;
if (lazy >= beta + LazyEval)
return beta;
U64 x, y, occ = pos.BitsAll();
FLD f;
//
// PAWNS
//
int index = pos.PawnHash() % g_pawnHashSize;
PawnEntry& pentry = g_pawnHash[index];
if (pentry.m_pawnHash != pos.PawnHash())
pentry.Readend(pos);
posScore += pentry.m_score;
x = pentry.m_passed[WHITE];
while (x)
{
f = PopLSB(x);
posScore += PawnPassed * (7 - Row(f)) / 4;
if (pos.MatIndex(BLACK) == 0)
{
FLD f1 = f;
if (pos.Side() == BLACK)
f1 += 8;
if ((BB_PAWN_SQUARE[f1][WHITE] & pos.Bits(KB)) == 0)
posScore += PawnPassedSquare * (7 - Row(f1)) / 4;
}
}
x = pentry.m_passed[BLACK];
while (x)
{
f = PopLSB(x);
posScore -= PawnPassed * Row(f) / 4;
if (pos.MatIndex(WHITE) == 0)
{
FLD f1 = f;
if (pos.Side() == WHITE)
f1 -= 8;
if ((BB_PAWN_SQUARE[f1][BLACK] & pos.Bits(KW)) == 0)
posScore -= PawnPassedSquare * Row(f1) / 4;
}
}
//
// KNIGHTS
//
static const int outpost[64] =
{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 1, 1, 0, 0,
0, 0, 1, 1, 1, 1, 0, 0,
0, 1, 1, 1, 1, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
x = pos.Bits(NW);
while (x)
{
// if (pos.Count(x) >= 1)
// posScore += ajuste_knight[pos.Count(PW)];
f = PopLSB(x);
posScore += PSQ_N[f];
if (outpost[f])
{
if (BB_PAWN_ATTACKS[f][BLACK] & pos.Bits(PW))
posScore += KnightOutpost;
}
}
x = pos.Bits(NB);
while (x)
{
// if (pos.Count(x) >= 1)
// posScore -= ajuste_knight[pos.Count(PB)];
f = PopLSB(x);
posScore -= PSQ_N[FLIP[f]];
if (outpost[FLIP[f]])
{
if (BB_PAWN_ATTACKS[f][WHITE] & pos.Bits(PB))
posScore -= KnightOutpost;
}
}
//
// BISHOPS
//
x = pos.Bits(BW);
while (x)
{
f = PopLSB(x);
// posScore += PSQ_B[f];
y = BishopAttacks(f, occ);
posScore += BISHOP_MOBILITY[CountBits(y)];
}
x = pos.Bits(BB);
while (x)
{
f = PopLSB(x);
// posScore -= PSQ_B[FLIP[f]];
y = BishopAttacks(f, occ);
posScore -= BISHOP_MOBILITY[CountBits(y)];
}
//
// ROOKS
//
x = pos.Bits(RW);
while (x)
{
// if (pos.Count(x) >= 1)
// posScore += ajuste_rook[pos.Count(PW)];
f = PopLSB(x);
y = RookAttacks(f, occ);
posScore += ROOK_MOBILITY[CountBits(y)];
int drow = Row(f) - Row(pos.King(BLACK));
int dcol = Col(f) - Col(pos.King(BLACK));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore += QUEEN_KING_TROPISM[dist];
}
x = pos.Bits(RB);
while (x)
{
f = PopLSB(x);
y = RookAttacks(f, occ);
posScore -= ROOK_MOBILITY[CountBits(y)];
int drow = Row(f) - Row(pos.King(WHITE));
int dcol = Col(f) - Col(pos.King(WHITE));
if (drow < 0) drow = -drow;
if (dcol < 0) dcol = -dcol;
int dist = drow + dcol;
posScore -= QUEEN_KING_TROPISM[dist];
}
//
// QUEENS
//
//
// KINGS
//
{
f = pos.King(WHITE);
posScore += PSQ_K_END[f] * (32 - pos.MatIndex(BLACK)) / 32;
}
{
f = pos.King(BLACK);
posScore -= PSQ_K_END[FLIP[f]] * (32 - pos.MatIndex(WHITE)) / 32;
}
// FIN KINGS
EVAL e = matScore + posScore;
if (pos.Count(PW) == 0 && pos.MatIndex(WHITE) < 5 && e > 0)
e = 0;
if (pos.Count(PB) == 0 && pos.MatIndex(BLACK) < 5 && e < 0)
e = 0;
return (pos.Side() == WHITE)? e : -e;
}
///////////////////////////////////////////////////////////////////////////////
} //FIN de evaluate
////////////////////////////////////////////////////////////////////////////////
const int center[64] =
{
-3, -2, -1, 0, 0, -1, -2, -3,
-2, -1, 0, 1, 1, 0, -1, -2,
-1, 0, 1, 2, 2, 1, 0, -1,
0, 1, 2, 3, 3, 2, 1, 0,
0, 1, 2, 3, 3, 2, 1, 0,
-1, 0, 1, 2, 2, 1, 0, -1,
-2, -1, 0, 1, 1, 0, -1, -2,
-3, -2, -1, 0, 0, -1, -2, -3
};
const int inicio_p[64] =
{
0, 0, 0, 0, 0, 0, 0, 0,
4, 5, 6, 7, 7, 6, 5, 4,
3, 3, 5, 6, 6, 5, 3, 3,
2, 2, 4, 5, 5, 4, 2, 2,
1, 1, 3, 4, 4, 3, 1, 1,
1, 1, 2, 2, 2, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
const int center_p[64] =
{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 2, 2, 0, 0, 0,
0, 0, 1, 2, 2, 1, 0, 0,
0, 0, 1, 2, 2, 1, 0, 0,
0, 0, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
const int end_p[64] =
{
0, 0, 0, 0, 0, 0, 0, 0,
4, 4, 5, 5, 5, 5, 4, 4,
3, 3, 4, 4, 4, 4, 3, 3,
2, 2, 3, 3, 3, 3, 2, 2,
1, 1, 2, 2, 2, 2, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
const int inicio_knigth[64] =
{
0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 0,
0, 1, 2, 3, 3, 2, 2, 0,
0, 2, 2, 4, 4, 2, 2, 0,
0, 1, 1, 4, 4, 1, 1, 0,
0, 0, 2, 2, 2, 3, 0, 0,
0, 0, 0, 1, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
const int inicio_bishop[64] =
{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 0,
0, 3, 2, 3, 3, 2, 3, 0,
0, 1, 2, 3, 3, 2, 1, 0,
0, 0, 1, 1, 1, 1, 0, 0,
0, 3, 0, 1, 1, 0, 3, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
const int center_k[64] =
{
4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4,
2, 2, 2, 2, 2, 2, 2, 2,
1, 0, 0, 1, 0, 1, 0, 1
};
const int center_r[64] =
{
-10, -5, 0, 5, 5, 0, -5, -10,
-10, -5, 0, 5, 5, 0, -5, -10,
-10, -5, 0, 5, 5, 0, -5, -10,
-10, -5, 0, 5, 5, 0, -5, -10,
-10, -5, 0, 5, 5, 0, -5, -10,
-10, -5, 0, 5, 5, 0, -5, -10,
-10, -5, 0, 5, 5, 0, -5, -10,
-10, -5, 0, 5, 5, 0, -5, -10
};
void InitEval()
{
PARAM (VAL_Pp)
PARAM (VAL_Np)
PARAM (VAL_Bp)
PARAM (VAL_Rp)
PARAM (VAL_Qp)
VAL_Q = ((VAL_Q+VAL_Qp)-VAL_Q);
VAL_N = ((VAL_N+VAL_Np)-VAL_N);
for (int f = 0; f < 64; ++f)
{
PSQ_P[f] = PawnCenter * center_p[f] / 2;
PSQ_P_I[f] = PawnCenter * inicio_p[f] / 2;
PSQ_N[f] = KnightCenter * center[f] / 3;
PSQ_N_I[f] = KnightCenter * inicio_knigth[f] / 3;
PSQ_B[f] = BishopCenter * center[f] / 3;
PSQ_B_I[f] = BishopCenter * inicio_bishop[f] / 3;
PSQ_R[f] = center_r[f];
PSQ_K_MID[f] = KingCenterMid * center_k[f] / 4;
PSQ_K_END[f] = KingCenterEnd * center[f] / 3;
PSQ_P_END[f] = PawnCenter * end_p[f];
PSQ_Q_END[f] = QueenCenterEnd * center[f] / 4;
PSQ_Q_MED[f] = QueenCenterEnd * center[f] / 6;
}
for (int m = 0; m < 14; ++m)
{
double x = (m - 6.5) / 6.5;
double y = -0.5 * x * x + x + 0.5;
BISHOP_MOBILITY[m] = EVAL(BishopMobility * y);
}
for (int m = 0; m < 15; ++m)
{
double x = (m - 7.0) / 7.0;
double y = -0.5 * x * x + x + 0.5;
ROOK_MOBILITY[m] = EVAL(RookMobility * y);
}
for (int d = 0; d < 15; ++d)
{
QUEEN_KING_TROPISM[d] = QueenKingTropism * (14 - d) / 14;
}
const double f[10] =
{ 0, -0.056, -0.111, -0.222, -0.389, -0.611, -0.778, -0.889, -0.944, -1.000 };
for (int p = 0; p < 10; ++p)
{
KING_PAWN_SHIELD[p] = EVAL(KingPawnShield * f[p]);
}
}
////////////////////////////////////////////////////////////////////////////////
void PawnEntry::Read(const Position& pos)
{
U64 x;
FLD f;
int file, rank;
m_pawnHash = pos.PawnHash();
m_score = 0;
m_passed[WHITE] = m_passed[BLACK] = 0;
for (file = 0; file < 10; ++file)
{
m_ranks[file][WHITE] = 0;
m_ranks[file][BLACK] = 7;
}
x = pos.Bits(PW);
while (x)
{
f = PopLSB(x);
file = Col(f) + 1;
rank = Row(f);
if (rank > m_ranks[file][WHITE])
m_ranks[file][WHITE] = rank;
}
x = pos.Bits(PB);
while (x)
{
f = PopLSB(x);
file = Col(f) + 1;
rank = Row(f);
if (rank < m_ranks[file][BLACK])
m_ranks[file][BLACK] = rank;
}
x = pos.Bits(PW);
while (x)
{
f = PopLSB(x);
file = Col(f) + 1;
rank = Row(f);
m_score += PSQ_P_I[f];
if (m_ranks[file][BLACK] == 7)
{
if (m_ranks[file - 1][BLACK] >= rank && m_ranks[file + 1][BLACK] >= rank)
m_passed[WHITE] |= BB_SINGLE[f];
}
if (rank != m_ranks[file][WHITE])
m_score += PawnDoubled;
if (m_ranks[file - 1][WHITE] == 0 && m_ranks[file + 1][WHITE] == 0)
m_score += PawnIsolated;
else if (m_ranks[file - 1][WHITE] < rank && m_ranks[file + 1][WHITE] < rank)
m_score += PawnBackwards;
}
x = pos.Bits(PB);
while (x)
{
f = PopLSB(x);
file = Col(f) + 1;
rank = Row(f);
m_score -= PSQ_P_I[FLIP[f]];
if (m_ranks[file][WHITE] == 0)
{
if (m_ranks[file - 1][WHITE] <= rank && m_ranks[file + 1][WHITE] <= rank)
m_passed[BLACK] |= BB_SINGLE[f];
}
if (rank != m_ranks[file][BLACK])
m_score -= PawnDoubled;
if (m_ranks[file - 1][BLACK] == 7 && m_ranks[file + 1][BLACK] == 7)
m_score -= PawnIsolated;
else if (m_ranks[file - 1][BLACK] > rank && m_ranks[file + 1][BLACK] > rank)
m_score -= PawnBackwards;
}
}
////////////////////////////////////////////////////////////////////////////////
void PawnEntry::Readend(const Position& pos)
{
U64 x;
FLD f;
int file, rank;
m_pawnHash = pos.PawnHash();
m_score = 0;
m_passed[WHITE] = m_passed[BLACK] = 0;
for (file = 0; file < 10; ++file)
{
m_ranks[file][WHITE] = 0;
m_ranks[file][BLACK] = 7;
}
x = pos.Bits(PW);
while (x)
{
f = PopLSB(x);
file = Col(f) + 1;
rank = Row(f);
if (rank > m_ranks[file][WHITE])
m_ranks[file][WHITE] = rank;
}
x = pos.Bits(PB);
while (x)
{
f = PopLSB(x);
file = Col(f) + 1;
rank = Row(f);
if (rank < m_ranks[file][BLACK])
m_ranks[file][BLACK] = rank;
}
x = pos.Bits(PW);
while (x)
{
f = PopLSB(x);
file = Col(f) + 1;
rank = Row(f);
m_score += PSQ_P_END[f];
if (m_ranks[file][BLACK] == 7)
{
if (m_ranks[file - 1][BLACK] >= rank && m_ranks[file + 1][BLACK] >= rank)
m_passed[WHITE] |= BB_SINGLE[f];
}
if (rank != m_ranks[file][WHITE])
m_score += PawnDoubled;
if (m_ranks[file - 1][WHITE] == 0 && m_ranks[file + 1][WHITE] == 0)
m_score += PawnIsolated;
// if ((m_ranks[file - 1][WHITE] != 0) | (m_ranks[file + 1][WHITE] != 0))
// m_score += PawnDuo;
// if ((m_ranks[file - 1][WHITE] != 0) && (m_ranks[file + 1][WHITE] != 0))
// m_score += PawnTrio;
else if (m_ranks[file - 1][WHITE] < rank && m_ranks[file + 1][WHITE] < rank)
m_score += PawnBackwards;
}
x = pos.Bits(PB);
while (x)
{
f = PopLSB(x);
file = Col(f) + 1;
rank = Row(f);
m_score -= PSQ_P_END[FLIP[f]];
if (m_ranks[file][WHITE] == 0)
{
if (m_ranks[file - 1][WHITE] <= rank && m_ranks[file + 1][WHITE] <= rank)
m_passed[BLACK] |= BB_SINGLE[f];
}
if (rank != m_ranks[file][BLACK])
m_score -= PawnDoubled;
if (m_ranks[file - 1][BLACK] == 7 && m_ranks[file + 1][BLACK] == 7)
m_score -= PawnIsolated;
// if ((m_ranks[file - 1][BLACK] != 7) | (m_ranks[file + 1][BLACK] != 7))
// m_score -= PawnDuo;
// if ((m_ranks[file - 1][BLACK] != 7) && (m_ranks[file + 1][BLACK] != 7))
// m_score -= PawnTrio;
else if (m_ranks[file - 1][BLACK] > rank && m_ranks[file + 1][BLACK] > rank)
m_score -= PawnBackwards;
}
}
////////////////////////////////////////////////////////////////////////////////
EVAL VALUE[14] =
{
0, 0, VAL_P, VAL_P, VAL_N = ((VAL_N+VAL_Np)-VAL_N),VAL_N =
((VAL_N+VAL_Np)-VAL_N), VAL_B, VAL_B, VAL_R, VAL_R, VAL_Q, VAL_Q, 0, 0
};
For the rest I would put here the full code
You could see up the dates when it was made,
you could look up where it was published a year ago,
but worth it more power.
Learn what a HEX edit before speaking.
Greetings.