KoboldSim/koboldsim/stats.go

173 lines
7.2 KiB
Go
Raw Normal View History

2023-04-03 06:24:47 +00:00
package koboldsim
import (
"git.chromaticdragon.app/kistaro/CardSimEngine/cardsim"
)
2024-09-27 23:04:17 +00:00
// KoboldMine is the state of a kobold mine.
2023-04-03 06:24:47 +00:00
type KoboldMine struct {
2023-04-05 03:23:32 +00:00
BasePopulation float64 `cardsim:"stathidden"`
2023-04-03 06:24:47 +00:00
2024-09-28 04:56:13 +00:00
Mining float64 `cardsim:"stathidden" cardsim_name:"Mining"`
Scavenging float64 `cardsim:"stathidden" cardsim_name:"Scavenging"`
Alchemy float64 `cardsim:"stathidden" cardsim_name:"Alchemy"`
Hospitality float64 `cardsim:"stathidden" cardsim_name:"Hospitality"`
Agriculture float64 `cardsim:"stathidden" cardsim_name:"Agriculture"`
Manufacturing float64 `cardsim:"stathidden" cardsim_name:"Manufacturing"`
PlanarConnections float64 `cardsim:"stathidden" cardsim_name:"Planar Connections"`
Publishing float64 `cardsim:"stathidden" cardsim_name:"Publishing"`
Forestry float64 `cardsim:"stathidden" cardsim_name:"Forestry"`
Finance float64 `cardsim:"stathidden" cardsim_name:"Finance"`
Gadgetry float64 `cardsim:"stathidden" cardsim_name:"Gadgetry"`
Fishing float64 `cardsim:"stathidden" cardsim_name:"Fishing"`
Construction float64 `cardsim:"stathidden" cardsim_name:"Construction"`
Propaganda float64 `cardsim:"stathidden" cardsim_name:"Propaganda"`
Bureaucracy float64 `cardsim:"stathidden" cardsim_name:"Bureaucracy"`
Militarism float64 `cardsim:"stathidden" cardsim_name:"Militarism"`
Welfare float64 `cardsim:"stathidden" cardsim_name:"Social Safety Net"`
Logistics float64 `cardsim:"stathidden" cardsim_name:"Logistics"`
DragonSubs float64 `cardsim:"stathidden" cardsim_name:"Dragon Subsidies"`
ResearchSubs float64 `cardsim:"stathidden" cardsim_name:"Research"`
Education float64 `cardsim:"stathidden" cardsim_name:"Education"`
Healthcare float64 `cardsim:"stathidden" cardsim_name:"Healthcare"`
ForeignRelExpense float64 `cardsim:"stathidden" cardsim_name:"Diplomatic Investment"`
Police float64 `cardsim:"stathidden" cardsim_name:"Law Enforcement"`
ParksExpense float64 `cardsim:"stathidden" cardsim_name:"City Beautification"`
Faith float64 `cardsim:"stathidden" cardsim_name:"Faith"`
FoodSupply float64 `cardsim:"stathidden"`
ForeignRelations float64 `cardsim:"stathidden"`
HiddenRelPenalty float64 `cardsim:"stathidden"` // Lower is better.
Secrecy float64 `cardsim:"stathidden"`
Rebellion float64 `cardsim:"stathidden"`
Madness float64 `cardsim:"stathidden"`
Cruelty float64 `cardsim:"stat"`
Greed float64 `cardsim:"stat"`
Gullibility float64 `cardsim:"stathidden"`
Authoritarianism float64 `cardsim:"stat"`
Taxation float64 `cardsim:"stat"`
TaxEvasion float64 `cardsim:"stat"`
Squalor float64 `cardsim:"stat"`
// Idea for tax evasion. The corruption stat should increase tax evasion, while the squalor stat should reduce it. The link with corruption should be obvious, but for squalor: when the economy improves, more people have resources with which to attempt to protect their income. This is part of why rich people can evade taxes more effectively than poor people. It's not ALL lobbying advantage.
2023-05-23 18:30:09 +00:00
2023-04-03 06:24:47 +00:00
}
2023-04-05 03:23:32 +00:00
func (k *KoboldMine) Kobolds() int64 {
2024-09-28 04:56:13 +00:00
return int64((k.BasePopulation * (k.Healthcare + 1)) * (k.FoodSupply) * (100 + k.TrueForeignRelations()/100))
2023-04-05 03:23:32 +00:00
}
2024-09-28 04:56:13 +00:00
const (
MinFoodSupply = 18
MaxFoodSupply = 37
)
2023-04-05 03:23:32 +00:00
2024-09-28 04:56:13 +00:00
func (k *KoboldMine) DisplayedFoodSupply() float64 {
return 100 * (k.FoodSupply - MinFoodSupply) / (MaxFoodSupply - MinFoodSupply) //This returns a Policy Implementation Percentage, so that the player can see how good they are at capturing food supply. When it becomes possible for Food Supply to hit 0 and end the game in famine, the minimum survivable food supply PIP should be calculated and returned to the player as a warned-against failure threshold.
2023-04-19 18:37:40 +00:00
}
2024-09-28 04:56:13 +00:00
//func (k *KoboldMine) StatObesity() float64 {
//return (100 / (2.3 + math.Exp(-0.04*(k.DisplayedFoodSupply()-37)))) + 100/(2.3+math.Exp(-0.04*(k.StatObesogenicity()-37)))
//}
func (k *KoboldMine) TrueForeignRelations() float64 {
2024-09-28 04:56:13 +00:00
openness := 100 - clamp(k.Secrecy, 0, 100)
effectiveRel := clamp(k.ForeignRelations, -100, 100) - k.HiddenRelPenalty
return openness / 100 * effectiveRel
}
2024-09-28 04:56:13 +00:00
const (
MinForeignRelations = -11
MaxForeignRelations = 9
)
func (k *KoboldMine) DisplayedForeignRelations() float64 {
2024-09-28 04:56:13 +00:00
return 100 * (k.ForeignRelations - MinForeignRelations) / (MaxForeignRelations - MinForeignRelations)
}
func (k *KoboldMine) DisplayedSecrecy() float64 {
return k.Secrecy * 100
}
// So I want squalor to be a value between 100 and 0 that reduces readily at the start and then becomes increasingly difficult to further reduce. This initial squalor stat starts at about 80%, but may not change rapidly enough. Note that the 1.2-(2* sequence is meant to balance it at 80% starting point. If I change the velocity on the 2* side, I have to change the 1.2 offset as well. I really hope this math works, because I don't quite understand it.
2023-05-14 03:05:07 +00:00
func (k *KoboldMine) StatChaos() float64 {
2023-05-14 03:15:57 +00:00
return Mean(k.Rebellion, k.Madness, k.Cruelty)
2023-05-14 03:05:07 +00:00
}
2023-05-23 18:30:09 +00:00
// This is the "crimes of chaos" stat for my crime calculations. It will also be displayed to the player as just Chaos. The player can see Cruelty, but not Madness or Rebellion. I'm concerned some players may think, "Oh, chaos is a good thing, I want more of that as long as it's not cruel!" In that case, they'll have mad, rebellious colonies that commit crimes against those perceived to be cruel...
func (k *KoboldMine) StatCorruption() float64 {
return Mean(k.Greed, k.Gullibility, k.Authoritarianism)
}
// This is the "crimes of cunning" stat for my crime calculations. It will also be displayed to the player as just Corruption. The player can also see Greed and Authoritarianism, so they should have a good idea what goes into Corruption, but they'll have to infer the importance of Gullibility.
2023-04-03 06:24:47 +00:00
func (k *KoboldMine) Stats() []cardsim.Stat {
stats := cardsim.ExtractStats(k)
funcs := []cardsim.Stat{
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{
2024-09-28 04:56:13 +00:00
BasePopulation: 1025,
Mining: 0,
Scavenging: 0,
Alchemy: 0,
Hospitality: 0,
Agriculture: 0,
Manufacturing: 0,
PlanarConnections: 0,
Publishing: 0,
Forestry: 0,
Finance: 0,
Gadgetry: 0,
Fishing: 0,
Construction: 0,
Propaganda: 0,
Bureaucracy: 0,
Militarism: 0,
Welfare: 0,
Logistics: 0,
DragonSubs: 0,
ResearchSubs: 0,
Education: 0,
Healthcare: 0,
ForeignRelExpense: 0,
Police: 0,
ParksExpense: 0,
Faith: 0,
FoodSupply: 20,
ForeignRelations: 0,
HiddenRelPenalty: 0,
Rebellion: 0,
Madness: 0,
Cruelty: 0,
Greed: 0,
Gullibility: 0,
Authoritarianism: 0,
Secrecy: 95,
2023-04-03 06:24:47 +00:00
}
}