how to model a train system to include track and, to begin with two trains.
at present i have implemented using a vector two train objects fit into
vector at different positions and each has a move method which changes
postion +1 and replaces old position with a "empty block". (when vector
reaches end goes to beginning - creating a circular track) when one train
catches up to another it has to wait. what i want is for a transaction to
occur between trains and maybe control centre that involves train1 telling
train2 to speed up. have not been able to reference get name of train from
vector only that it is a train object - then i want to say train2.speedUp().
is this a fair model. i thought of using two dimensional vector to involve
tracks which intersected.
is there a more obvious model to choose - i have had jxta mentioned to me to
use trains as peers - but have no experience of this.
thanks for any help
mark
Glenn Reynolds - 01 Jun 2005 11:22 GMT
I would set up the trains and the track (and a central controller
representing the switching system) as independent agents
that you add to an application. All comms should be done by event messaging.
Read up on intelligent agents. This seems to offer a lot of flexibility. You
could add trains, monitor communications between trains, etc.
regards
Glenn
> how to model a train system to include track and, to begin with two trains.
> at present i have implemented using a vector two train objects fit into
[quoted text clipped - 14 lines]
> thanks for any help
> mark