Aalk4308/outpost — pull request #13 by Aalk4308 (2014-11-25 02:01:51+00:00)
Title: General infrastructure

I've added some additional infrastructure to facilitate assigning outposts to different strategies, where that assignment persists across ticks.

First, there is now an outpost object class called Outpost. It basically stores information useful to the "general" and in persisting the outpost information across ticks, even though the simulator doesn't. This class isn't yet used in the Board class, but I don't anticipate that would be an issue (let me know if otherwise).

The Player class is the "general" and assigns strategies to outposts. Each strategy class has a run() method that takes a board and the list of outposts the general has assigned to it. For each outpost in that list, the strategy should call setTargetLoc() to say where it wants that outpost to go. If the strategy doesn't want to or can't use an outpost, it should call setStrategy(null) on that outpost, which unassigns the strategy and makes it available for another strategy to use instead.

I've illustrated the basic usage with GetResources and DiagonalStrategy. You'll see that the first 10 outposts are gathering resources, and the rest go diagonal.

Richard, in this commit, I've commented out Consumer so that it compiles. You'll want to replace that with your revised implementation.

Do not call the isUpdated() or setUpdated() methods on an outpost. Those are reserved for the general. (Implementation is slightly hacky, but it's OK for our purposes.)

Each outpost also has a public "memory" field implemented as a HashMap. You should use this as a key/value store to keep any strategy-specific information that you want to recall on the next tick. In the Consumer strategy, I'd expect each outpost would store (a) which Consumer group it's in, and (b) which role it's filling (north, south, east, west). The memory is cleared when an outpost changes strategy.