Mobility
Moderators: hgm, Rebel, chrisw
-
- Posts: 226
- Joined: Sun Mar 08, 2009 3:08 pm
- Location: Canada
Re: Mobility
I also agree that linear mobility is not the best, I was using a sqrt() function to try to combat some linearity, but its removed for now..
outAtime
-
- Posts: 226
- Joined: Sun Mar 08, 2009 3:08 pm
- Location: Canada
Re: Mobility
I do not have SEE, if that is what you mean.Uri Blass wrote:I do not know but if the score that you have is based on search and not static evaluation then it is possible that the bishop get 13 squares and not 7 squares because search can push the bishop to the centre of the board when it has 13 squares.outAtime wrote:I can keep "p" but I'll need to adjust the other values - 1/2 I guess. ? I just don't know why the score seems to double with "p".
outAtime
-
- Posts: 10309
- Joined: Thu Mar 09, 2006 12:37 am
- Location: Tel-Aviv Israel
Re: Mobility
I did not mean SEE but simply search.outAtime wrote:I do not have SEE, if that is what you mean.Uri Blass wrote:I do not know but if the score that you have is based on search and not static evaluation then it is possible that the bishop get 13 squares and not 7 squares because search can push the bishop to the centre of the board when it has 13 squares.outAtime wrote:I can keep "p" but I'll need to adjust the other values - 1/2 I guess. ? I just don't know why the score seems to double with "p".
I do not know if the scores that you get for KB vs K position are score of the static evaluation or scores of the position after searching like you do in a real game.
-
- Posts: 2684
- Joined: Sat Jun 14, 2008 9:17 pm
Re: Mobility
This is the correct version. I forgot to define 'p'.outAtime wrote:Code: Select all
int bishop_mobility(int squareb) { int p, d, bfs, s = 0; for (d = 0; d < 4; d++) { bfs = b_offsets[d]; for (p = squareb + bfs; board[p] == npiece; p += bfs) s++; } return s; }
I suggest to print the score of just mobility. As a general rule while debugging you may want to go as near as possible in monitoring _just_ the function you are verifying, so I strongly suggest to add some printf that prints the position _and_ the bishop mobility for that position, i.e. the return value of bishop_mobility() no more no less. In this case it is easier to find the bug.
Another general rule that I'd suggest is to focus _only_ on bug fixing before to pass to something else (I have read about non-linear mobility here). If you mess too much stuff toghter at the end you got nothing. The standard approach is first fix the bug, then try to improve. The reverse does not work.
Last edited by mcostalba on Sat Oct 16, 2010 10:44 pm, edited 1 time in total.
-
- Posts: 226
- Joined: Sun Mar 08, 2009 3:08 pm
- Location: Canada
Re: Mobility
interesting point. I should apologize for this ridiculous oversight. ridiculous.
In fact the version _without_ "p" is undervalued in this case. "p" is correct.
Thanks for pointing out my error. duh.
In fact the version _without_ "p" is undervalued in this case. "p" is correct.
Thanks for pointing out my error. duh.
outAtime
-
- Posts: 2684
- Joined: Sat Jun 14, 2008 9:17 pm
Re: Mobility
Actually error was mineoutAtime wrote:interesting point. I should apologize for this ridiculous oversight. ridiculous.
In fact the version _without_ "p" is undervalued in this case. "p" is correct.
Thanks for pointing out my error. duh.
-
- Posts: 2684
- Joined: Sat Jun 14, 2008 9:17 pm
Re: Mobility
And if you like compact code here is another variation, although I guess is slower....but test is needed...as usual
Code: Select all
int b_offsets[] = { 11, -11, 13, -13, 0 };
int bishop_mobility(int squareb)
{
int p, *d = b_offsets, s = 0;
for ( ; *d; d++)
for (p = squareb + *d; board[p] == npiece; p += *d)
s++;
return s;
}
-
- Posts: 226
- Joined: Sun Mar 08, 2009 3:08 pm
- Location: Canada
Re: Mobility
Im gonna test this :
where...
maybe it's still too high, not sure how many games to do or if 1 0 is ok, or if I should do 3 0.... 3 0 for now...
Code: Select all
/* calculate mobitity scores -- Thanks to Harald Lüßen(knight_mobility) and Marco Costalba (Bishop Mobility)
also Uri Blass and Ferdinand Mosca who helped to clarify and suggest improvements */
int knight_mobility(int squaren)
{
int n;
int g = 0;
for (n = 0; n < 8; n++)
//n_sq = squaren + n_offsets[n];
if (board[squaren + n_offsets[n]] == npiece) // or == opponent
g++;
return g;
}
int bishop_mobility(int squareb)
{
int p, d, bfs, s = 0;
for (d = 0; d < 4; d++)
{
bfs = b_offsets[d];
for (p = squareb + bfs; board[p] == npiece; p += bfs)
s++;
}
return s;
}
int rook_mobility(int squarer)
{
int r, f, rfs, c = 0;
for (f = 0; f < 4; f++)
{
rfs = r_offsets[f];
for (r = squarer + rfs; board[r] == npiece; r += rfs)
c++;
}
return c;
}
int queen_mobility(int squareq)
{
int q, l, qfs, m = 0;
for (l = 0; l < 8; l++)
{
qfs = q_offsets[l];
for (q = squareq + qfs; board[q] == npiece; q += qfs)
m++;
}
return m;
}
Code: Select all
#define bmo 7
#define nmo 5
#define rmo 3
#define bme 4
#define nme 2
#define rme 4
#define qmo 1
#define qme 1
outAtime
-
- Posts: 2684
- Joined: Sat Jun 14, 2008 9:17 pm
Re: Mobility
I prefer your version, is more reaadable and probably faster but....anyhow....outAtime wrote:Im gonna test this :
Code: Select all
int b_ofs[] = { 11, -11, 13, -13, 0 };
int r_ofs[] = { 12, -12, 1, -1, 0 };
int piece_mobility(int sq, int offsets[])
{
int p, *d = offsets, s = 0;
for ( ; *d; d++)
for (p = sq + *d; board[p] == npiece; p += *d)
s++;
return s;
}
int bishop_mobility(int sq){ return piece_mobility(sq, b_ofs); }
int rook_mobility(int sq) { return piece_mobility(sq, r_ofs); }
int queen_mobility(int sq) { return piece_mobility(sq, b_ofs)
+ piece_mobility(sq, r_ofs); }
-
- Posts: 226
- Joined: Sun Mar 08, 2009 3:08 pm
- Location: Canada
Re: Mobility
Why the , 0 ?
it looks really sophisticated, Im wondering if nt b_ofs[] = { 11, -11, 13, -13, 0 };
is an improvement over the offset without 0.
it looks really sophisticated, Im wondering if nt b_ofs[] = { 11, -11, 13, -13, 0 };
is an improvement over the offset without 0.
outAtime