TOC
- prev
- next
- javadoc tree
A Game is a game of BusRider.
A Game has:
INITIAL_CASH
(40),WINNING_CASH
(500), the amount of cash needed to
win,WEALTHY_CASH
(375), the amount of cash needed to
be Wealthy,SMALL_FARE
(2), the fare for riding on one's own
Routes, or on unowned Routes,LARGE_FARE
(20), the fare for riding on another
player's Routes, andRIGHT_OF_WAY_COST
(60), the cost of purchasing a
Right-of-Way.A Game is represented by the Game class.
A Strategy can see all of the above aspects of a Game, although the players are visible only through PlayerView objects. A Strategy can also query the Game object, to see which player owns a Route.
The BusRider Applet does more than just keep game information. It also conducts the game: sequencing player-turns, updating players, informing Strategies, accepting decisions from Strategies, and providing default choices for Strategies. That aspect of the Applet is called the conductor.
When a Strategy fails to make a choice, the conductor makes the choice on behalf of the Strategy:
The Segment-choosing code is in the Router class, and is listed here. In effect, the conductor finds a least-cost path, assuming that
Admittedly, the assumptions are severe. An optimal router would take into account the distribution of the player's rolls (and therefore his speed), and even the likelyhood that a Route be purchased during the trip. It is therefore a difficult problem of graph theory, statistics, and behavioural analysis. Perhaps the programmer will prefer to forgive the occasional misdirection of the conductor.
A Strategy can see which Segment the conductor would pick by calling the Router's method. (Having done so and accepted the choice, it is more efficient to return that choice, than to return null and make the conductor recalculate.)
TOC
- prev
- next
- javadoc tree