generator: verified
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
package generator
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
)
|
||||
|
||||
const defaultFactor float32 = 0.1
|
||||
|
||||
type MapSetting struct {
|
||||
Players uint32
|
||||
HWSize uint32
|
||||
@@ -11,11 +18,28 @@ type MapSetting struct {
|
||||
DWMinDistance uint32
|
||||
DWMaxDistance uint32
|
||||
|
||||
GiantPlanets PlanetSetting
|
||||
BigPlanets PlanetSetting
|
||||
NormalPlanets PlanetSetting
|
||||
RichPlanets PlanetSetting
|
||||
Asterioids PlanetSetting
|
||||
GiantPlanets PlanetSetting
|
||||
BigPlanets PlanetSetting
|
||||
OthersMinDistance float32
|
||||
NormalPlanets PlanetSetting
|
||||
RichPlanets PlanetSetting
|
||||
Asterioids PlanetSetting
|
||||
}
|
||||
|
||||
func (ms MapSetting) String() string {
|
||||
return fmt.Sprintf("MapSetting[players=%d HWMinDistance=%d Size=%d]", ms.Players, ms.HWMinDistance, ms.ExpectedSize())
|
||||
}
|
||||
|
||||
func (ms MapSetting) ExpectedSize() uint32 {
|
||||
return uint32(math.Sqrt(float64(ms.Players)) * float64(ms.HWMinDistance) * 1.4)
|
||||
}
|
||||
|
||||
func (ms MapSetting) TotalPlanets() uint32 {
|
||||
return ms.Players * 10
|
||||
}
|
||||
|
||||
func (ms MapSetting) NobodysPlanets() uint32 {
|
||||
return ms.TotalPlanets() - ms.Players*(ms.DWCount+1)
|
||||
}
|
||||
|
||||
type PlanetSetting struct {
|
||||
@@ -27,6 +51,10 @@ type PlanetSetting struct {
|
||||
Probability float32
|
||||
}
|
||||
|
||||
func (ps PlanetSetting) Count(freePlanets uint32) int {
|
||||
return int(math.Ceil(float64(freePlanets) * float64(ps.Probability)))
|
||||
}
|
||||
|
||||
func DefaultMapSetting() MapSetting {
|
||||
return MapSetting{
|
||||
Players: 25,
|
||||
@@ -54,9 +82,10 @@ func DefaultMapSetting() MapSetting {
|
||||
MaxResource: 10,
|
||||
Probability: 0.18,
|
||||
},
|
||||
OthersMinDistance: defaultFactor, // minimal of 1 pixel on the plotter
|
||||
NormalPlanets: PlanetSetting{
|
||||
MinDistanceHW: 0,
|
||||
MinSize: 0.001,
|
||||
MinSize: 0,
|
||||
MaxSize: 1000,
|
||||
MinResource: 0,
|
||||
MaxResource: 10,
|
||||
@@ -64,7 +93,7 @@ func DefaultMapSetting() MapSetting {
|
||||
},
|
||||
RichPlanets: PlanetSetting{
|
||||
MinDistanceHW: 0,
|
||||
MinSize: 0.001,
|
||||
MinSize: 0,
|
||||
MaxSize: 500,
|
||||
MinResource: 5,
|
||||
MaxResource: 25,
|
||||
@@ -72,8 +101,8 @@ func DefaultMapSetting() MapSetting {
|
||||
},
|
||||
Asterioids: PlanetSetting{
|
||||
MinDistanceHW: 0,
|
||||
MinSize: 0.001,
|
||||
MaxSize: 10,
|
||||
MinSize: 0,
|
||||
MaxSize: 0,
|
||||
MinResource: 0,
|
||||
MaxResource: 0,
|
||||
Probability: 0.08,
|
||||
|
||||
Reference in New Issue
Block a user