From 96d6b8ebd32166f5d72420e94060de4792da999b Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Tue, 11 Feb 2014 22:32:45 +1100 Subject: Fixed bug where no possible rules to apply --- Thue/Interpreter.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Thue/Interpreter.hs b/Thue/Interpreter.hs index 896ec8a..c53bff9 100644 --- a/Thue/Interpreter.hs +++ b/Thue/Interpreter.hs @@ -26,7 +26,8 @@ thue program = interpret :: ThueState -> [ThueRule] -> StdGen -> IO ThueState interpret state rules gen = do let possibleRules = rules `applicableTo` state - ruleToApply = possibleRules !! num + ruleToApply = if (possibleRules == []) then (ThueRule "" "") else possibleRules !! num + -- ^ dummy rule if no possible rules apply (num, gen') = nextInRange 0 (length possibleRules - 1) gen -- cgit