ghashcode

package
v0.0.0-...-7d6df93 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2018 License: GPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

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 NewTrip

func NewTrip(id int, a, b, x, y, s, f int32) *Trip

NewTrip a constructor for Trip

func (*Trip) AddToImd

func (t *Trip) AddToImd(imd *imdraw.IMDraw)

AddToImd adds to the imd batch the graphic line of the trip We only call .draw once for all the trips

func (*Trip) Finish

func (t *Trip) Finish(step int32) int

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) SetEnd

func (t *Trip) SetEnd(x, y int32)

SetEnd setter for StartCoordinates

func (*Trip) SetStart

func (t *Trip) SetStart(x, y int32)

SetStart setter for StartCoordinates

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

func (*Trip) StartTrip

func (t *Trip) StartTrip(step int, bonus int16)

StartTrip takes the current step as parameter if we start it on time we earn the bonus points a different color is assigned if we start it on time or not

func (*Trip) WarnEarly

func (t *Trip) WarnEarly()

WarnEarly it changes only the trip color to warn graphically that a vehicle is too early on a trip We can see that way that some drivers are waiting way too long

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

func NewVehicle(trips []int32) *Vehicle

NewVehicle a constructor for Trip takes its trips as parameters

func (*Vehicle) AddToImd

func (v *Vehicle) AddToImd(imd *imdraw.IMDraw)

AddToImd adds to the imd batch the graphic point of the vehicle We only call .draw once for all the vehicles

func (*Vehicle) Drive

func (v *Vehicle) Drive(allTrips []*Trip, step int, bonus int16) (score int)

func (*Vehicle) DriveOnTrip

func (v *Vehicle) DriveOnTrip(destinationX, destinationY int32)

DriveOnTrip it will make the vehicle follow the line drawn on the screen by the trip

func (*Vehicle) DriveTo

func (v *Vehicle) DriveTo(destinationX, destinationY int32)

DriveTo destinationX, destinationY coordinates It will make the vehicle move in a straight line to a point

func (*Vehicle) GetPosition

func (v *Vehicle) GetPosition() (int32, int32)

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

func (v *Vehicle) SetPosition(x, y int32)

SetPosition setter for CurrentPosition

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL