This commit is contained in:
Luke Meyers 2020-02-07 22:19:34 -08:00
parent eac373c444
commit e31c585e3a
4 changed files with 23 additions and 17 deletions

View File

@ -40,6 +40,8 @@ func doCommand(cmd command, s State, teamID int) State {
pos := b.Position pos := b.Position
pos.Pos++ pos.Pos++
s = removeObstacle(s, pos) s = removeObstacle(s, pos)
b.v = 0
s = updateBot(s, *b)
} }
if b := ActiveBot(s.Teams[teamID]); b != nil { if b := ActiveBot(s.Teams[teamID]); b != nil {

View File

@ -33,7 +33,7 @@ func maybePassBaton(s State, teamID int) State {
if h.ID >= b.ID || h.Position.Lane != b.Position.Lane { if h.ID >= b.ID || h.Position.Lane != b.Position.Lane {
continue continue
} }
if abs(b.Position.Pos-h.Position.Pos) <= passDistance { if abs(b.Position.Pos-h.Position.Pos) <= PassDistance {
h.v = 0 h.v = 0
h.a = 0 h.a = 0
s = updateBot(s, *h) s = updateBot(s, *h)
@ -259,6 +259,6 @@ var (
const ( const (
Steps = 40 Steps = 40
numBots = 4 numBots = 4
NumTeams = 4 NumTeams = 2
NumLanes = NumTeams NumLanes = NumTeams
) )

View File

@ -1,19 +1,19 @@
package game package game
func accelerate(b Bot) Bot { func accelerate(b Bot) Bot {
if b.a < -maxA { if b.a < -MaxA {
b.a = -maxA b.a = -MaxA
} }
if b.a > maxA { if b.a > MaxA {
b.a = maxA b.a = MaxA
} }
b.v += b.a b.v += b.a
if b.v > maxV { if b.v > MaxV {
b.v = maxV b.v = MaxV
} }
if b.v < -maxV { if b.v < -MaxV {
b.v = -maxV b.v = -MaxV
} }
return b return b
@ -50,7 +50,7 @@ func collide(pos, lane int, s State) interface{} {
const ( const (
baseAccel = 1 baseAccel = 1
maxA = 1 MaxA = 1
maxV = 2 MaxV = 2
passDistance = 2 PassDistance = 2
) )

View File

@ -109,13 +109,17 @@ func teamColors(ts []game.Team) map[*game.Team]pixel.RGBA {
var c color.RGBA var c color.RGBA
switch i { switch i {
case 0: case 0:
c = colornames.Cyan c = colornames.Red
case 1: case 1:
c = colornames.Gold c = colornames.Green
case 2: case 2:
c = colornames.Lavender c = colornames.Blue
case 3: case 3:
c = colornames.Rosybrown c = colornames.Magenta
case 4:
c = colornames.Cyan
case 5:
c = colornames.Yellow
} }
m[&ts[i]] = pixel.ToRGBA(c) m[&ts[i]] = pixel.ToRGBA(c)
} }