Programming A Chess Engine In Pure Javascript Part 47 - Search Implementation #7 - It searches

preview_player
Показать описание
We chatter on this Discord server:

A tutorial series programming a chess engine in Javascript

But really, it's for fun and for free.
Рекомендации по теме
Комментарии
Автор

I've made a pretty interesting discovery regarding the performance of the engine. I wasn't getting the same number of nodes as you were only to discover that it had to do with the way that the numbers were stored in the direction arrays for the pieces in defs.js

For example, in BiDir you have the order [-9, -11, 11, 9] which produces 230351 nodes at depth 5. This is the only number that changes depending on the order but the answers vary quite a bit. Also note that every time I refresh the page, I'll always get 230351 so the results are perfectly consistent.

I brute forced all possible permutations for these numbers and found that:

The order [-9, 11, 9, -11] yielded the best performance with 246645 nodes analyzed

The order [9, -9, 11, -11] yielded the worst performance with 194623 nodes analyzed

What makes this all the more interesting is that I tried the exact same thing for the rook direction array, and no matter what order you give it the performance does not change by a single node.


I can't thank you enough for your videos. They're incredible, concise, and perfectly understandable. You're an absolute legend!

luisvictoria
Автор

Just a small hint: The code for this video (download as well as presented in the video) differs from the code from the "full program" regarding the MoveExists-function: In the code found online the parameter "move" is overwritten and the comparison "move == moveFound" is missing.

philonous
Автор

Thanks for the guide. After cloning your algorithm to my C# Unity project, I find that it takes at least 10 seconds on average to find the best move with a maximum depth of 5, sometimes it takes even longer.

Though my code is not exactly the same as yours since I have made some modifications, it seems that on your machine the searching algorithm runs much faster than mine. Do you remember how many seconds it takes to find the best move using iterative deepening with 5 maximum depths?

C-and-S
Автор

Wow, Well spotted :) :) The online version is obviously incorrect - I remember now I realised during the video, and corrected it. I forgot to update the online version. Thanks a lot, talk about eagle-eyed!!

BlueFeverSoft
Автор

I have this one doubt probepvtable() will always return a legal move then why do we need to check if move exist or not?

piyushpathak
Автор

also when printing the whole line of a certain depth let's say 3 it doesn't contain 3 moves instead prints only 1 move?do you have any idea why while loop inside GetPvLine() breaks before depth len?

piyushpathak
Автор

For me it doesnt work. I altered a code a little bit bc Im working on a different table game but it only works for me for the first 2 depths and then pvnum sets to 0 every depth from then on. I dont know what to do. Any ideas?

k.s.
Автор

I noticed a while ago, in the "search.js" file, in the "CheckUp()" function, There's an "if" statement with the equal to ( == ) comparison operator instead of the assignment operator ( = ) after the conditional statement, in the code block. Executed Code: SearchController.stop == BOOL.TRUE;. (Unless i'm incorrect lol) Just in case you didn't catch it in a later video ;)

Semperfi
Автор

movegen.js line 165 it should be NO_SQ instead of NOSQ

harshverma-iemh
Автор

in search.js, line 23 you had
SearchController.stop == BOOL.TRUE;

instead of
SearchController.stop = BOOL.TRUE;

bobsandvegane