Insanely buggy move generator, please help

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
vittyvirus
Posts: 646
Joined: Wed Jun 18, 2014 2:30 pm
Full name: Fahad Syed

Insanely buggy move generator, please help

Post by vittyvirus »

This is my move generator code for black. Its insanely buggy, please help me find those bugs. I've fixed parts of white move generator code, but Black's movegen code is still buggy. So just not to confuse you guys, I've only posted White movegen code.

Code: Select all

#include "movegen.h"
#include "bitboard.h"
#include "func.h"
#include "move.h"
#include "names.h"
#include "const.h"

#define WHITE_OO_CASTLE 6
#define WHITE_OOO_CASTLE 112

inline BitMap whiteSinglePush(const UINT &sq, const BitMap &empty) {
	return (&#40;1 << sq&#41; << 8&#41; & empty;
&#125;

inline BitMap whiteDoublePush&#40;const UINT &sq, const BitMap &empty&#41; &#123;
	BitMap singlePush = whiteSinglePush&#40;sq, empty&#41;;
	return &#40;singlePush << 8&#41; & empty & 0x00000000FF000000; // 0x00000000FF000000 = rank 4.
&#125;

inline BitMap blackSinglePush&#40;const BitMap &bpawns, const BitMap &empty&#41; &#123;
	return &#40;bpawns >> 8&#41; & empty;
&#125;

inline BitMap blackDoublePush&#40;const BitMap &bpawns, const BitMap &empty&#41; &#123;
	singlePush = blackSinglePush&#40;bpawns, empty&#41;;
	return &#40;singlePush << 8&#41; & empty & 0x000000FF00000000; // 0x000000FF00000000 = rank 5.
&#125;

inline BitMap genBishopMoves&#40;const UINT &square, const U64 &board, const U64 &target&#41; &#123;
	BitMap bishopMoves = 0;
	bishopMoves = arrDiagA8H1Moves&#91;&#40;square&#41;&#93;&#91;(&#40;board & arrDiagA8H1Mask&#91;&#40;square&#41;&#93;) * arrDiagA8H1Magics&#91;&#40;square&#41;&#93;) >> 57&#93;;
	bishopMoves |= arrDiagA1H8Moves&#91;&#40;square&#41;&#93;&#91;(&#40;board & arrDiagA1H8Mask&#91;&#40;square&#41;&#93;) * arrDiagA1H8Magics&#91;&#40;square&#41;&#93;) >> 57&#93;;
	bishopMoves &= target;
	return bishopMoves;
&#125;

inline BitMap genRookMoves&#40;const UINT &square, const U64 &board, const U64 &target&#41; &#123;
	BitMap rookMoves = 0;
	rookMoves |= &#40;arrRankMoves&#91;&#40;square&#41;&#93;&#91;(&#40;board & arrRankMask&#91;&#40;square&#41;&#93;) >> arrRankShifts&#91;&#40;square&#41;&#93;)&#93;);
	rookMoves |= &#40;arrFileMoves&#91;&#40;square&#41;&#93;&#91;(&#40;board & arrFileMask&#91;&#40;square&#41;&#93;) * arrFileMagics&#91;&#40;square&#41;&#93;) >> 57&#93;);
	rookMoves &= target;
	return rookMoves;
&#125;

inline BitMap genQueenMoves&#40;const UINT &square, const U64 &board, const U64 &target&#41; &#123;
	return &#40;genRookMoves&#40;square, board, target&#41; | genBishopMoves&#40;square, board, target&#41;);
&#125;


void Bitboard&#58;&#58;GenWhiteMoves&#40;) &#123;
	register int index, from, to;
	register CMove tempMove; // Stores the temporary generated move, then copied into Moves
	register BitMap targets, piece;

	/********************************************
	*											*
	*			White Pawn Moves				*
	*											*
	*********************************************/

	BitMap empty = (~Bitboard&#58;&#58;occupiedSquares&#41;;

	tempMove.clearMove&#40;);
	targets = index = from = to = 0;

	tempMove.setPiece&#40;WHITEPAWN&#41;;
	piece = Bitboard&#58;&#58;whitePawns;

	while&#40;piece&#41; &#123;

		from = lsb&#40;piece&#41;;
		tempMove.setFrom&#40;from&#41;;

		std&#58;&#58;cout << "White Single Push, sq=" << from << " empty=" << empty << "returns " << whiteSinglePush&#40;from, empty&#41; << std&#58;&#58;endl;
		targets = whiteSinglePush&#40;from, empty&#41;;
		std&#58;&#58;cout << "Targets now&#58;" << targets << std&#58;&#58;endl;
		std&#58;&#58;cout << "White Doble Push, sq=" << from << " empty=" << empty << "returns " << whiteDoublePush&#40;from, empty&#41; << std&#58;&#58;endl;
		targets |= whiteDoublePush&#40;from, empty&#41;;
		std&#58;&#58;cout << "Targets now&#58;" << targets << std&#58;&#58;endl;
		targets |= (&#40;arrPawnAttacks&#91;0&#93;&#91;from&#93;) & &#40;Bitboard&#58;&#58;blackPieces&#41;);

		if&#40;Bitboard&#58;&#58;epSquare&#41; &#123;
			if&#40;&#40;from == &#40;Bitboard&#58;&#58;epSquare - 1&#41;) || &#40;from == &#40;Bitboard&#58;&#58;epSquare + 1&#41;)) &#123;
				tempMove.setTo&#40;Bitboard&#58;&#58;epSquare - 8&#41;;
				tempMove.setFlags&#40;WHITEPAWN&#41;;
				tempMove.setCapture&#40;WHITEPAWN&#41;;
				Moves&#91;index++&#93;.m_move = tempMove.m_move;
			&#125;
		&#125;

		while&#40;targets&#41; &#123;
			to = lsb&#40;targets&#41;;
			tempMove.setTo&#40;to&#41;;

			if&#40;to < 56&#41; &#123;
				Moves&#91;index++&#93;.m_move = tempMove.m_move;
			&#125; else &#123;									// I've lately started to use K&R Style fromatting
				tempMove.setFlags&#40;WHITEQUEEN&#41;;
				Moves&#91;index++&#93;.m_move = tempMove.m_move;
				tempMove.setFlags&#40;WHITEROOK&#41;;
				Moves&#91;index++&#93;.m_move = tempMove.m_move;
				tempMove.setFlags&#40;WHITEBISHOP&#41;;
				Moves&#91;index++&#93;.m_move = tempMove.m_move;
				tempMove.setFlags&#40;WHITEKNIGHT&#41;;
				Moves&#91;index++&#93;.m_move = tempMove.m_move;
			&#125;

			// Remove the least significant bit&#58;
			targets &= &#40;targets - 1&#41;;
		&#125;
		piece &= &#40;piece - 1&#41;;
	&#125;

	/********************************************
	*											*
	*			White Knight Moves				*
	*											*
	*********************************************/

	tempMove.clearMove&#40;);
	tempMove.setPiece&#40;WHITEKNIGHT&#41;;
	piece = Bitboard&#58;&#58;whiteKnights;
	targets = 0;

	while&#40;piece&#41; &#123;
		from = lsb&#40;piece&#41;;
		tempMove.setFrom&#40;from&#41;;

		targets |= &#40;arrKnightAttacks&#91;from&#93; & (~Bitboard&#58;&#58;whitePieces&#41;);

		while&#40;targets&#41; &#123;
			to = lsb&#40;targets&#41;;
			tempMove.setTo&#40;to&#41;;
			tempMove.setCapture&#40;Bitboard&#58;&#58;square&#91;to&#93;);

			Moves&#91;index++&#93;.m_move = tempMove.m_move;

			targets &= &#40;targets - 1&#41;;
		&#125;
		piece &= &#40;piece - 1&#41;;
	&#125;

	/********************************************
	*											*
	*			White King Moves				*
	*											*
	*********************************************/

	tempMove.clearMove&#40;);
	tempMove.setPiece&#40;WHITEKING&#41;;
	piece = Bitboard&#58;&#58;whiteKing;
	targets = 0;

	while&#40;piece&#41; &#123;
		from = lsb&#40;piece&#41;;
		tempMove.setFrom&#40;from&#41;;

		targets |= &#40;arrKingAttacks&#91;from&#93; & (~Bitboard&#58;&#58;whitePieces&#41;);

		while&#40;targets&#41; &#123;
			to = lsb&#40;targets&#41;;
			tempMove.setTo&#40;to&#41;;
			tempMove.setCapture&#40;Bitboard&#58;&#58;square&#91;to&#93;);

			Moves&#91;index++&#93;.m_move = tempMove.m_move;

			targets &= &#40;targets - 1&#41;;
		&#125;
		piece &= &#40;piece - 1&#41;;
	&#125;
	/********************************************
	*											*
	*			White Bishop Moves				*
	*											*
	*********************************************/

	tempMove.clearMove&#40;);
	tempMove.setPiece&#40;WHITEBISHOP&#41;;
	piece = Bitboard&#58;&#58;whiteBishops;
	targets = 0;

	while&#40;piece&#41; &#123;
		from = lsb&#40;piece&#41;;
		tempMove.setFrom&#40;from&#41;;


		targets = genBishopMoves&#40;from, Bitboard&#58;&#58;occupiedSquares, (~Bitboard&#58;&#58;whitePieces&#41;);

		while&#40;targets&#41; &#123;
			to = lsb&#40;targets&#41;;
			tempMove.setTo&#40;to&#41;;
			tempMove.setCapture&#40;Bitboard&#58;&#58;square&#91;to&#93;);

			Moves&#91;index++&#93;.m_move = tempMove.m_move;

			targets &= &#40;targets - 1&#41;;
		&#125;
		piece &= &#40;piece - 1&#41;;
	&#125;

	/********************************************
	*											*
	*			White Rook Moves				*
	*											*
	*********************************************/

	tempMove.clearMove&#40;);
	tempMove.setPiece&#40;WHITEROOK&#41;;
	piece = Bitboard&#58;&#58;whiteRooks;
	targets = 0;
	while&#40;piece&#41; &#123;
		from = lsb&#40;piece&#41;;
		tempMove.setFrom&#40;from&#41;;

		targets = genRookMoves&#40;from, Bitboard&#58;&#58;occupiedSquares, (~Bitboard&#58;&#58;whitePieces&#41;);

		while&#40;targets&#41; &#123;
			to = lsb&#40;targets&#41;;
			tempMove.setTo&#40;to&#41;;
			tempMove.setCapture&#40;Bitboard&#58;&#58;square&#91;to&#93;);

			Moves&#91;index++&#93;.m_move = tempMove.m_move;

			targets &= &#40;targets - 1&#41;;
		&#125;
		piece &= &#40;piece - 1&#41;;
	&#125;

	/********************************************
	*											*
	*			White Queen Moves				*
	*											*
	*********************************************/

	tempMove.clearMove&#40;);
	tempMove.setPiece&#40;WHITEQUEEN&#41;;
	piece = Bitboard&#58;&#58;whiteQueens;
	targets = 0;

	while&#40;piece&#41; &#123;
		from = lsb&#40;piece&#41;;
		tempMove.setFrom&#40;from&#41;;

		targets = genQueenMoves&#40;from, Bitboard&#58;&#58;occupiedSquares, (~Bitboard&#58;&#58;whitePieces&#41;);

		while&#40;targets&#41; &#123;
			to = lsb&#40;targets&#41;;
			tempMove.setTo&#40;to&#41;;
			tempMove.setCapture&#40;Bitboard&#58;&#58;square&#91;to&#93;);

			Moves&#91;index++&#93;.m_move = tempMove.m_move;

			targets &= &#40;targets - 1&#41;;
		&#125;
		piece &= &#40;piece - 1&#41;;
	&#125;

	/********************************************
	*											*
	*			White Castling Moves			*
	*											*
	*********************************************/

	// White O-O Castling Moves&#58;
	if&#40;&#40;Bitboard&#58;&#58;WhiteCastleOO&#41; &&
		(!(&#40;Bitboard&#58;&#58;occupiedSquares&#41; & WHITE_OO_CASTLE&#41;) &&
		(!&#40;isBlackAttacking&#40;2&#41;))) 
	&#123;
		Moves&#91;index&#93;.setFrom&#40;4&#41;;
		Moves&#91;index&#93;.setTo&#40;6&#41;;
		Moves&#91;index&#93;.setPiece&#40;WHITEKING&#41;;
		Moves&#91;index++&#93;.setFlags&#40;WHITEKING&#41;;
	&#125;

	// White O-O-O Castling Moves&#58;
	if&#40;&#40;Bitboard&#58;&#58;WhiteCastleOOO&#41; &&
		(!(&#40;Bitboard&#58;&#58;occupiedSquares&#41; & WHITE_OOO_CASTLE&#41;) &&
		(!&#40;isBlackAttacking&#40;32&#41;)))
	&#123;
		Moves&#91;index&#93;.setFrom&#40;4&#41;;
		Moves&#91;index&#93;.setTo&#40;2&#41;;
		Moves&#91;index&#93;.setPiece&#40;WHITEKING&#41;;
		Moves&#91;index++&#93;.setFlags&#40;WHITEKING&#41;;
	&#125;
	Bitboard&#58;&#58;noOfMoves = index;
&#125;
[/code]
kinderchocolate
Posts: 454
Joined: Mon Nov 01, 2010 6:55 am
Full name: Ted Wong

Re: Insanely buggy move generator, please help

Post by kinderchocolate »

Some remarks and hints:

1. When you code a bitboard generator like this, verify and verify about knights before moving to another piece type. Knight is the easiest because it isn't sliding. Are you sure your knight generation is correct? If not, focus only and only on it.

2. You don't need code for both colors. You should define a function for generation for each piece type. The function takes a color.

3. What's Bitboard::whiteKnights??? Is this a static bitboard? If this is static, how can you play a game?

Instead of debugging it for you. I'll advise you to do the following:

A. Write a function that generates a bitboard for a knight attacks for each square.

B. Write and test a function that returns a list or a bitboard of all knights from any FEN position.

Once you've done A and B. You can easily generate pseudo-knight moves by looping through each knight square. Please proceed only if you're confident your knight generation is correct.
User avatar
vittyvirus
Posts: 646
Joined: Wed Jun 18, 2014 2:30 pm
Full name: Fahad Syed

Re: Insanely buggy move generator, please help

Post by vittyvirus »

kinderchocolate wrote:Some remarks and hints:

1. When you code a bitboard generator like this, verify and verify about knights before moving to another piece type. Knight is the easiest because it isn't sliding. Are you sure your knight generation is correct? If not, focus only and only on it.

2. You don't need code for both colors. You should define a function for generation for each piece type. The function takes a color.

3. What's Bitboard::whiteKnights??? Is this a static bitboard? If this is static, how can you play a game?

Instead of debugging it for you. I'll advise you to do the following:

A. Write a function that generates a bitboard for a knight attacks for each square.

B. Write and test a function that returns a list or a bitboard of all knights from any FEN position.

Once you've done A and B. You can easily generate pseudo-knight moves by looping through each knight square. Please proceed only if you're confident your knight generation is correct.
Hi!

1. The Knight Move generator is the most correct one in my program, weird enough. The more buggy parts are pawns.

2. Yes, I have. I just posted this to not confuse you guys, as I mentioned.

3. Bitboard::whiteKnights stores white knights on the board, and so does Bitboard::whitePawns, Bitboard::whiteQueens etc.

A. I use this function to generate arrKnightAttacks:

Code: Select all

inline BitMap calcKnightAttacks&#40;const UINT &sq&#41; &#123;
	BitMap b = 1ULL << sq, KnightAttacks&#40;0&#41;;
	KnightAttacks = noNoEa&#40;b&#41; | noEaEa&#40;b&#41; | soEaEa&#40;b&#41; | soSoEa&#40;b&#41; | noNoWe&#40;b&#41; | noWeWe&#40;b&#41; | soWeWe&#40;b&#41; | soSoWe&#40;b&#41;;
	return KnightAttacks;
&#125;
B. Done that too, already. I've a fen parser.

Cheers!
Syed Fahad.
kbhearn
Posts: 411
Joined: Thu Dec 30, 2010 4:48 am

Re: Insanely buggy move generator, please help

Post by kbhearn »

The earlier comment with regard to Bitboard::whiteKnights was motivated by it being strange syntax (and i'm not sure if it's correct or not to be honest). Usually you would only use class::member to access a variable if a) you're not operating in the namespace already anyways (which you are because this is a member function) and b) member is declared static. since the function you're in is part of Bitboard:: already you can access the whiteKnights variable without any qualifier. And if it's not a static member (which i assume it shouldn't be in the event you ever want to have more than one copy of the class), to access it outside of the class you'd need to use 'variable.whiteKnights'.

Pawns and knights should be straightforward to debug. The cases you need to watch out for are where the square differences cause the board to wrap (what happens when a pawn on h3 tries to capture to the right). A note on your pawn generation: rather than looping through all pawns and individually testing for unoccupied/enemy occupied squares the normal way to generate pawn moves is in batch for each case (capture left, capture right, single push, double push), and then loop through the result of pawns that can execute the move in question.

As for your sliders, i'd recommend NOT using magics for your first move generator due to reliance on large data tables that are a pain to debug manually. One simple way to generate a slider attack is to use either bitscan forward or bitscan reverse on (ray & (occupied | perimeterofboard)) depending on direction to find your first blocker in each direction and just return the path between each pair of blockers, much simpler to debug. You can later switch to magics if you want and use the simpler move generator to do automatic testing of your mass of magic numbers.
User avatar
vittyvirus
Posts: 646
Joined: Wed Jun 18, 2014 2:30 pm
Full name: Fahad Syed

Re: Insanely buggy move generator, please help

Post by vittyvirus »

kbhearn wrote:The earlier comment with regard to Bitboard::whiteKnights was motivated by it being strange syntax (and i'm not sure if it's correct or not to be honest). Usually you would only use class::member to access a variable if a) you're not operating in the namespace already anyways (which you are because this is a member function) and b) member is declared static. since the function you're in is part of Bitboard:: already you can access the whiteKnights variable without any qualifier. And if it's not a static member (which i assume it shouldn't be in the event you ever want to have more than one copy of the class), to access it outside of the class you'd need to use 'variable.whiteKnights'.

Pawns and knights should be straightforward to debug. The cases you need to watch out for are where the square differences cause the board to wrap (what happens when a pawn on h3 tries to capture to the right). A note on your pawn generation: rather than looping through all pawns and individually testing for unoccupied/enemy occupied squares the normal way to generate pawn moves is in batch for each case (capture left, capture right, single push, double push), and then loop through the result of pawns that can execute the move in question.

As for your sliders, i'd recommend NOT using magics for your first move generator due to reliance on large data tables that are a pain to debug manually. One simple way to generate a slider attack is to use either bitscan forward or bitscan reverse on (ray & (occupied | perimeterofboard)) depending on direction to find your first blocker in each direction and just return the path between each pair of blockers, much simpler to debug. You can later switch to magics if you want and use the simpler move generator to do automatic testing of your mass of magic numbers.
I find magics simpler to understand. But I'd surely work on your advice.
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: Insanely buggy move generator, please help

Post by zullil »

vittyvirus wrote:This is my move generator code for black. Its insanely buggy, please help me find those bugs.
One day I might use bitboards, and maybe even understand "magic" bitboards. For now, I use an array of 130 (thought of as 13 x 10) ints for my board representation. (It's a 12 x 10 scheme, with an extra "rank" that holds state information and king locations.) After two weeks of writing and debugging (twice finding = where I intended to have ==), I seem to have a working (legal) move generator:

Code: Select all

louis@LZsT5610&#58;~/Documents/Chess/Kirby$ ./perft_new 
FEN string = rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -
Depth = 6
Leaf nodes = 119060324
Time taken = 2353 ms

louis@LZsT5610&#58;~/Documents/Chess/Kirby$ ./perft_new 
FEN string = r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq -
Depth = 5
Leaf nodes = 193690690
Time taken = 2199 ms
Good luck getting yours working. I'm sure it will be faster than mine once you've killed all the bugs.
User avatar
vittyvirus
Posts: 646
Joined: Wed Jun 18, 2014 2:30 pm
Full name: Fahad Syed

Re: Insanely buggy move generator, please help

Post by vittyvirus »

zullil wrote:
vittyvirus wrote:This is my move generator code for black. Its insanely buggy, please help me find those bugs.
One day I might use bitboards, and maybe even understand "magic" bitboards. For now, I use an array of 130 (thought of as 13 x 10) ints for my board representation. (It's a 12 x 10 scheme, with an extra "rank" that holds state information and king locations.) After two weeks of writing and debugging (twice finding = where I intended to have ==), I seem to have a working (legal) move generator:

Code: Select all

louis@LZsT5610&#58;~/Documents/Chess/Kirby$ ./perft_new 
FEN string = rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -
Depth = 6
Leaf nodes = 119060324
Time taken = 2353 ms

louis@LZsT5610&#58;~/Documents/Chess/Kirby$ ./perft_new 
FEN string = r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq -
Depth = 5
Leaf nodes = 193690690
Time taken = 2199 ms
Good luck getting yours working. I'm sure it will be faster than mine once you've killed all the bugs.
If your move generator does perft 6 in under 3 seconds, it is fairly difficult to beat.
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: Insanely buggy move generator, please help

Post by zullil »

vittyvirus wrote:
zullil wrote:
vittyvirus wrote:This is my move generator code for black. Its insanely buggy, please help me find those bugs.
One day I might use bitboards, and maybe even understand "magic" bitboards. For now, I use an array of 130 (thought of as 13 x 10) ints for my board representation. (It's a 12 x 10 scheme, with an extra "rank" that holds state information and king locations.) After two weeks of writing and debugging (twice finding = where I intended to have ==), I seem to have a working (legal) move generator:

Code: Select all

louis@LZsT5610&#58;~/Documents/Chess/Kirby$ ./perft_new 
FEN string = rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -
Depth = 6
Leaf nodes = 119060324
Time taken = 2353 ms

louis@LZsT5610&#58;~/Documents/Chess/Kirby$ ./perft_new 
FEN string = r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq -
Depth = 5
Leaf nodes = 193690690
Time taken = 2199 ms
Good luck getting yours working. I'm sure it will be faster than mine once you've killed all the bugs.
If your move generator does perft 6 in under 3 seconds, it is fairly difficult to beat.
But not for a world-class engine like the one you want to create!

Code: Select all

Stockfish 270714 64 SSE4.2 by Tord Romstad, Marco Costalba and Joona Kiiski
position startpos
perft 6

Position&#58; 1/1

Perft 6 leaf nodes&#58; 119060324

===========================
Total time &#40;ms&#41; &#58; 758
Nodes searched  &#58; 119060324
Nodes/second    &#58; 157071667
User avatar
vittyvirus
Posts: 646
Joined: Wed Jun 18, 2014 2:30 pm
Full name: Fahad Syed

Re: Insanely buggy move generator, please help

Post by vittyvirus »

zullil wrote:
vittyvirus wrote:
zullil wrote:
vittyvirus wrote:This is my move generator code for black. Its insanely buggy, please help me find those bugs.
One day I might use bitboards, and maybe even understand "magic" bitboards. For now, I use an array of 130 (thought of as 13 x 10) ints for my board representation. (It's a 12 x 10 scheme, with an extra "rank" that holds state information and king locations.) After two weeks of writing and debugging (twice finding = where I intended to have ==), I seem to have a working (legal) move generator:

Code: Select all

louis@LZsT5610&#58;~/Documents/Chess/Kirby$ ./perft_new 
FEN string = rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -
Depth = 6
Leaf nodes = 119060324
Time taken = 2353 ms

louis@LZsT5610&#58;~/Documents/Chess/Kirby$ ./perft_new 
FEN string = r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq -
Depth = 5
Leaf nodes = 193690690
Time taken = 2199 ms
Good luck getting yours working. I'm sure it will be faster than mine once you've killed all the bugs.
If your move generator does perft 6 in under 3 seconds, it is fairly difficult to beat.
But not for a world-class engine like the one you want to create!

Code: Select all

Stockfish 270714 64 SSE4.2 by Tord Romstad, Marco Costalba and Joona Kiiski
position startpos
perft 6

Position&#58; 1/1

Perft 6 leaf nodes&#58; 119060324

===========================
Total time &#40;ms&#41; &#58; 758
Nodes searched  &#58; 119060324
Nodes/second    &#58; 157071667
You have a faster system:

Code: Select all

Stockfish 5 64 SSE4.2 by Tord Romstad, Marco Costalba and Joona Kiiski
perft 6

Position&#58; 1/1

Perft 6 leaf nodes&#58; 119060324

===========================
Total time &#40;ms&#41; &#58; 939
Nodes searched  &#58; 119060324
Nodes/second    &#58; 126794807
But but, here's what Cheng (another strong engine) has to say:

Code: Select all

&#93;
perft 6
119060324 nodes
took 2537 ms
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: Insanely buggy move generator, please help

Post by zullil »

vittyvirus wrote: But but, here's what Cheng (another strong engine) has to say:

Code: Select all

perft 6
119060324 nodes
took 2537 ms
For reference, here's what I get on my 2.0 GHz Intel Core 2 Duo Late 2007 MacBook:

Code: Select all

ProcyonLeo&#58; ~/Documents/Chess/Kirby&#93; ./perft_new 
FEN string = rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -
Depth = 6
Leaf nodes = 119060324
Time taken = 5425 ms