help understanding fancy magic bit boards

Discussion of chess software programming and technical issues.

Moderator: Ras

am5083
Posts: 10
Joined: Mon Jul 18, 2022 6:01 pm
Full name: AM Solomon

help understanding fancy magic bit boards

Post by am5083 »

I have currently run into an issue while writing my search function where indexing the rook/bishop attack tables at depth>5 overflows the stack and causes my program to segfault. I am using the plain magic bit board approach, and it seems the obvious solution is to switch to another approach with smaller attack table sizes, however I cannot understand how the attack table for fancy magic bit boards is generated and cannot find any pseudocode I can reference. Everything else makes sense, but what I do not understand is how exactly I should structure the attack table array.
clayt
Posts: 29
Joined: Thu Jun 09, 2022 5:09 am
Full name: Clayton Ramsey

Re: help understanding fancy magic bit boards

Post by clayt »

How on earth are you managing to overflow the stack? Even if your attack lookup tables are stack-allocated, I wouldn't think there's enough of them to completely kill your stack. On many machines these days the stack size is 8192 KiB, which should be large enough even for the least efficient magic lookup tables.

That being said, it's generally more common to heap-allocate your attack lookup tables. This has the added benefit of allowing you to make "ragged" attack lookup tables and save some space.
AndrewGrant
Posts: 1957
Joined: Tue Apr 19, 2016 6:08 am
Location: U.S.A
Full name: Andrew Grant

Re: help understanding fancy magic bit boards

Post by AndrewGrant »

I cannot imagine your stackoverflow is the result of the attack tables, unless you are initing the attack tables inside tiny little functions itself of just once and using it globally.