fix: generator deadZone overlapping

This commit is contained in:
IliaDenisov
2026-02-06 15:23:41 +03:00
parent 327f2865d4
commit ef10842dac
2 changed files with 4 additions and 10 deletions
+1 -9
View File
@@ -9,7 +9,7 @@ import (
)
func TestGenerator(t *testing.T) {
maxPlayers := 20
maxPlayers := 30
for players := 10; players <= maxPlayers; players++ {
t.Run(fmt.Sprintf("%d_players", players), func(t *testing.T) {
var s generator.MapSetting
@@ -51,14 +51,6 @@ func TestGenerator(t *testing.T) {
if ps.MinDistanceHW > 0 {
for hw := range m.HomePlanets {
d := m.ShortDistance(m.HomePlanets[hw].HW.Position, m.FreePlanets[fp].Position)
// FIXME:
// Error: "20" is not less than or equal to "19.98697122994701"
// Test: TestGenerator/24_players
// Messages: distance: HW[44.4883,136.985727] <-> %!s(generator.PlanetClass=2)[38.9977,156.203728]
//
// Error: "10" is not less than or equal to "9.985592188977868"
// Test: TestGenerator/33_players
// Messages: distance: HW[231.7975,76.996315] <-> planet_class=3[237.7334,85.026044]
assert.LessOrEqualf(t, float64(ps.MinDistanceHW), d, "distance: HW[%.04f,%04f] <-> planet_class=%v[%.04f,%04f]",
m.HomePlanets[hw].HW.Position.X, m.HomePlanets[hw].HW.Position.Y,
m.FreePlanets[fp].PlanetClass,
+3 -1
View File
@@ -61,7 +61,9 @@ func (p Plotter) MarkDeadZone(x, y float64, radius float64) {
}
func (p Plotter) plotDeadZone(x, y int, radius float64) {
p.circleFn(x, y, radius/p.factor)
// Adding extra 'pixel' to avoid radius became less than deadZoneRaduis
// after division by factor due to floating-point operations specifics
p.circleFn(x, y, (radius+p.factor)/p.factor)
}
func (p Plotter) Clear() { p.clearFn() }