Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


ashish123

Member Since 22 Dec 2010
Offline Last Active Sep 18 2013 01:16 AM

Topics I've Started

UCI based chess Engine : Some questions.

31 May 2013 - 09:35 AM

I have coded a chess engine in C# which has no sophisticated features.

I have just done with mate detection and some crude static evaluation.

I am trying to make it UCI compatible, but then I am facing a question as to why the protocol returns the list of moves rather than the fen of the new position.

 

I mean the list of moves will take more time to execute and the space required is also more than equivalent FEN string.

Can any one help me with this?

 

 

 


Chess Programing: Request for Code Review.

22 December 2012 - 03:05 AM

Hi all,

 

I have written a chess program using bit boards in C# and almost done with move generation(Castling still incomplete).

 

I have also written a PERFT function which gives me  the following statistics for the starting position on the chess board:

  1. 20 Nodes ---> 10 ms  --->  2 kN/s
  2. 400 Nodes --->11 ms  --->  36 kN/s
  3. 8902 Nodes ---> 18 ms  ---> 494.56 kN/s
  4. 197281 Nodes  --->477 ms. ---> 413.59 kN/s
  5. 4865609 Nodes ---> 4372 ms   --->  1112.9 kN/s
  6. 119060324 Nodes ---> 307920  ---> 386.56 kN/s

 

 

This is my very first bit-boards chess engine so don't know much about the speed, however when compared to my previous 0x88 chess stats this is definitely a winner.

 

When I compared these stats with Sharper (amazing chess program), I realized that it is much more faster than this, It computed Perft(6) in 132 ms without hash tables.

 

So I would request some one with experience in chess programming or in c# to review my code and let me know where I am going wrong or what can be done to optimize it.

 

I shall post my code if any one is ready to review the same.

Please note, that there are no visible bugs.

 

Also if any one is aware, kindly post some kind of profiling tool which will help me to understand the coding efficiency better.

 

I am using Visual Studio 2010 as my IDE and C# as the language.

 

Thanks.

 

 


Move Generation using Bit boards (Connect-4)

28 June 2012 - 12:35 PM

Hi all,
I am facing some speed(performance) issues while generating moves for connect 4.

Perviously I wrote simple nested for-loops to generate the moves now I tried to convert it into bit boards so
I found all the empty squares and anded it with column bits. (eg column1=(1L<<1|1L<<10...)
This gave me the empty bits which are in a particular column.
Now I found the MSB by right-shifting this till the number was 0( trick to find MSB when its power of 2).
it gave me correct answer, but then surprisingly this was slower as compared to nested for (nested for loops took 238 ms where as bitboards took 1349 ms).

So then I tried another method, the folding trick as mentioned here.
[source lang="csharp"] x |= (x >> 1); x |= (x >> 2); x |= (x >> 4); x |= (x >> 8); x |= (x >> 16); x |= (x >> 32); for (int n = 53; n >=0; n--) if (((1L << n) & (x & ~(x >> 1))) != 0) return n;[/source]
This too gave me slow results.
What am I doing wrong as I am sure bitboards will be certainly faster then nested loops.
How can I achieve this without nested loops, something like debrujin sequence for MSB (64 bit number).

-Thank you.

Help in optimizing the negamax+alphabeta

24 December 2011 - 02:34 PM

Hi I have been working on a code of connect-4 for few months now. Its a strong player but however its not perfect. I am now focussing in slightly tweaking my search algorithm so that the search seed is increased.
I have pretty decent evaluation. But for some positions, I just dont understand how to write a favourable routine and that is where I want my machine power to work.

My search code contains negamax implementation with alpha-beta pruning. It also has Iterative deepening, killers and hashtables. I tried to add NegaScout but it doesnt give my search any benifit.
My evaluation is coded in bitboards and currently I am able to search uptil 17 plys from start with evaluations and it reaches uptil 25plys with only winning conditions.

All evaluation is coded in form of bitboards.
I am not favouring opening book as of now as I want to learn to code and optimize the search algorithm.

The snippet of my entire code can be found here

Kindly help.
Thank you.

Help in understanding getMove function.

26 November 2011 - 04:55 AM

There were many posts on this forum by which helped me a lot.
I generally write my getMove method as

public getMove(boolean turn)
{
   int max=-INFINITY;
   int eval=0;
  genMoves();

  (for all moves)
 	{
        		eval=-negamax(...) //Negamax.
            	if(eval>max)
              	{
                      max=eval;
               		bestmove=current;
           		}
 	}

return bestmove;

public int negamax(..)
{
normal negamax....
return max;
}
}



This is another way which I found on google.

public getMove(boolean turn)
{
   int eval=negmax(1)
return bestmove.
}

public int negamax(int depth)
{
int max=-INFINITY;
if(   test for win,boardful,reachd maxdepth...)
return...
else
{
	genMoves();
   (for all moves)
make
eval=-negmax(depth+1)
unmake
if(eval>max)
{
if(depth==1)
{
   bestMove=current
}
max=eval
}
}
return max;
}
I don't remember from where I got this pseudo-code, but it beats the normal way I wrote, and I am unable to reason why it happens so.
I am also not getting the logic of
if(depth==1)
{
bestMove=current
}
What if the bestMove wasnt found on 1st ply, but this works and works better than normal getMove, I am missing something kindly help.
Thank you.

PARTNERS