summaryrefslogtreecommitdiff
path: root/Thue
diff options
context:
space:
mode:
Diffstat (limited to 'Thue')
-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