Tribe Design: Difference between revisions

From PSwiki
Jump to navigation Jump to search
Magodra (talk | contribs)
Zee (talk | contribs)
No edit summary
Line 1: Line 1:
= Tribe Design =
= Tribe Design =


The tribe design is done in much the same way as the NPC Beaviors. The tribe have a set of needs, each need will over time change and be used as the input to assign tasks to the tribe members as they become available.
The tribe design is done using NPC Behaviors and Recipes. Tribe members are assigned tasks based on what the recipes dictates the tribe to achieve. This system uses a Recipe Manager which takes care of parsing recipes, breaking the initial recipe into subtasks and telling the npcs which action to take.


== Classes ==
== Classes ==
Line 10: Line 10:
Tribe "1" *-- "0..N" Resource : resources
Tribe "1" *-- "0..N" Resource : resources
Tribe "1" *-- "0..N" Memory : memories
Tribe "1" *-- "0..N" Memory : memories
Tribe "1" *-- "1..N" TribeNeedSet : needSet
Tribe "1" *-- "0..N" Asset : assets
TribeNeedSet "1" *-- "0..N" TribeNeed : needs
Tribe "1" *-- "0..N" Knowledge : knowledge
TribeNeed <|-- TribeNeedGeneric
Tribe "1" *-- "1..1" RecipeTreeNode : recipes
TribeNeed <|-- TribeNeedResourceArea
RecipeTreeNode *-- Recipe
TribeNeedResourceArea "1" *-- "0..1" TribeNeedResourceArea : explorer
RecipeManager "1" *-- "N..1" Recipe : all recipes
TribeNeed <|-- TribeNeedReproduce
TribeNeedReproduce "1" *-- "0..1" TribeNeedReproduce : getResourceNeed
TribeNeed <|-- TribeNeedResourceRate
TribeNeedResourceRate "1" *-- "0..1" TribeNeedResourceRate : dependendNeed
TribeNeed <|-- TribeNeedDeathRate
TribeNeedDeathRate "1" *-- "0..1" TribeNeedDeathRate : dependendNeed
TribeNeed <|-- TribeNeedTimeOfDay
</uml>
</uml>



Revision as of 13:46, 16 September 2011

Tribe Design

The tribe design is done using NPC Behaviors and Recipes. Tribe members are assigned tasks based on what the recipes dictates the tribe to achieve. This system uses a Recipe Manager which takes care of parsing recipes, breaking the initial recipe into subtasks and telling the npcs which action to take.

Classes

Sequences

Advance Sequence

Advance sequence is the hart of the Tribe system. The NPCClient will advance the brain 4 times a second. If some NPCs don't have task the Tribe will select a new task and Trigger a perception to start one of the NPCs behaviors.

Setting up tribes

There are 2 main database tables that need to be populated.

  • TribesTable
    • Each row represents one tribe, which must have a home position/sector and a radius in which to resurrect dead members.
    • max_size sets the maximum number of members.
    • wealth_resource sets the different types of resource that a tribe can mine in order to grow and/or sustain itself. This needs more work however the most important one is wealth_resource_growth which is the default rate at which a resource will grow without any work per second.
    • reproduction_cost is the amount of resources required to reproduce.
  • tribe_members
    • Each row is an association between a PID (on the server side) and a tribe.
  • tribe_needs
    • Each row is a need associated with a tribe
    • Consists of: type, name, perception, depend, need_start_value,need_growth_value, arguments

Tribe day-to-day life

Behaviour

A tribe has a set of needs, which are nothing, explore, dig, reproduce and walk. These needs are increased by a rate set in the code for now. When a need is activated, it may also trigger a perception for the next npc.

Tribe members are ordinary NPCs, with an additional set of Behavior Operations and perceptions to be used in Reactions. These perceptions are defined by the needs defined in the tribe_needs table and might be:

  • tribe:explore
  • tribe:dig
  • tribe:reproduce (should result in a reproduce op).
  • tribe:resurrect
  • tribe:guard
  • Or anything else

Reproduction

The reproduction need will only increase if the number of tribe members is below the maximum. When reproduction is triggered, the tribe resources are decreased by reproduction_cost and the next NPC receives the tribe:reproduce perception. If the NPC then performs the reproduce op, it causes a server-side clone. Everything is cloned and the new cloned NPC will be a member of the tribe.

Resurrection

When a member dies, it will be resurrected according to the tribe need and will also take a reproduction_cost. However, no cloning will take place.

Resources

A tribe member can be set to use the Transfere Operation to locate the memory of a tribe resource and use the Dig Operation or Harvest Operation to get resources when for example a tribe:harvest perception is triggered. The Transfere Operation needs to be used when the npc is back home to transfer it to the tribe.

Locations

The tribe:resource and tribe:home locations can be used with tribe members. For example in the Locate Operation.

Tribe death

When all the members die, then a member will be resurrected if there are 10*reproduction_cost resources available.