Check out Janggi (Korean Chess), our featured variant for December, 2024.


[ Help | Earliest Comments | Latest Comments ]
[ List All Subjects of Discussion | Create New Subject of Discussion ]
[ List Earliest Comments Only For Pages | Games | Rated Pages | Rated Games | Subjects of Discussion ]

Single Comment

GAME code table-driven move generator[Subject Thread] [Add Response]
H. G. Muller wrote on Thu, Aug 13, 2020 01:14 PM UTC in reply to Fergus Duniho from 12:10 PM:

Why not just copy your HTML to a member-created page?

I suppose I could do that. But I thought it would be pointless to have it as an independent article; no one would ever get there from the article index, they would not know which title to look for, or even that it existed. If they get there, it would be through a link from another article, e.g. from the Play-Test Applet. So I wanted to put a link to it from there. But you are right, I could of also do that if it was a member contribution. I will do that then.

It would be ideal if there could be a link to it from the GAME Courier page, next to the links to all the other tutorials in the developers section. I noticed your tutorial about the fairychess include file is also not mentioned there. And I couldn't find it through the index either.

4 seconds does seem a bit long. It seems you have ideas for reducing that time.

Indeed, I am working on that. I have been running some timing tests with the stopwatch command, to get a bit of feeling for what would be fast and what would be slow. The method one often uses in engines, to map a pair of squares to a number that uniquely represents the geometry of the leap between them, and then use that as an index in a table to see whether that leap matches what the piece can do, seems to be reasonably fast. Initializing the required table for a 20x20 board with Queen, Griffon and Aanca moves only took 0.08 sec. And calculating the mapping like

set i + 800 - file #origin + file #destination * 40 - rank #origin rank #destination;

needed to calculate the table index took only about 23 micro-seconds. You would only have to do that once for every piece, and a bitwise AND with the value retrieved from the table would for most pieces immediately tell you whether they checked or could not possibly check. Only for quite unusual pieces it would not be conclusive, and the slow method of generating all unusual moves of the pieces, and see if one of those happens to hit the King would have to be used as a fall-back.

For the time being I configured the presets to highlight all pseudo-legal moves.