Documentation
¶
Index ¶
- type Coordinates
- type Trip
- type Vehicle
- func (v *Vehicle) AddToImd(imd *imdraw.IMDraw)
- func (v *Vehicle) Drive(allTrips []*Trip, step int, bonus int16) (score int)
- func (v *Vehicle) DriveOnTrip(destinationX, destinationY int32)
- func (v *Vehicle) DriveTo(destinationX, destinationY int32)
- func (v *Vehicle) GetPosition() (int32, int32)
- func (v *Vehicle) NextTrip()
- func (v *Vehicle) SetPosition(x, y int32)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Coordinates ¶
type Coordinates struct {
X, Y int32
}
Coordinates export a type that look like coordinates on a map
type Trip ¶
type Trip struct {
// unique identifier for each trip, used for debugging
ID int
// start & end coordinates
Start Coordinates
End Coordinates
// computed distance from Start to End
// helps for score computation
Distance int
// we set there the bonus defined in Config if the
// driver starts its trip on time
Bonus int
// A driver cannot start its trip before EarlierStart step
// And if he finish his drive after LatestFinish the trip will
// be marked as failed
EarliestStart int32
LatestFinish int32
// current color of the trip
Color color.RGBA
// when a driver is going towards the trip
Taken bool
// the vehicle is actually doing it
InProgress bool
// the vehicle end the trip too late
Failed bool
}
Trip a structure which represents a trip in the simulation Quite self-explanatory
func (*Trip) AddToImd ¶
AddToImd adds to the imd batch the graphic line of the trip We only call .draw once for all the trips
func (*Trip) Finish ¶
Finish the vehicle finished the trip at step. we determine if he failed or not to arrive on time a different is assigned if we end it on time or not
func (*Trip) SomeoneIsOnIt ¶
func (t *Trip) SomeoneIsOnIt()
SomeoneIsOnIt we could store the vehicle id for debugging purposes there but atm we only change the trip color and its status
type Vehicle ¶
type Vehicle struct {
// current position of the vehicle
CurrentPosition Coordinates
// Trips an array of trips' indexes
// (and not their ids)
Trips []int32
// index of the current trip in Trips
CurrentTrip int
// if he is currently assigned on a trip
OnRide bool
Enabled bool
}
Vehicle a structure which represents a vehicle in the simulation Quite self-explanatory
func NewVehicle ¶
NewVehicle a constructor for Trip takes its trips as parameters
func (*Vehicle) AddToImd ¶
AddToImd adds to the imd batch the graphic point of the vehicle We only call .draw once for all the vehicles
func (*Vehicle) DriveOnTrip ¶
DriveOnTrip it will make the vehicle follow the line drawn on the screen by the trip
func (*Vehicle) DriveTo ¶
DriveTo destinationX, destinationY coordinates It will make the vehicle move in a straight line to a point
func (*Vehicle) GetPosition ¶
GetPosition getter for CurrentPosition
func (*Vehicle) NextTrip ¶
func (v *Vehicle) NextTrip()
NextTrip move forward next trip or disable the vehicle if there isnt any trips left
func (*Vehicle) SetPosition ¶
SetPosition setter for CurrentPosition