Data Structures and Interfaces

The currentStates member is a list of StateAndDom instances. In addition to its normal liststyle operations (i.e., iteration, removal of an element, testing for membership, addition of an element), it supports two operations specific for this algorithm.

The sortByDecreasingDOM method returns a copy of the list sorted in order of decreasing DOM values. It does not make copies of any of the StateAndDom instances in the list. We need a copy, since we’ll be making changes to the original while we iterate through its contents. This can cause problems or infinite loops (although no infinite loops will be caused in this algorithm), so it is to be avoided as good programming practice.

The get method looks up a StateAndDom ...

Get AI for Games, Third Edition, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.