
2 Jun
2010
2 Jun
'10
7:07 a.m.
Yitzchak Gale schrieb: [...]
If you choose a map from positions to pieces, it might turn out to be just about as fast to use a simple association list
[(Int, Int), Maybe Piece]
instead of all the machinery of Data.Map.Map (Int, Int) (Maybe Piece) A chess board has only 64 locations.
if you associate positions to pieces, you can omit "Maybe" and simple delete positions without pieces from the Map. So your Map will only have 32 entries or fewer. Furthermore, you could code your row and column positions (r, c) as a single Int p and use Data.IntMap.IntMap Piece. p = 8 * r + c c = mod p 8 r = div p 8 Have fun Christian