my code, takes a gameState and tries to return a list of GameStates.
I wish to limit the depth of the tree to depth n.
to do this i wrote this code
applyMoves :: Maybe GameState -> [Maybe GameState]
applyMoves g = map (applyMove (f g)) (legalMoves (f g))
where
f :: Maybe GameState -> GameState
f (Just x) = x
othelloTree :: Maybe GameState -> Int -> RoseTree (Maybe GameState)
othelloTree (state) 0 = RoseNode (state) []
othelloTree state depth = RoseNode (state) (myMap' (othelloTree) (applyMoves state) (depth-1))
where
myMap' :: (a->Int->c)->[a]->Int->[c]
myMap' _ [] 0 = []
myMap' _ [] _ = []
myMap' f (x:xs) 0 = []
myMap' f (x:xs) i = (f (x) (i)) : myMap' f xs (i-1)
this code compiles but does not return all of the nodes at a depth n. Instead it only returns some of the nodes at depth n. This has confused me for many days now as the code should return the tree up to a depth n not only some of the tree.
any help or guidance would be greatly appreciated !!