diff --git a/src/Datatypes/Game.hs b/src/Datatypes/Game.hs index 406ea95..727fd72 100644 --- a/src/Datatypes/Game.hs +++ b/src/Datatypes/Game.hs @@ -49,10 +49,10 @@ new b us = Game { } where (c:cs) = map (flip Unit.centeredIn b) us phraseConverter :: [Command] -> String -phraseConverter s = if s == [MoveE, MoveSW, MoveW] +phraseConverter s = if s == reverse [MoveE, MoveSW, MoveW] then "ei!" - else if s == [MoveSW, MoveSW, MoveW, MoveSE, MoveSW, MoveSW, MoveW] - then "ia ! ia!" + else if s == reverse [MoveSW, MoveSW, MoveW, MoveSE, MoveSW, MoveSW, MoveW] + then "ia! ia!" else "PUPPA" powerPhrases :: [[Command]] diff --git a/src/Strategy0.hs b/src/Strategy0.hs index b6f8e41..62bd8ea 100644 --- a/src/Strategy0.hs +++ b/src/Strategy0.hs @@ -58,7 +58,7 @@ tryPowerPhrases game = validResults where findBest :: Int -> Queue -> [Game] -> (Queue, [Game]) findBest 0 queue completed = (queue, completed) findBest i queue completed = - let candidates = map (step game) commandsList -- ++ (tryPowerPhrases game) + let candidates = (tryPowerPhrases game) ++ (map (step game) commandsList) (newQueue, newCompleted) = updateCollections candidates remQueue (game:completed) in findBest (i - 1) newQueue newCompleted where diff --git a/src/VM.hs b/src/VM.hs index cf14286..88de3f0 100644 --- a/src/VM.hs +++ b/src/VM.hs @@ -33,7 +33,7 @@ dumbConvert RotateClockwise = 'd' dumbConvert RotateCounterclockwise = 'k' smartConvert cmds = innerSmartConvert cmds Game.powerPhrases where innerSmartConvert _ [] = Nothing - innerSmartConvert cmds (p:ps) = if p `List.isPrefixOf` cmds + innerSmartConvert cmds (p:ps) = if (reverse p) `List.isPrefixOf` cmds then Just $ Game.phraseConverter p else innerSmartConvert cmds ps