ChessUSA.com TalkChess.com
Hosted by Your Move Chess & Games
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

best board representation for variants (javascript) ?
Post new topic    TalkChess.com Forum Index -> Computer Chess Club: Programming and Technical Discussions Flat
View previous topic :: View next topic  
Author Message
H.G.Muller



Joined: 10 Mar 2006
Posts: 21824
Location: Amsterdam

PostPost subject: Re: best board representation for variants (javascript) ?    Posted: Sun Dec 10, 2017 8:53 pm Reply to topic Reply with quote

Least coding would be a 1-dimensional array containing the piece types, with a 0x88-type square layout (i.e. gaps between the ranks), and a band of boundary guards around it to prevent pieces could jump off board. You can generate moves from that with a triply mested loop, over the board to find pieces, then over directions the piece moves in, and then (if it is a sliding move) over the number of steps taken in that direction.

This is not very efficient, though, as you spend a lot of time locating your own pieces on the board. And captures are only generated as the last move of a slide, meaning that you basically always generate all the moves, even if you only want captures. There are ways to enormously speed up the move generation, but they all add code complexity.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Subject Author Date/Time
best board representation for variants (javascript) ? Mahmoud Uthman Sun Dec 10, 2017 1:54 pm
      Re: best board representation for variants (javascript) ? H.G.Muller Sun Dec 10, 2017 8:53 pm
      Re: best board representation for variants (javascript) ? Tamás Kuzmics Mon Dec 11, 2017 6:49 pm
      Re: best board representation for variants (javascript) ? Evert Glebbeek Mon Dec 11, 2017 8:22 pm
Post new topic    TalkChess.com Forum Index -> Computer Chess Club: Programming and Technical Discussions

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Powered by phpBB © 2001, 2005 phpBB Group
Enhanced with Moby Threads