Tribe Design: Difference between revisions

From PSwiki
Jump to navigation Jump to search
Zee (talk | contribs)
Classes: Added info for each.
Zee (talk | contribs)
Line 63: Line 63:
This class represents a node of the recipe tree describing the tribe current tasks. Each recipe tree node contains a link to it's recipe, waiting times, current requirement, current algorithm step and relationship information regarding other recipes. (just as a standard Tree, it may have parents and descendants).
This class represents a node of the recipe tree describing the tribe current tasks. Each recipe tree node contains a link to it's recipe, waiting times, current requirement, current algorithm step and relationship information regarding other recipes. (just as a standard Tree, it may have parents and descendants).


RecipeTreeNodes are not being stored in any database. They are just used during runtime to be used like an AI for the tribes.
RecipeTreeNodes are not being stored in any database. They are just used during runtime as an AI for tribes.


''' Recipe '''
''' Recipe '''

Revision as of 14:21, 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

Members

Tribe members (both dead & alive) are kept in an array in the Tribe Class. They are all represented by the NPC class. The tribal class only has methods to attach a tribe member. For spawning new members the server (gemSupervisor & entityManager classes) and the npcclient class are responsable.

Tribe members can have different types. (Discussion needed about tribe types)

Tribe members are being kept in the 'tribe_members' mysql table.

Resources

A resource is kept in a data structure (Tribe::Resource) containing it's name, nick and quantity. The tribe class has methods for adding, modifying, storing and completely deleting resources.

Resources are being kept in the 'sc_tribe_resources' mysql table.

Memories

A memory is a location of some importance to the tribe. (E.g. a mine, a field, an enemy, etc)

A memory is kept in a data structure (Tribe::Memory) containing it's location (sector & coords), it's name and a link to an NPC (which is NULL if the memory is public to all tribe members, or != NULL if it's private to a tribe member). The tribe object has methods to add, store, modify and search memories.

Tribe members also have a memory slot for keeping it's current task location. (see bufferMemory attribute of NPC class).

Tribe memories are being kept in the 'sc_tribe_memories' mysql table.

Assets

Assets are belongings of the tribe. They can represent buildings, items or spots to be built in the future.

An asset is represented by a data structure (Tribe::Asset) containing it's location (sector & coords), it's name, it's quantity (relevant just for items) and it's type (Building Spot, Building or Item). The tribe class has methods for adding, editing and deleting assets. It also has methods for managing buildings. (e.g. Replace a building spot with the actual building after the workers built it)

Tribe assets are being kept in the 'sc_tribe_assets' mysql table.

Knowledge

Knowledge represents the information the tribe has gathered and the technologies they can use. (E.g. Ironworks, pottery, horseback riding, alphabet, math, etc)

Technically, they are just strings used as tokens to prove the tribe has acquired knowledge or not.

Knowledge is kept in an array of strings.

Tribe knowledge is being kept in the 'sc_tribe_knowledge' mysql table.

Recipe Tree Node

This class represents a node of the recipe tree describing the tribe current tasks. Each recipe tree node contains a link to it's recipe, waiting times, current requirement, current algorithm step and relationship information regarding other recipes. (just as a standard Tree, it may have parents and descendants).

RecipeTreeNodes are not being stored in any database. They are just used during runtime as an AI for tribes.

Recipe

A recipe is a set of requirements and algorithm steps regarding a task that needs to be done. Recipes can vary from simple (Gather a resource) to very complex (Build an entire civilization).

Recipes are being stored in the 'tribe_recipes' mysql table.

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.