simvillage

package
v0.0.0-...-ce97658 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2024 License: Apache-2.0 Imports: 9 Imported by: 1

README

simvillage: Village simulation

This package is a port of the wonderful village simulator by Kontari. See: https://github.com/Kontari/Village/ Since I ported it straight from Python to Go, it is quite chaotic and probably would benefit from a refactor.

Documentation

Overview

Package simvillage is a port of the wonderful village simulator by Kontari. See: https://github.com/Kontari/Village/

Index

Constants

View Source
const (
	AgeInfant     = "Infant"
	AgeChild      = "Child"
	AgeYoungAdult = "Young Adult"
	AgeAdult      = "Adult"
	AgeOldPerson  = "Old Person"
	AgeElder      = "Elder"
)
View Source
const (
	SeasonWinter = "Winter"
	SeasonSpring = "Spring"
	SeasonSummer = "Summer"
	SeasonFall   = "Fall"
)
View Source
const (
	VERSION = 1.1
	VERBOSE = true

	// Tier 0 -- World events
	// Tier 1 -- Character information
	// Tier 2 -- Daily happenings
	// Tier 3 -- Details
	// Tier 4 -- Math details
	// Tier 5 -- Everything
	LOGGING_VERBOSITY = 3

	// How many villagers to start with,
	// cannot select less than 8
	// Default: 10
	STARTING_POP = 4

	// FRIENDLY_CHANCE
	// Controls how likely neutral villagers will respond
	// positively to interactions
	// Default: 0.6
	// Range: 0.0 - 1.0
	FRIENDLY_CHANCE = 0.6

	// How often settlers will arrive
	// at your village per year
	// Default = 12
	SETTLER_CHANCE = 22

	// WORLD_SADNESS
	// This controls how likely it is for people to have a good day
	// Default: 0.7
	// Accepted Range: 0.0 - 1.0
	AVG_HAPPY = 0.7

	// SOCIAL_CHANCE
	// This controls the % of the population that has a social
	// interaction every day. Setting this to 0.0 will disable
	// all social events.
	// Warning: Setting this above 1 might cause performance
	// issues.
	// Default: 0.6
	// Accepted Range: 0.0 <=
	SOCIAL_CHANCE = 0.6

	// DISEASE_ENABLED
	// Enables and disables the disease module
	DISEASE_ENABLED = false

	// DISEASE_CHANCE
	// This controls how frequenty disease will break out
	// on average per year
	// Default: 1
	DISEASE_CHANCE = 1

	// DISEASE_SEVERITY
	// This controls how much of a population will be effected
	// by the sickness
	// Default: 0.2
	// Accepted Range: 0.0 - 1.0
	DISEASE_SEVERITY = 0.1
)
View Source
const (
	MoodIndifferent = "Indifferent"
	MoodJoyous      = "Joyous"
	MoodHappy       = "Happy"
	MoodSad         = "Sad"
	MoodMelancholic = "Melancholic"
	MoodDepressed   = "Depressed"
)
View Source
const (
	GenderStrMale   = "Male"
	GenderStrFemale = "Female"
)
View Source
const (
	RelDisliked = "Disliked"
	RelNeutral  = "Neutral"
	RelLiked    = "Liked"
	RelFriendly = "Friendly"
)

Variables

View Source
var (
	JobMiner = &Job{
		name:        "Miner",
		successMsg:  "%s mines %.0f stone.",
		produces:    ResStone,
		produceBase: 15.0,
		chance:      0,
	}
	JobFarmer = &Job{
		name:        "Farmer",
		successMsg:  "%s harvests %.0f crops.",
		produces:    ResCrops,
		produceBase: 10.0,
		chance:      0,
	}
	JobWoodcutter = &Job{
		name:        "Woodcutter",
		successMsg:  "%s chops %.0f wood.",
		produces:    ResWood,
		produceBase: 20.0,
		chance:      0,
	}
	JobHunter = &Job{
		name:        "Hunter",
		successMsg:  "%s hunts and brings back %.0f food",
		failMsg:     "%s hunts and catches nothing.",
		produces:    ResGame,
		produceBase: 20.0,
		canFail:     true,
		chance:      2,
	}
	JobInfant = &Job{
		name:        "Infant",
		successMsg:  "%s poops %.0f times",
		failMsg:     "%s didn't poop",
		produces:    ResNothing,
		produceBase: 2,
		canFail:     true,
		chance:      2,
	}
	JobChild = &Job{
		name:        "Child",
		successMsg:  "%s groans %.0f times",
		failMsg:     "%s was helpful in the household",
		produces:    ResNothing,
		canFail:     true,
		produceBase: 1,
		chance:      2,
	}
	JobOldPerson = &Job{
		name:        "Old Person",
		successMsg:  "%s complains %.0f times",
		produces:    ResNothing,
		canFail:     false,
		produceBase: 1,
		chance:      2,
	}
)

Functions

This section is empty.

Types

type Age

type Age struct {
	// contains filtered or unexported fields
}

Age manages birthdays, and age-related job eligability.

func NewAge

func NewAge(age int) *Age

func NewAgeWithBDay

func NewAgeWithBDay(age, bday int) *Age

func (*Age) Tick

func (a *Age) Tick() []string

type Calendar

type Calendar struct {
	// contains filtered or unexported fields
}

Calendar manages time and seasons

func NewCalendar

func NewCalendar() *Calendar

func (*Calendar) Tick

func (c *Calendar) Tick() []string

type CityManager

type CityManager struct {
	// contains filtered or unexported fields
}

CityManager manages the villages stockpiles and items.

func NewCityManager

func NewCityManager(people *PeopleManager) *CityManager

func (*CityManager) Tick

func (c *CityManager) Tick() []string

type Death

type Death struct {
	// contains filtered or unexported fields
}

Death controls chance of death, and death events

func NewDeath

func NewDeath(pmanager *PeopleManager, mark *MarkovGen) *Death

func (*Death) Tick

func (d *Death) Tick() []string

type GenderType

type GenderType int
const (
	GenderMale   GenderType = 0
	GenderFemale GenderType = 1
	GenderRandom GenderType = -1
)

type HistoryManager

type HistoryManager struct {
	// contains filtered or unexported fields
}

HistoryManager manages game ticks and logging events

func NewHistoryManager

func NewHistoryManager(gameTimer *Calendar) *HistoryManager

func (*HistoryManager) Tick

func (m *HistoryManager) Tick() []string

type Instance

type Instance struct {
	// contains filtered or unexported fields
}

func NewInstance

func NewInstance() *Instance

func (*Instance) TickDay

func (in *Instance) TickDay()

type Job

type Job struct {
	// contains filtered or unexported fields
}

func NewJob

func NewJob(name, mode string) *Job

func (*Job) Tick

func (j *Job) Tick() float64

type JobManager

type JobManager struct {
	// contains filtered or unexported fields
}

func NewJobManager

func NewJobManager(peopleManager *PeopleManager, cityStats *CityManager) *JobManager

func (*JobManager) Tick

func (m *JobManager) Tick() []string

type Log

type Log struct {
	// contains filtered or unexported fields
}

Log object represents a single tick in the village

func NewLog

func NewLog(date string) *Log

type MarkovGen

type MarkovGen struct {
	// contains filtered or unexported fields
}

func NewMarkovGen

func NewMarkovGen() *MarkovGen

type Marriage

type Marriage struct {
	// contains filtered or unexported fields
}

Subclass of the people manager

  1. Decides who is eligable for Marriage
  2. Allows romantic events to happen in the social manager

func NewMarriage

func NewMarriage(people []*Person) *Marriage

type MgenIf

type MgenIf interface {
	Text(test string) MgenModel
}

type MgenModel

type MgenModel interface {
	// contains filtered or unexported methods
}

type Mngi

type Mngi interface {
	Tick() []string
}

type Mood

type Mood struct {
	// contains filtered or unexported fields
}

Mood manages daily moods and emotions

func NewMood

func NewMood() *Mood

func (*Mood) Tick

func (m *Mood) Tick() []string

type MoodEvent

type MoodEvent struct {
	// contains filtered or unexported fields
}

func NewMoodEvent

func NewMoodEvent(dailyHappy, dailySad, duration int, text string) *MoodEvent

Moods can be effected by larger events like having a kid, losing a loved one, or getting a promotion at work. These last multiple days and effect sadness and happiness daily.

type PeopleManager

type PeopleManager struct {
	// contains filtered or unexported fields
}

func NewPeopleManager

func NewPeopleManager() *PeopleManager

func (*PeopleManager) Tick

func (m *PeopleManager) Tick() []string

type Person

type Person struct {
	// contains filtered or unexported fields
}

func NewPerson

func NewPerson(job string, age int, gender GenderType) *Person

func (*Person) Tick

func (p *Person) Tick() []string

type Personality

type Personality struct {
	// contains filtered or unexported fields
}

func NewPersonality

func NewPersonality(name string) *Personality

Each villager gets a personality archetype which effects how social, work, and life events effect them.

type RandomEffects

type RandomEffects struct {
}

func NewRandomEffects

func NewRandomEffects() *RandomEffects

type Relations

type Relations struct {
	// contains filtered or unexported fields
}

func NewRelations

func NewRelations(myName string, myID int) *Relations

func (*Relations) Tick

func (r *Relations) Tick() []string

type Relationship

type Relationship struct {
	A     *Person
	Value float64
	Text  string
}

type Resource

type Resource int
const (
	ResNothing Resource = iota
	ResStone
	ResCrops
	ResWood
	ResGame
)

type SocialEvents

type SocialEvents struct {
	// contains filtered or unexported fields
}

func NewSocialEvents

func NewSocialEvents(peopleObjs *PeopleManager) *SocialEvents

func (*SocialEvents) Tick

func (s *SocialEvents) Tick() []string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL