Santa always leaves plans for his elves to determine the order in which the reindeer will pull his sleigh. This year, for the European leg of his journey, his elves are working to the following schedule, which will form a single line of nine reindeer
Create a rule model that determines the order of the reindeer.
The 12 statements above are effectively the rules that solve the problem.
The challenge is to find a way to represent them in Corticon such that we can use the power of Corticon’s inferencing to continue working until all the reindeer are in the correct order.
The basic idea is to assign a sequence number to each reindeer (initially one).
Then compare reindeer (two at a time) and use the rules to adjust that sequence number whenever reindeer are found to out of order. Because modifying a reindeer’s sequence number may cause that reindeer to break other rules we’ll need to repeat the process of applying the rules until no more changes are made to the sequence numbers. Then we will have a solution. This means we will need to make the rule sheet iterate. This is done by drawing the rule flow diagram and marking the rule sheet with the iterate symbol:
By specifying two aliases to the entity Reindeer Corticon will automatically try every possible combination of two reindeer from the set of reindeer that is passed in as the data payload.
The rules then modify the sequence number of one of the reindeer if it is found to break the rules.
This process repeats until no more rules fire (i.e. no reindeer are out of sequence)
Note that it’s the value of the attribute called order that determines the sequence. The reindeer are not displayed in the tester in order. But the tester automatically compares the attributes of the reindeer and if there were any differences they would be highlighted in red.
If we apply the Corticon compression feature to the rule sheet we’ll see that Corticon is able to express the same logic in fewer rules. 10 rules instead of 15.
Rules 2, 4 and 14 can be merged since they all apply to cupid
Rules 6, 10 and 11 can be merged since the all apply to prancer.
Rules 5 and 13 can be merged since they all apply to donder.