Personal tools

Talk:Learning Haskell with Chess

From HaskellWiki

Jump to: navigation, search

Contents

1 list handling vs. abstract data types (array)

Lists are very inefficient, but understanding list handling is important for understanding functional programming. On the other hand, using
Array
would provide understanding for abstract data types.

2 using state monad for the board

Only possible with advanced students, do not try this in introductory courses.

3 full ruleset vs. reduced and simplified ruleset

To implement the full ruleset you have to remember and consider previous states (in particular for castling rule and capturing en passant).

-- Actually, this isn't so bad to do. It's entirely possibly by simply checking and updating flags. A single Int with a few bit masks could easily do it. One thing to consider as far as what needs to be encoded in any given position to be able to determine all legal moves is the FEN specification for representing moves: [[1]] -- Andrew Wagner.

4 representation of positions

Is
type Pos = (Int,Int)
ok? Or better something like
type Pos = (Row, Column), data Row = A | B | ... | H, data Column = ?
. How to model the constraints (0<=x,y<=7)?

-- There are several ways to handle this. Much work has been done in figuring out what the best way is, but I'll just point you to the first two articles at [[2]] I should point out that the theory behind using bitboards has advanced significantly since those articles were written, and I would strongly recommend looking at that. -- Andrew Wagner

-- Andrew, thank you for this link. The facts there strongly apply to imperative programming, however, I cannot see how to transfer these practices to functional programming without getting the fingers too dirty. -- Steffen Mazanek

-- I'm not quite sure what you see there that's inherently imperative. In fact, the whole point of bitboards is to get rid of loops as much as possible, which should please the functional programmer greatly. Can you possibly clarify? -- Andrew

5 more general game library

Should students be confronted with a more general gametree generation (successor states-function as param) and minimax algorithm (eval-function as param)?