Haskell checkers (I WILL PROVIDE FILES) This is a haskell checkers question and I simply…

Haskell checkers (I WILL PROVIDE FILES) This is a haskell checkers assignment and I simply needed help with one part of the assignment with is checking states (please dont change the types.hs file to do this, just work in main and run the test in main.hs). It is the only part of the assignment I need assistance with; You have to use the history (this is coded in main*) to tell whether one has repeated a state. As pawn moves and jumps are irreversible the only moves one has to worry about are the simple king moves. In this case you are looking for a repetition of the current state: this means looking back in the moves to see whether there is an earlier stage at which each piece was in exactly the same spot or, more challengingly, the black and red kings are in some permutation of their original position. So there must have been a sequence of history moves in which, for each king, there is a series of simple king moves which take the colored kings back to the same place or (more generally) a permutation of those places. To determine this is one uses the history to trace where each piece came from. To program this keep two lists — black moves and red moves — of “movement pairs” (a start position and a current position): these lists will initially be empty. For each move in the history update the appropriate lists by altering the start position of the piece being moved back to its earlier start position. When the appropriate list is empty — or the piece has not been moved before — this will amount to adding the move itself to that appropriate list. Note that all you need to know is the positions of the pieces as each piece (red or black) occupies a unique position and a move gives a before and after position. Furthermore, you need not keep track of pieces which have not moved. This means one can eliminate movement pairs that record no movement. Furthermore you can eliminate any cycles which occur in either of these lists. If at some stage in the history (of simple king moves) you discover each piece came from where it is currently — which means the movement list is empty again — you have repeated a state. Similarly, if you reach a state in which every move (in each list) is in a cycle so can be removed then you have a repeated state. In programming this it may be worth first not worrying initially about removing permutations from the list so that you check for non-repeating positions which allow similarly colored pieces to be permuted. 

Don't use plagiarized sources. Get Your Custom Essay on
Haskell checkers (I WILL PROVIDE FILES) This is a haskell checkers question and I simply…
Just from $13/Page
Order Essay