ui calculator
This commit is contained in:
@@ -3,10 +3,10 @@ package controller
|
||||
import (
|
||||
"iter"
|
||||
"maps"
|
||||
"math"
|
||||
"math/rand/v2"
|
||||
"slices"
|
||||
|
||||
"galaxy/calc"
|
||||
"galaxy/game/internal/model/game"
|
||||
|
||||
"github.com/google/uuid"
|
||||
@@ -65,7 +65,7 @@ func FilterBattleOpponents(c *Cache, attIdx, defIdx int, cacheProbability map[in
|
||||
return true
|
||||
}
|
||||
|
||||
p := DestructionProbability(
|
||||
p := calc.DestructionProbability(
|
||||
c.ShipGroupShipClass(attIdx).Weapons.F(),
|
||||
c.ShipGroup(attIdx).TechLevel(game.TechWeapons).F(),
|
||||
c.ShipGroupShipClass(defIdx).Shields.F(),
|
||||
@@ -216,16 +216,6 @@ func SingleBattle(c *Cache, b *Battle) {
|
||||
}
|
||||
}
|
||||
|
||||
func DestructionProbability(attWeapons, attWeaponsTech, defShields, defShiledsTech, defFullMass float64) float64 {
|
||||
effAttack := attWeapons * attWeaponsTech
|
||||
effDefence := EffectiveDefence(defShields, defShiledsTech, defFullMass)
|
||||
return (math.Log10(effAttack/effDefence)/math.Log10(4) + 1) / 2
|
||||
}
|
||||
|
||||
func EffectiveDefence(defShields, defShiledsTech, defFullMass float64) float64 {
|
||||
return defShields * defShiledsTech / math.Pow(defFullMass, 1./3.) * math.Pow(30., 1./3.)
|
||||
}
|
||||
|
||||
func randomValue(v iter.Seq[int]) int {
|
||||
ids := slices.Collect(v)
|
||||
return ids[rand.IntN(len(ids))]
|
||||
|
||||
Reference in New Issue
Block a user