Selection in Monte Carlo Alpha-Beta

Discussion of chess software programming and technical issues.

Moderator: Ras

dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Selection in Monte Carlo Alpha-Beta

Post by dangi12012 »

HINT

Code: Select all

child_value/child_visits + sqrt(2log(parent_visits)/child_visits)

==

child_value/child_visits + C * inv_sqrt(child_visits/log2(parent_visits))
where C is the amalgation of adjusting the ln together with the free parameter of ucb1.

Also dont do the first term in integers. Cast to float before! Integer division is much slower than float and the + will cast it to float anyway.

Later advanced hint:

Code: Select all

(AVX1) _mm256_rsqrt_ps
(unfortunately avx512) _mm256_lzcnt_epi64 

To find the best UCB1 value you can use _mm256_cmpgt_epi64 + mask.
So you can calculate + compare 8 ucb1 values at once in a few instructions.
But keep the hardcore optimisation for when your search is good and everything works :D
No paper on the topic uses this as far as I have seen. Leaving performance on the table.

I am not built that way. When I see the optimum is not reached I will optimize more. Letting me take 2 years for a movegen alone... Not recommended.
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
User avatar
RedBedHed
Posts: 84
Joined: Wed Aug 04, 2021 12:42 am
Full name: Ellie Moore

Re: Selection in Monte Carlo Alpha-Beta

Post by RedBedHed »

lithander wrote: Fri Sep 16, 2022 5:29 pm
RedBedHed wrote: Fri Sep 16, 2022 8:45 am I recently switched to 2-ply Alpha-Beta searches. I am finding that the Alpha-Beta searches are much better at estimating win probabilities. The Alpha-Beta searches also help my MCTS pick up on subtle tactics that it missed before.
Apparently Kommodo Dragon's MCTS mode is doing it like that, too: https://youtu.be/JUQoSVqiavw?t=1689
This is so cool! Thank you for the link! I wish the code wasn't proprietary. *sigh*
>> Move Generator: Charon
>> Engine: Homura
void life() { playCapitalism(); return; live(); }