use float64
This commit is contained in:
@@ -22,7 +22,7 @@ func Generate(cfg ...func(*MapSetting)) (Map, error) {
|
||||
freePlanets := ms.NobodysPlanets()
|
||||
|
||||
createPlanets := func(ps PlanetSetting) error {
|
||||
return m.CreatePlanets(ps.Count(freePlanets), float32(ps.MinDistanceHW), RandIFn(ps.MinSize, ps.MaxSize), RandIFn(ps.MinResource, ps.MaxResource))
|
||||
return m.CreatePlanets(ps.Count(freePlanets), float64(ps.MinDistanceHW), RandIFn(ps.MinSize, ps.MaxSize), RandIFn(ps.MinResource, ps.MaxResource))
|
||||
}
|
||||
|
||||
// 1. Place Giant planets
|
||||
@@ -37,18 +37,18 @@ func Generate(cfg ...func(*MapSetting)) (Map, error) {
|
||||
|
||||
// 3. Place players' Home Worlds
|
||||
for player := 0; player < int(ms.Players); player++ {
|
||||
coord, err := m.NewCoordinate(float32(ms.HWMinDistance))
|
||||
coord, err := m.NewCoordinate(float64(ms.HWMinDistance))
|
||||
if err != nil {
|
||||
return Map{}, fmt.Errorf("%s: hw new_coordinate: %s", ms, err)
|
||||
}
|
||||
planet := NewPlanet(coord, float32(ms.HWSize), float32(ms.HWResources))
|
||||
planet := NewPlanet(coord, float64(ms.HWSize), float64(ms.HWResources))
|
||||
m.HomePlanets[player] = PlanetarySystem{HW: planet, DW: make([]Planet, ms.DWCount)}
|
||||
for dw := 0; dw < int(ms.DWCount); dw++ {
|
||||
p := rand.Float64()*(float64(ms.DWMaxDistance)-float64(ms.DWMinDistance)) + float64(ms.DWMinDistance)
|
||||
phi := rand.Float64() * 360
|
||||
x := float32(p * math.Cos(phi))
|
||||
y := float32(p * math.Sin(phi))
|
||||
dwPlanet := NewPlanet(Coordinate{x, y}, float32(ms.DWSize), float32(ms.DWResources))
|
||||
x := p * math.Cos(phi)
|
||||
y := p * math.Sin(phi)
|
||||
dwPlanet := NewPlanet(Coordinate{x, y}, float64(ms.DWSize), float64(ms.DWResources))
|
||||
m.HomePlanets[player].DW[dw] = dwPlanet
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user