KoboldSim/koboldsim/stats.go

274 lines
8.5 KiB
Go
Raw Normal View History

2023-04-03 06:24:47 +00:00
package koboldsim
import (
"math"
2023-04-03 06:24:47 +00:00
"git.chromaticdragon.app/kistaro/CardSimEngine/cardsim"
)
// KoboldMine is the state of a kobold mine.
type KoboldMine struct {
2023-04-05 03:23:32 +00:00
BasePopulation float64 `cardsim:"stathidden"`
2023-04-03 06:24:47 +00:00
MiningIncome float64 `cardsim:"stat" cardsim_name:"Mining Productivity"`
ScavengingIncome float64 `cardsim:"stat" cardsim_name:"Scavenging Productivity"`
AlchemyIncome float64 `cardsim:"stat" cardsim_name:"Alchemy Productivity"`
HospitalityIncome float64 `cardsim:"stat" cardsim_name:"Hospitality Productivity"`
AgricultureIncome float64 `cardsim:"stat" cardsim_name:"Agriculture Productivity"`
ManufacturingIncome float64 `cardsim:"stat" cardsim_name:"Manufacturing Productivity"`
PlanarIncome float64 `cardsim:"stat" cardsim_name:"Planar Productivity"`
PublishingIncome float64 `cardsim:"stat" cardsim_name:"Publishing Productivity"`
ForestryIncome float64 `cardsim:"stat" cardsim_name:"Forestry Productivity"`
FinanceIncome float64 `cardsim:"stat" cardsim_name:"Finance Productivity"`
GadgetryIncome float64 `cardsim:"stat" cardsim_name:"Gadgetry Productivity"`
FishingIncome float64 `cardsim:"stat" cardsim_name:"Fishing Productivity"`
ConstructionIncome float64 `cardsim:"stat" cardsim_name:"Construction Productivity"`
2023-04-03 06:24:47 +00:00
2023-04-05 03:23:32 +00:00
PropagandaExpense float64 `cardsim:"stat" cardsim_name:"Propaganda Investment"`
BureaucracyExpense float64 `cardsim:"stat" cardsim_name:"Bureaucracy Investment"`
WarExpense float64 `cardsim:"stat" cardsim_name:"War Investment"`
QoLExpense float64 `cardsim:"stat" cardsim_name:"QoL Investment"`
LogisticsExpense float64 `cardsim:"stat" cardsim_name:"Logistics Investment"`
DragonSubsExpense float64 `cardsim:"stat" cardsim_name:"Dragon Subsidies Investment"`
ResearchSubsExpense float64 `cardsim:"stat" cardsim_name:"Research Subsidies Investment"`
EducationExpense float64 `cardsim:"stat" cardsim_name:"Education Investment"`
HealthcareExpense float64 `cardsim:"stat" cardsim_name:"Healthcare Investment"`
ForeignRelExpense float64 `cardsim:"stat" cardsim_name:"Foreign Relations Investment"`
PoliceExpense float64 `cardsim:"stat" cardsim_name:"Law Enforcement Investment"`
EconPlanExpense float64 `cardsim:"stat" cardsim_name:"Economic Planning Investment"`
ParksExpense float64 `cardsim:"stat" cardsim_name:"Parks and Aesthetics Investment"`
FaithExpense float64 `cardsim:"stat" cardsim_name:"Faith Investment"`
FoodSupply float64 `cardsim:"stathidden"`
ForeignRelations float64 `cardsim:"stathidden"`
HiddenRelPenalty float64 `cardsim:"stathidden"`
Secrecy float64 `cardsim:"stathidden"`
2023-04-05 03:23:32 +00:00
// AnotherExpense float64 `cardsim:"hiddenround5"`
// A different way of adding stats that is slightly more empowering.
2023-04-03 06:24:47 +00:00
}
func (k *KoboldMine) ProductivityFunc(s *float64) func() float64 {
2023-04-03 06:24:47 +00:00
return func() float64 {
2023-04-05 03:23:32 +00:00
return *s * float64(k.BasePopulation)
2023-04-03 06:24:47 +00:00
}
}
2023-04-03 23:18:26 +00:00
func (k *KoboldMine) TotalSectorIncome() float64 {
2023-04-05 03:23:32 +00:00
return float64(k.Kobolds()) * (k.MiningIncome + k.ScavengingIncome + k.AlchemyIncome + k.HospitalityIncome + k.AgricultureIncome + k.ManufacturingIncome + k.PlanarIncome + k.PublishingIncome + k.FinanceIncome + k.GadgetryIncome + k.FishingIncome + k.ConstructionIncome)
2023-04-03 06:24:47 +00:00
}
2023-04-03 23:18:26 +00:00
func (k *KoboldMine) TotalGovExpense() float64 {
2023-04-05 07:09:12 +00:00
return float64(k.Kobolds()) * (k.PropagandaExpense + k.BureaucracyExpense + k.WarExpense + k.QoLExpense + k.LogisticsExpense + k.DragonSubsExpense + k.ResearchSubsExpense + k.EducationExpense + k.HealthcareExpense + k.ForeignRelExpense + k.PoliceExpense + k.EconPlanExpense + k.ParksExpense + k.FaithExpense)
}
func (k *KoboldMine) Taxation() float64 {
return (k.TotalGovExpense() / (k.TotalSectorIncome() + k.TotalGovExpense())) * 100
}
func (k *KoboldMine) StatTaxRate() float64 {
return k.Taxation()
2023-04-03 06:24:47 +00:00
}
2023-04-05 03:23:32 +00:00
func (k *KoboldMine) Kobolds() int64 {
return int64(k.BasePopulation * k.FoodSupply * (1 - 0.5*(k.StatObesity()/100)) * (1 + k.TrueForeignRelations()))
2023-04-05 03:23:32 +00:00
}
func (k *KoboldMine) DisplayedFoodSupply() float64 {
return (k.FoodSupply - 1) * 100
}
func (k *KoboldMine) StatObesity() float64 {
return 100 / (2.3 + math.Exp(-0.04*(k.DisplayedFoodSupply()-37)))
}
func (k *KoboldMine) TrueForeignRelations() float64 {
return (1 - math.Max(math.Min(k.Secrecy, 1), 0)) * (math.Max(math.Min(k.ForeignRelations, 1), -1) - k.HiddenRelPenalty)
}
func (k *KoboldMine) DisplayedForeignRelations() float64 {
return math.Max(math.Min((k.ForeignRelations*100), 100), -100)
}
func (k *KoboldMine) DisplayedSecrecy() float64 {
return k.Secrecy * 100
}
2023-04-03 06:24:47 +00:00
func (k *KoboldMine) Stats() []cardsim.Stat {
stats := cardsim.ExtractStats(k)
funcs := []cardsim.Stat{
cardsim.StatFunc(
"Mining Income",
k.ProductivityFunc(&k.MiningIncome),
2023-04-03 06:24:47 +00:00
),
cardsim.StatFunc(
"Scavenging Income",
k.ProductivityFunc(&k.ScavengingIncome),
2023-04-03 06:24:47 +00:00
),
cardsim.StatFunc(
"Alchemy Income",
k.ProductivityFunc(&k.AlchemyIncome),
2023-04-03 06:24:47 +00:00
),
cardsim.StatFunc(
"Hospitality Income",
k.ProductivityFunc(&k.HospitalityIncome),
),
cardsim.StatFunc(
"Agriculture Income",
k.ProductivityFunc(&k.AgricultureIncome),
),
cardsim.StatFunc(
"Manufacturing Income",
k.ProductivityFunc(&k.ManufacturingIncome),
),
cardsim.StatFunc(
"Planar Harvesting Income",
k.ProductivityFunc(&k.PlanarIncome),
),
cardsim.StatFunc(
"Book Publishing Income",
k.ProductivityFunc(&k.PublishingIncome),
),
cardsim.StatFunc(
"Forestry Income",
k.ProductivityFunc(&k.ForestryIncome),
),
cardsim.StatFunc(
"Finance Income",
k.ProductivityFunc(&k.FinanceIncome),
),
cardsim.StatFunc(
"Gadgetry Income",
k.ProductivityFunc(&k.GadgetryIncome),
),
cardsim.StatFunc(
"Fishing Income",
k.ProductivityFunc(&k.FishingIncome),
),
cardsim.StatFunc(
"Construction Income",
k.ProductivityFunc(&k.ConstructionIncome),
),
2023-04-05 07:09:12 +00:00
cardsim.StatFunc(
"Propaganda Expense",
k.ProductivityFunc(&k.PropagandaExpense),
),
cardsim.StatFunc(
"Bureaucracy Expense",
k.ProductivityFunc(&k.BureaucracyExpense),
),
cardsim.StatFunc(
"War Expense",
k.ProductivityFunc(&k.WarExpense),
),
cardsim.StatFunc(
"QoL Expense",
k.ProductivityFunc(&k.QoLExpense),
),
cardsim.StatFunc(
"Logistics Expense",
k.ProductivityFunc(&k.LogisticsExpense),
),
cardsim.StatFunc(
"Dragon Subsidies",
k.ProductivityFunc(&k.DragonSubsExpense),
),
cardsim.StatFunc(
"Research Subsidies",
k.ProductivityFunc(&k.ResearchSubsExpense),
),
cardsim.StatFunc(
"Education Expense",
k.ProductivityFunc(&k.EducationExpense),
),
cardsim.StatFunc(
"Healthcare Expense",
k.ProductivityFunc(&k.HealthcareExpense),
),
cardsim.StatFunc(
"Foreign Relations Expense",
k.ProductivityFunc(&k.ForeignRelExpense),
),
cardsim.StatFunc(
"Law Enforcement Expense",
k.ProductivityFunc(&k.PoliceExpense),
),
cardsim.StatFunc(
"Economic Planning Expense",
k.ProductivityFunc(&k.EconPlanExpense),
),
cardsim.StatFunc(
"Parks and Aesthetics Expense",
k.ProductivityFunc(&k.ParksExpense),
),
cardsim.StatFunc(
"Faith Expense",
k.ProductivityFunc(&k.FaithExpense),
2023-04-03 06:24:47 +00:00
),
cardsim.StatFunc(
"Total Sector Income",
2023-04-03 23:18:26 +00:00
k.TotalSectorIncome,
2023-04-03 06:24:47 +00:00
),
cardsim.StatFunc(
"Total Government Expense",
2023-04-03 23:18:26 +00:00
k.TotalGovExpense,
2023-04-03 06:24:47 +00:00
),
cardsim.StatFunc(
"Foreign Relations",
k.DisplayedForeignRelations,
),
cardsim.StatFunc(
"Secrecy",
k.DisplayedSecrecy,
),
2023-04-05 03:23:32 +00:00
cardsim.StatFunc(
"Food Supply",
k.DisplayedFoodSupply,
),
cardsim.StatFunc(
"Kobolds",
k.Kobolds,
),
2023-04-03 06:24:47 +00:00
}
stats = append(stats, funcs...)
// cardsim.SortStats(stats)
2023-04-03 06:24:47 +00:00
return stats
}
func NewKoboldMine() *KoboldMine {
return &KoboldMine{
BasePopulation: 1030,
MiningIncome: 0.15,
ScavengingIncome: 0.1,
AlchemyIncome: 0.01,
HospitalityIncome: 0.0,
AgricultureIncome: 0.0,
ManufacturingIncome: 0.10,
PlanarIncome: 0.00,
PublishingIncome: 0.02,
ForestryIncome: 0.0,
FinanceIncome: 0.02,
GadgetryIncome: 0.03,
FishingIncome: 0.0,
ConstructionIncome: 0.05,
2023-04-05 07:09:12 +00:00
PropagandaExpense: 0.01,
BureaucracyExpense: 0.05,
WarExpense: 0.1,
QoLExpense: 0.01,
LogisticsExpense: 0.02,
DragonSubsExpense: 0.0,
ResearchSubsExpense: 0.0,
EducationExpense: 0.01,
HealthcareExpense: 0.01,
ForeignRelExpense: 0.0,
PoliceExpense: 0.03,
EconPlanExpense: 0.02,
ParksExpense: 0.0,
FaithExpense: 0.03,
2023-04-05 03:23:32 +00:00
FoodSupply: 0.20,
ForeignRelations: -0.40,
HiddenRelPenalty: -0.01,
Secrecy: .95,
2023-04-03 06:24:47 +00:00
}
}