Documentation ¶
Index ¶
- Constants
- type AcquiredFact
- type Career
- type Character
- func (c *Character) AddRoutine(r *Routine)
- func (c *Character) AddSources(item *Item, locs ...*Location)
- func (c *Character) ChangeOpinion(id uint64, imp Impact) Opinion
- func (c *Character) DoYourThing(day int, hour int)
- func (c *Character) FindTopics(ct *Character) []*Topic
- func (c *Character) GetRoutine(dayOfWeek int, hour int) *Routine
- func (c *Character) GoTo(loc *Location)
- func (c *Character) Idle()
- func (c *Character) Interact(ct *Character, loc *Location)
- func (c *Character) Name() string
- func (c *Character) Plan()
- func (c *Character) SetCareer(car *Career)
- func (c *Character) Sleep()
- func (c *Character) WakeUp()
- func (c *Character) Work()
- type CharacterStatus
- type DayOfWeek
- type Education
- type Fact
- type Impact
- type Index
- func (idx *Index) GetID() uint64
- func (idx *Index) NewLocation(name string, parent *Location, t LocationType, s LocationScale) *Location
- func (idx *Index) NewProfession(name string, req LocationType) *Profession
- func (idx *Index) StartCareer(c *Character, p *Profession, l *Location)
- func (idx *Index) Tick()
- type Interaction
- type Inventory
- type Item
- type ItemInstance
- type Location
- type LocationScale
- type LocationType
- type Opinion
- type ProductionTask
- type Profession
- type Routine
- type Skill
- type SpeechModel
- type Task
- type TaskType
- type Tasks
- type Topic
- type TopicPool
- type TopicRelation
Constants ¶
const ( DayTimeStart = 7 DayTimeEnd = 22 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AcquiredFact ¶
AcquiredFact is a fact that a character has acquired.
TODO: Add more information about how the fact was acquired. - Who / who else supplied information - When / during what interaction(s) - What was discussed - Who else knows?
Method of acquisition: - Casual knowledge - Education - Legend - First hand experience
type Career ¶
type Career struct { ID uint64 // Unique ID Start int // Started career at cycle Active int // Number of active cycles (experience) End int // Last cycle of activity Profession *Profession // Type of profession Location *Location // Main career location Storage *Inventory // Produced items, resources... WorkingHours [7][24]bool // Active working hours // TODO: Change this to requested items list / orders. WorkingOn *ProductionTask // Task currently being worked on }
Career is an instance of a profession associated with a person.
func (*Career) IsWorkTime ¶
IsWorkTime returns true if the given day of the week and hour is active for this profession.
func (*Career) NeedsItems ¶
NeedsItems returns all items that are required to produce items for this profession.
func (*Career) SellsItems ¶
SellsItems returns all items that can be sold by this profession.
type Character ¶
type Character struct { ID uint64 // Unique ID FirstName string // First name LastName string // Last name Title string // Title (Sir, Lady, ...), optional Exhaustion int // Current exhaustion level (0-8) WakeAt int // Time of day to wake up SleepAt int // Time of day to go to sleep Status CharacterStatus // Current status (idle, working, resting, sleeping, ...) aifiver.SmallModel // Personality Career *Career // Current career (maybe allow multiple careers?) Home *Location // Current home (where the character sleeps) Location *Location // Current location PastCareers []*Career // TODO: Add reason for new career PastHomes []*Location // TODO: Add reason for move // Social standing. // Superior / Underlings // Birthday / Gender // Passions // Hobby []*Career - Hobby gardening, chicken coop. // Beliefs // Affiliations // Social connections Knowledge map[*Topic][]AcquiredFact // Total knowledge Opinions map[uint64]Opinion // ID to opinion mapping Routines [7][24]*Routine // Fixed routines Sources map[uint64][]*Location // Where to find what Tasks // Current tasks Inventory *Inventory // Personal inventory }
func NewCharacter ¶
func NewCharacter(id uint64, firstName, lastName string, p aifiver.SmallModel) *Character
NewCharacter creates a new character.
func (*Character) AddRoutine ¶
AddRoutine adds a specific routine for the character.
func (*Character) AddSources ¶
AddSources adds a list of locations to the sources map so the character can find the item.
func (*Character) ChangeOpinion ¶
Change opinion on an entity with the given ID.
func (*Character) DoYourThing ¶
DoYourThing causes the character to do watever is expected for the given day and hour.
func (*Character) FindTopics ¶
Determine overlap in Topics.
func (*Character) GetRoutine ¶
GetRoutine gets any routine for the given day and hour.
func (*Character) Plan ¶
func (c *Character) Plan()
Plan creates a number of tasks for the character on the current day.
type CharacterStatus ¶
type CharacterStatus int
const ( CharStatIdle CharacterStatus = iota CharStatWorking CharStatResting CharStatSleeping )
type Education ¶
type Education struct {
ID uint64 // Unique ID
}
Education is a record of a character's education.
type Impact ¶
type Impact struct { Emotional float64 // Positive / negative emotion Monitary float64 // Monitary gain Information float64 // Value of information exchanged }
Impact is a measure of the impact of an interaction.
type Index ¶
type Index struct { Entries []*Character // All NPCs Locations []*Location // All locations Topics *TopicPool // All topics (shared between NPCs) TickCount uint64 // Current tick count IDCount uint64 // Current ID count (for unique IDs) }
Index is the central index for all NPCs.
func (*Index) NewLocation ¶
func (idx *Index) NewLocation(name string, parent *Location, t LocationType, s LocationScale) *Location
NewLocation adds a new location to the index.
func (*Index) NewProfession ¶
func (idx *Index) NewProfession(name string, req LocationType) *Profession
NewProfession adds a new profession to the index.
func (*Index) StartCareer ¶
func (idx *Index) StartCareer(c *Character, p *Profession, l *Location)
StartCareer starts a new career for a character.
type Interaction ¶
type Interaction struct {
ID uint64 // Unique ID
}
Interaction is a record of an interaction between two characters. TODO: Add more information about the interaction. - Who was part of the interaction. - What was the type of interaction? - What was the outcome of the interaction - Was there an exchange of information
type Inventory ¶
type Inventory struct {
Items []*ItemInstance
}
Inventory represents a storage of items.
func (*Inventory) Add ¶
func (inv *Inventory) Add(item *ItemInstance)
Add adds an item to the inventory.
func (*Inventory) Find ¶
func (inv *Inventory) Find(item *Item) *ItemInstance
Find returns the first item instance of a given item in the inventory.
func (*Inventory) FindIndex ¶
func (inv *Inventory) FindIndex(item *ItemInstance) int
FindIndex returns the index of the given item instance in the inventory.
func (*Inventory) List ¶
func (inv *Inventory) List() []*ItemInstance
List returns a list of all items in the inventory.
func (*Inventory) Move ¶
func (inv *Inventory) Move(item *ItemInstance, to *Inventory)
Move moves an item from one inventory to another.
type Item ¶
type Item struct { ID uint64 // Unique id Name string // Name of the item Buy int // Purchase price Sell int // Sale price Durability int // Base durability in cycles Consumes []*Item // Items consumed to produce RequiresTime int // Number of cycles required to produce Requires *Skill // Skill required to produce ProducedBy []*Profession // Professions that can produce this item }
Item represents an item that can be bought, sold, crafted, etc. TODO: Allow passive production (growing crops).
type ItemInstance ¶
type ItemInstance struct { ID uint64 // Unique id Item *Item // Base item Durability int // Remaining durability }
ItemInstance represents an instance of an item.
type Location ¶
type Location struct { ID uint64 // Unique ID Name string // Name of the location Type LocationType // Type of location Scale LocationScale // Scale of the location Parent *Location // Parent location Children []*Location // Child locations Host *Character // Host of the location (merchant, innkeeper, etc.) }
TODO: Add features (farm plot, chicken coop) that allow passive production of goods... Features might require new routines (collecting eggs etc.)
func NewLocation ¶
func NewLocation(id uint64, name string, t LocationType, s LocationScale) *Location
NewLocation creates a new location.
func (*Location) AssignChild ¶
AssignChild adds a child location to the location.
type LocationScale ¶
type LocationScale int
LocationScale determines the likelyhood of an encounter.
const ( LocScaleHouse LocationScale = iota LocScaleMerchantShopTavern LocScaleSquare LocScaleDistrict LocScaleTown LocScaleCity )
type LocationType ¶
type LocationType int
const ( LocTypeNone LocationType = iota LocTypeShop LocTypeSmith LocTypeFarm LocTypeMine LocTypeInn LocTypeTown LocTypeHome )
type Opinion ¶
type Opinion struct { Count int // Number of values in average Impact // Recent impact Total Impact // Total impact }
Opinion is a measure of how a character feels about a subject.
type ProductionTask ¶
type ProductionTask struct { *Item // Item being produced Remaining int // Remaining cycles until completion }
ProductionTask is a task that is being worked on.
type Profession ¶
type Profession struct { ID uint64 // Unique ID Name string // Name of the profession. Requires LocationType // Requires location type. TypicalStart int // Typical time the works starts (hour) TypicalEnd int // Typical time the works ends (hour) TypicalDays []DayOfWeek // Typical days of the week the profession is performed. RequiresItems []*Item // Required items (speer f. hunter, plow f. farmer, ...) Novice int // Requires number of (active) cycles to be "Novice" Skilled int // Requires number of (active) cycles to be "Skilled" Expert int // Requires number of (active) cycles to be "Expert" Skills []*Skill // Skills that can be learned by this profession. }
Profession represents a profession like "smith", "farmer", "miner", etc.
func NewProfession ¶
func NewProfession(id uint64, name string, req LocationType) *Profession
NewProfession creates a new profession.
func (*Profession) AddSkill ¶
func (p *Profession) AddSkill(id uint64, name string, produce []*Item, minExp int)
AddSkill adds a new skill to the profession.
func (*Profession) CanCraft ¶
func (p *Profession) CanCraft(activeTics int) []*Item
CanCraft returns all items that can be crafted by this profession at the given experience level.
type Routine ¶
type Routine struct { DayOfWeek int // Day of week the routine is performed. Hour int // Hour of day the routine is performed. Location *Location // Location of the routine. C *Character // Character performing the routine. }
Routine is a routine that a character performs.
type Skill ¶
type Skill struct { ID uint64 // Unique ID of the skill. Name string // Name of the skill. CanProduce []*Item // Items that can be produced by this skill. Requires *Profession // Profession required. MinExperience int // Minimum number of active cycles needed }
Skill represents a skill that can be used to produce items.
type SpeechModel ¶
type SpeechModel struct { }
SpeechModel describes the factors that has an impact on how a Character expresses themselves.
type Task ¶
type Task struct { ID uint64 // Unique id Type TaskType // Type of task Item *Item // Item to find/buy/sell/craft }
Task represents a task.
type Tasks ¶
type Tasks []*Task
Tasks represents a list of tasks.
func (*Tasks) RemoveTask ¶
RemoveTask removes a task from the list.
type Topic ¶
type Topic struct { ID uint64 // Unique id Name string // Name of the topic Facts []*Fact // Facts related to this topic RelatedTo TopicRelation // Topics related to this topic }
Topic represents a topic of interest.
type TopicPool ¶
type TopicPool struct { ByProfession map[*Profession][]Topic ByLocation map[*Location][]Topic ByEducation map[*Education][]Topic }
TopicPool represents a pool of topics npc's can talk about.
type TopicRelation ¶
type TopicRelation struct { Professions []*Profession Characters []*Character Locations []*Location }
TopicRelation represents locations, profession, etc. related to a topic.