summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2014-02-11 22:32:45 +1100
committerJed Barber <jjbarber@y7mail.com>2014-02-11 22:32:45 +1100
commit96d6b8ebd32166f5d72420e94060de4792da999b (patch)
treee49654f3c66ed5ea58bb3ef948f5d94d7ccdc539
parent9788afd65ff8bab34b70f2b3d63c02b4ebd38e09 (diff)
Fixed bug where no possible rules to apply
-rw-r--r--Thue/Interpreter.hs3
1 files changed, 2 insertions, 1 deletions
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