Skip to content

Commit

Permalink
Fix production/h formulas
Browse files Browse the repository at this point in the history
  • Loading branch information
alaingilbert committed Sep 21, 2018
1 parent 73dd61c commit 0be1f50
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 14 deletions.
4 changes: 2 additions & 2 deletions crystalMine.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ func (b *crystalMine) EnergyConsumption(level int) int {
}

// Production returns the crystal production of the mine
func (b *crystalMine) Production(universeSpeed int, productionRatio float64, level int) int {
func (b *crystalMine) Production(universeSpeed int, productionRatio float64, plasmaTech, level int) int {
basicIncome := 15.0
levelProduction := 20 * float64(level) * math.Pow(1.1, float64(level)) * float64(universeSpeed)
levelProduction := 20 * float64(universeSpeed) * (1 + float64(plasmaTech)*0.0066) * float64(level) * math.Pow(1.1, float64(level))
production := int(levelProduction*productionRatio + (basicIncome * float64(universeSpeed)))
return production
}
10 changes: 10 additions & 0 deletions crystalMine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,13 @@ func TestCrystalMineConstructionTime(t *testing.T) {
cm := newCrystalMine()
assert.Equal(t, 75*time.Second, cm.ConstructionTime(5, 6, Facilities{}))
}

func TestCrystalMine_EnergyConsumption(t *testing.T) {
cm := newCrystalMine()
assert.Equal(t, 736, cm.EnergyConsumption(16))
}

func TestCrystalMine_Production(t *testing.T) {
cm := newCrystalMine()
assert.Equal(t, 37921+1752+105, cm.Production(7, 1, 7, 25))
}
4 changes: 2 additions & 2 deletions deuteriumSynthesizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ func (b *deuteriumSynthesizer) EnergyConsumption(level int) int {
}

// Production returns the deuterium production of the mine
func (b *deuteriumSynthesizer) Production(universeSpeed, maxTemp int, productionRatio float64, level int) int {
return int(math.Round(10 * float64(level) * math.Pow(1.1, float64(level)) * (1.44 - 0.004*float64(maxTemp)) * float64(universeSpeed) * productionRatio))
func (b *deuteriumSynthesizer) Production(universeSpeed, avgTemp int, productionRatio float64, level int) int {
return int(math.Round(10 * float64(level) * math.Pow(1.1, float64(level)) * (-0.004*float64(avgTemp) + 1.36) * float64(universeSpeed) * productionRatio))
}
10 changes: 10 additions & 0 deletions deuteriumSynthesizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,13 @@ func TestDeuteriumSynthesizerConstructionTime(t *testing.T) {
ds := newDeuteriumSynthesizer()
assert.Equal(t, 1845*time.Second, ds.ConstructionTime(9, 6, Facilities{}))
}

func TestDeuteriumSynthesizer_Production(t *testing.T) {
ds := newDeuteriumSynthesizer()
assert.Equal(t, 29760, ds.Production(7, (-23+17)/2, 1, 26))
}

func TestDeuteriumSynthesizer_EnergyConsumption(t *testing.T) {
ds := newDeuteriumSynthesizer()
assert.Equal(t, 6198, ds.EnergyConsumption(26))
}
6 changes: 3 additions & 3 deletions metalMine.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ func (b *metalMine) EnergyConsumption(level int) int {
}

// Production returns the metal production of the mine
func (b *metalMine) Production(universeSpeed int, productionRatio float64, level int) int {
func (b *metalMine) Production(universeSpeed int, productionRatio float64, plasmaTech, level int) int {
basicIncome := 30.0 * float64(universeSpeed)
levelProduction := basicIncome * float64(level) * math.Pow(1.1, float64(level))
production := int(levelProduction*productionRatio + basicIncome)
levelProduction := 30.0 * (1.0 + (float64(plasmaTech) / 100.0)) * float64(universeSpeed) * float64(level) * math.Pow(1.1, float64(level))
production := int((levelProduction * productionRatio) + basicIncome)
return production
}
14 changes: 10 additions & 4 deletions metalMine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (

func TestMetalMineProduction(t *testing.T) {
mm := newMetalMine()
assert.Equal(t, 30, mm.Production(1, 1, 0))
assert.Equal(t, 63, mm.Production(1, 1, 1))
assert.Equal(t, 120, mm.Production(4, 1, 0))
assert.Equal(t, 252, mm.Production(4, 1, 1))
assert.Equal(t, 30, mm.Production(1, 1, 0, 0))
assert.Equal(t, 63, mm.Production(1, 1, 0, 1))
assert.Equal(t, 120, mm.Production(4, 1, 0, 0))
assert.Equal(t, 252, mm.Production(4, 1, 0, 1))
assert.Equal(t, 96606+6762+210, mm.Production(7, 1, 7, 29))
}

func TestMetalMineConstructionTime(t *testing.T) {
Expand All @@ -26,3 +27,8 @@ func TestMetalMine_GetLevel(t *testing.T) {
assert.Equal(t, 0, mm.GetLevel(ResourcesBuildings{}, Facilities{}, Researches{}))
assert.Equal(t, 3, mm.GetLevel(ResourcesBuildings{MetalMine: 3}, Facilities{}, Researches{}))
}

func TestMetalMine_EnergyConsumption(t *testing.T) {
mm := newMetalMine()
assert.Equal(t, 4601, mm.EnergyConsumption(29))
}
6 changes: 3 additions & 3 deletions ogame.go
Original file line number Diff line number Diff line change
Expand Up @@ -2797,9 +2797,9 @@ func getProductions(resBuildings ResourcesBuildings, resSettings ResourceSetting
energyProduced := energyProduced(temp, resBuildings, resSettings, researches.EnergyTechnology, resBuildings.SolarSatellite)
energyNeeded := energyNeeded(resBuildings, resSettings)
return Resources{
Metal: MetalMine.Production(universeSpeed, productionRatio, resBuildings.MetalMine),
Crystal: CrystalMine.Production(universeSpeed, productionRatio, resBuildings.CrystalMine),
Deuterium: DeuteriumSynthesizer.Production(universeSpeed, temp.Max, productionRatio, resBuildings.DeuteriumSynthesizer),
Metal: MetalMine.Production(universeSpeed, productionRatio, researches.PlasmaTechnology, resBuildings.MetalMine),
Crystal: CrystalMine.Production(universeSpeed, productionRatio, researches.PlasmaTechnology, resBuildings.CrystalMine),
Deuterium: DeuteriumSynthesizer.Production(universeSpeed, temp.Mean(), productionRatio, resBuildings.DeuteriumSynthesizer),
Energy: energyProduced - energyNeeded,
}
}
Expand Down

0 comments on commit 0be1f50

Please sign in to comment.