You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
576 B

9 years ago
  1. module GeneralStrategies where
  2. import Data.Maybe
  3. import Datatypes
  4. import PowerPhrases
  5. import VM
  6. executePhrase :: String -> Game -> [(Game, Notes)]
  7. executePhrase str game = foldl cmdprop [(game,OK)] commands
  8. where
  9. commands = mapMaybe charToCommand str
  10. cmdprop (x:xs) cmd = (fst (step (fst x) cmd), notesfilter (snd (step (fst x) cmd)) (snd x)):x:xs
  11. notesfilter :: Notes -> Notes -> Notes
  12. notesfilter a b = if b == ErrorZero
  13. then ErrorZero
  14. else if a == Ended
  15. then Ended
  16. else OK