Simple soft constraints
The first system I'll look at is a simple soft constraint I have been working on in code: "Character, Move (NearBackOf Building) To Goal)." We have a single effector, the "Back" annotation on the Building:
The multiplier is defined based on the distance to the closest point on the constraint annotation (as seen in the contour map above):
None of the functions I've tried have shown obvious advantages over others, but see the section on field addition for some considerations.
Other simple soft constraints
Many other soft constraints can be formulated in a similar way:
Multiplier field addition
Since a multiplier field is a simple scalar field, we can also add them together, allowing for multiple constraints as well as using goals as field effectors. (Note that the rule for constant fields, from the previous post, still holds under addition; however, adding a constant to a multiplier field will not result in the same minimized path.)
It should be noted that, when using addition, it is important to consider it when choosing a function $M(d)$ for weighting: if one function chosen rises too quickly, then it will quickly drown out any others, meaning we may want to choose a function that emulates electric/gravitational fields (i.e. $U \propto r^{-1}$).
Inverted constraints
Constraints such as "away from" are simply an inverted "near" constraint. This raises some minor difficulties, but the idea is the same. Since we must avoid negative weights (so that the search algorithm works correctly), it is necessary to, for example, effectively add a constant to the multiplier field. As seen before, this does not maintain the minimized path, but it does provide for some room for smaller multipliers.
Annotations as goals
Another benefit of having the annotations on objects is that it gives us flexibility with goals. Some of the goals listed in the tactical grammar specification are very similar to the constraints: to, near, away, between, behind, inside, outside.
Limitations of annotations
While annotations are a flexible approach, they have some important limitations. In particular, there are a lot of states that are probably much easier to compute on the fly: between, behind (relative to some third party), etc.



No comments:
Post a Comment