These are only extreme examples of how to make and compare alternative plans, but they illustrate the same sort of process that we all go through, when simply contemplating the leftovers in the refrigerator, trying to figure out a combination that will avoid another trip to the grocery store. Many animals look ahead in a limited way, predicting when winter is coming. It's a novel course of action, one that neither you nor any of your ancestors have done before, that is the difficult problem. And not even that is hard, if you have the time to grope around. A goal, and some feedback about progress, suffices for many novel situations.
Humans can simulate future courses of action and weed out the nonsense off-line.
By borrowing the mental structures for syntax to judge other combinations of possible actions, we can extend our plan-ahead abilities and our intelligence. To some extent, this is done by talking silently to ourselves, making narratives out of what might happen next, and then applying syntax-like rules of combination to rate a candidate scenario as dangerous nonsense, mere nonsense, possible, likely, or logical. We create sequences when we speak a sentence that we've never spoken before, or improvise at jazz, or plan a career. We invent dance steps. Preschool children will even make up such arbitrary rules, and then judge possible actions against them.