nix chooseCommand
This commit is contained in:
parent
9a87e3d349
commit
7fc869a675
29
game/ai.go
29
game/ai.go
|
@ -1,34 +1,5 @@
|
|||
package game
|
||||
|
||||
func chooseCommand(s State, teamID int) command {
|
||||
t := s.Teams[teamID]
|
||||
h := ActiveRacer(t)
|
||||
if collide(h.Position.Pos+1, h.Position.Lane, s) != nil {
|
||||
if h.Position.Lane <= t.Lane && h.Position.Lane < NumLanes-1 {
|
||||
return left
|
||||
}
|
||||
return right
|
||||
}
|
||||
|
||||
var nextRacer *Racer
|
||||
for i, b := range t.Racers {
|
||||
if b.ID == h.ID+1 {
|
||||
nextRacer = &t.Racers[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if nextRacer != nil {
|
||||
if h.Position.Lane != nextRacer.Position.Lane {
|
||||
if abs(nextRacer.Position.Pos-h.Position.Pos) < h.Kinetics.V {
|
||||
return slowDown
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return speedUp
|
||||
}
|
||||
|
||||
func smartChooseCommand(s State, teamID int) command {
|
||||
return smartChooseHelper(s, teamID, 2)
|
||||
}
|
||||
|
|
|
@ -51,6 +51,6 @@ func collide(pos, lane int, s State) interface{} {
|
|||
const (
|
||||
baseAccel = 1
|
||||
MaxA = 1
|
||||
MaxV = 2
|
||||
MaxV = 3
|
||||
PassDistance = 2
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue