ruby-diplomacy/rails-diplomacy — Issue #17: Take care of loops and implement backup rule
Author: TheNamelessOne
Created: 2011-12-24 00:49:30+00:00
State: open
Labels: adjudicator

There are many edge cases where endless order dependency loops arise. We need to detect these and pass them to a backup rule.

The idea is to keep a path of dependencies as we go down orders' dependencies. When a dependency is found, add it to the list. When it is resolved, remove it from the list. If we had a tree of order dependencies, this list would represent, for each order, its current path to a 'root' (an order chosen to be resolved that led to the current order via dependencies). It is sufficient to determine whether each new order is already on this list, to detect endless loops.