feat: support controller's cache
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"maps"
|
||||
"math"
|
||||
"math/rand/v2"
|
||||
"slices"
|
||||
|
||||
@@ -143,13 +142,14 @@ func FilterBattleOpponents(
|
||||
return true
|
||||
}
|
||||
|
||||
p := DestructionProbability(
|
||||
cacheShipClass[attIdx].Weapons,
|
||||
g.ShipGroups[attIdx].TechLevel(TechWeapons),
|
||||
cacheShipClass[defIdx].Shields,
|
||||
g.ShipGroups[defIdx].TechLevel(TechShields),
|
||||
g.ShipGroups[defIdx].FullMass(cacheShipClass[defIdx]),
|
||||
)
|
||||
// p := DestructionProbability(
|
||||
// cacheShipClass[attIdx].Weapons,
|
||||
// g.ShipGroups[attIdx].TechLevel(TechWeapons),
|
||||
// cacheShipClass[defIdx].Shields,
|
||||
// g.ShipGroups[defIdx].TechLevel(TechShields),
|
||||
// g.ShipGroups[defIdx].FullMass(cacheShipClass[defIdx]),
|
||||
// )
|
||||
p := 0.
|
||||
// Exclude opponent's group which cannot be probably destroyed
|
||||
if p <= 0 {
|
||||
return true
|
||||
@@ -288,15 +288,15 @@ func RaceIndex(g *Game, ID uuid.UUID) int {
|
||||
return i
|
||||
}
|
||||
|
||||
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 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 EffectiveDefence(defShields, defShiledsTech, defFullMass float64) float64 {
|
||||
// return defShields * defShiledsTech / math.Pow(defFullMass, 1./3.) * math.Pow(30., 1./3.)
|
||||
// }
|
||||
|
||||
func (b BattleReport) MarshalBinary() (data []byte, err error) {
|
||||
return json.Marshal(&b)
|
||||
|
||||
Reference in New Issue
Block a user