Mobility

Discussion of chess software programming and technical issues.

Moderator: Ras

outAtime
Posts: 226
Joined: Sun Mar 08, 2009 3:08 pm
Location: Canada

Re: Mobility

Post by outAtime »

Nice.

Code: Select all

int bishop_mobility(int squareb)
{
  int d, ofs, s = 0;
 
  for (d = 0; d < 4; d++)
  {
       ofs = b_offsets[d];
       for (d = squareb + ofs; board[d] == npiece; d += ofs)
           s++;
  }
  return s;
} 
returns correct score in the 1 bishop w/kings position. Im gonna try this with rooks and queens too. I think it will be less expensive because the other code seemed to be returning double scores. :D
outAtime
Uri Blass
Posts: 10891
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Mobility

Post by Uri Blass »

outAtime wrote:Nice.

Code: Select all

int bishop_mobility(int squareb)
{
  int d, ofs, s = 0;
 
  for (d = 0; d < 4; d++)
  {
       ofs = b_offsets[d];
       for (d = squareb + ofs; board[d] == npiece; d += ofs)
           s++;
  }
  return s;
} 
returns correct score in the 1 bishop w/kings position. Im gonna try this with rooks and queens too. I think it will be less expensive because the other code seemed to be returning double scores. :D
This code is not correct
p was correct but marco forgot to define it.

It is not logical to have a loop with d twice when one loop is inside the other loop.
outAtime
Posts: 226
Joined: Sun Mar 08, 2009 3:08 pm
Location: Canada

Re: Mobility

Post by outAtime »

ok, will add p etc.. Thankyou
outAtime
Uri Blass
Posts: 10891
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Mobility

Post by Uri Blass »

outAtime wrote:
mcostalba wrote:
outAtime wrote:Can anybody see where this code might be counting the squares twice?
It seems correct to me. Are you sure you call function bishop_mobility() only once ?

BTW what about this ?

Code: Select all

int b_offsets[] = { 11, -11, 13, -13 }; 

int bishop_mobility(int squareb)
{
  int d, ofs, s = 0;
  
  for (d = 0; d < 4; d++)
  {
       ofs = b_offsets[d];
       for (p = squareb + ofs; board[p] == npiece; p += ofs)
           s++;
  }
  return s;
}

Shouldn't "p" be "d" ? or is p new.. I dont see int p.
No
You should replace
int d, ofs, s = 0; by
int p,d, ofs, s = 0;

You have 4 variables and marco forgot to define p

Meaning of the variables:

1)d is the direction in the board 0-3
2)ofs is the difference between squares in the relevant direction
3)p is the square on the board that the bishop can move into it.
4)s is the number of squares that the bishop controls.
outAtime
Posts: 226
Joined: Sun Mar 08, 2009 3:08 pm
Location: Canada

Re: Mobility

Post by outAtime »

Image

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;
} 

score = 4.72 score -= bishop_mobility(i) * bme; bme = 10

Code: Select all

int bishop_mobility(int squareb)
{
  int d, bfs, s = 0;
 
  for (d = 0; d < 4; d++)
  {
       bfs = b_offsets[d];
       for (d = squareb + bfs; board[d] == npiece; d += bfs)
           s++;
  }
  return s;
} 
score = 3.97 score -= bishop_mobility(i) * bme; bme = 10

again, I feel I am running into a double score when using "p". Im not sure what it is. 3.97 seems correct (3.25 bishop value + 7 squares mobility * bme +/- kings position)
outAtime
outAtime
Posts: 226
Joined: Sun Mar 08, 2009 3:08 pm
Location: Canada

Re: Mobility

Post by outAtime »

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
outAtime
Posts: 226
Joined: Sun Mar 08, 2009 3:08 pm
Location: Canada

Re: Mobility

Post by outAtime »

I dont see the point here. Isn't the version with "p" just returning too high a score??
outAtime
Uri Blass
Posts: 10891
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Mobility

Post by Uri Blass »

I think that a score of 10 centi-pawns for one square is too high for mobility and I also think that it is not the best to have a linear mobility but it is still better than no mobility.

I suggest that you use bme=5 and not bme=10 and I believe that it should be productive relative to no mobility evaluation.
Uri Blass
Posts: 10891
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Mobility

Post by Uri Blass »

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 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
Posts: 226
Joined: Sun Mar 08, 2009 3:08 pm
Location: Canada

Re: Mobility

Post by outAtime »

lol, thanks :)
I know 10 is too high, I was just using it for the test position.
lol
outAtime