All sorts of fun stuff...
- stats are now based on a 1-100 ranged and mapped to sensibles - turnspeed and fire rate are available stats - bugs in movement are squished
This commit is contained in:
@@ -16,6 +16,7 @@ type Robot struct {
|
||||
MoveTo *v.Point2d `json:"move_to,omitempty"`
|
||||
FireAt *v.Point2d `json:"fire_at,omitempty"`
|
||||
Scanners []Scanner `json:"scanners"`
|
||||
LastFired int `json:"last_fired"`
|
||||
}
|
||||
|
||||
type RobotSorter struct {
|
||||
@@ -40,11 +41,62 @@ type Stats struct {
|
||||
Acceleration float64 `json:"acceleration"`
|
||||
WeaponRadius int `json:"weapon_radius"`
|
||||
ScannerRadius int `json:"scanner_radius"`
|
||||
TurnSpeed int `json:"turn_speed"`
|
||||
FireRate int `json:"fire_rate"`
|
||||
}
|
||||
|
||||
func (s Stats) Valid() bool {
|
||||
total := int(s.Speed) + s.Hp + s.WeaponRadius + s.ScannerRadius
|
||||
if total > 500 {
|
||||
// We request stats using an integer between 1 and 100, the
|
||||
// integer values map to sensible min-max ranges
|
||||
type StatsRequest struct {
|
||||
Hp int `json:"hp"`
|
||||
Speed int `json:"speed"`
|
||||
Acceleration int `json:"acceleration"`
|
||||
WeaponRadius int `json:"weapon_radius"`
|
||||
ScannerRadius int `json:"scanner_radius"`
|
||||
TurnSpeed int `json:"turn_speed"`
|
||||
FireRate int `json:"fire_rate"`
|
||||
}
|
||||
|
||||
func DeriveStats(request StatsRequest) Stats {
|
||||
s := Stats{}
|
||||
|
||||
// Conversion Tables
|
||||
hp_min := 20.0
|
||||
hp_max := 200.0
|
||||
s.Hp = int(((float64(request.Hp) / 100.0) * (hp_max - hp_min)) + hp_min)
|
||||
|
||||
speed_min := 40.0
|
||||
speed_max := 200.0
|
||||
s.Speed = ((float64(request.Speed) / 100.0) * (speed_max - speed_min)) + speed_min
|
||||
|
||||
accel_min := 20.0
|
||||
accel_max := 200.0
|
||||
s.Acceleration = ((float64(request.Acceleration) / 100.0) * (accel_max - accel_min)) + accel_min
|
||||
|
||||
wep_rad_min := 5.0
|
||||
wep_rad_max := 60.0
|
||||
s.WeaponRadius = int(((float64(request.WeaponRadius) / 100.0) * (wep_rad_max - wep_rad_min)) + wep_rad_min)
|
||||
|
||||
scan_rad_min := 100.0
|
||||
scan_rad_max := 400.0
|
||||
s.ScannerRadius = int(((float64(request.ScannerRadius) / 100.0) * (scan_rad_max - scan_rad_min)) + scan_rad_min)
|
||||
|
||||
turn_spd_min := 30.0
|
||||
turn_spd_max := 300.0
|
||||
s.TurnSpeed = int(((float64(request.TurnSpeed) / 100.0) * (turn_spd_max - turn_spd_min)) + turn_spd_min)
|
||||
|
||||
fire_rate_min := 10.0
|
||||
fire_rate_max := 2000.0
|
||||
s.FireRate = int(fire_rate_max+300.0) - int(((float64(request.FireRate)/100.0)*(fire_rate_max-fire_rate_min))+fire_rate_min)
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
func (s StatsRequest) Valid() bool {
|
||||
total := (s.Speed + s.Hp + s.WeaponRadius +
|
||||
s.ScannerRadius + s.Acceleration + s.TurnSpeed + s.FireRate)
|
||||
|
||||
if total > 350 {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user