module Testing where

import GameBoard
import Strategy
import Rules
import Types

type GameState = (Board,[Board -> [Action]])

scores b = ((Troll,nt*4),(Dwarf,nd))
    where nt = length $ findPieces Troll b
          nd = length $ findPieces Dwarf b

initState = (landscape2board newLandscape, turnabout)

nextState st = case brd of
                Board [] _ -> error "no trolls"
                Board _ [] -> error "no dwarves"
                Board _ _  -> (newbrd, newplayer)
    where newplayer = tail . snd $ st
          player = head . snd $ st
          brd = fst $ st
          newbrd = let n = player brd
                   in if null n then brd else move (head n) brd

nthMove n st = bs !! n
    where bs = iterate nextState st

allinfo b = do printBoard b
               print $ scores b
printBoard = printLandscape . board2landscape

test n = fst $ nthMove n initState

