%Select the operation with the highest score :- rule([fire_once], [not( (match(select(_), 1322945958)) ), match(score(Score, Operation), 1322945958), not( (match(score(OtherScore, OtherOperation), 1322945958), OtherScore > Score) )], [delete(score(Score, Operation), 1322945958), add(select(Operation), 1322945958)]). %Push other operations to choice point stack :- rule([fire_once], [match(select(Operation), 1322945958), findall(OtherOp, ( match(OtherOp, 1322945958), select(Operation) \== OtherOp ), OtherOps), OtherOps \== [], match(Stack, 1321298902), match(PreviousWords, 1321291544)], [send(push(cp(Stack, PreviousWords, OtherOps)), 1323031400)]). %When there is only one operation, execute it :- rule([fire_once], [match(select(Operation), 1322945958)], [delete_all(_, 1322945958), add(execute(Operation), 1322945958)]).