About this blog
Project NN is experimental AI project which will cover Survival, Social and Battle simulation of various lifeforms
Entries in this blog
Recently I'v finished "game speed" property. This parameter I need to speed up some simulation parts. Now, finally, is engine working properly. I'v measured right Creature speed across different game speed settings and I'v realized that my previous algorithm was making phantom time differences in higher speeds. Currently is everything all right, and creatures are moving exactly fast in every game speed.
Something to my timer settings:
1.Main Update is runnig at 25 fps (40msec)
2.Background Update is running at 4 fps (250msec)
With speed of "2" I have updates in 125msec/20msec. Speed modifier is just divider to the timers.
Screens from right results for creature movement in speed of "1" and "2". Delta time is now correct.
The brake parameter is criterion of how to slow down creature movement until they are facing right direction. More angle they need turn, more brake is needed to ther movement
Curretnly I'm working on Nature as gameObject type and its substances.
All this stuff is about Combat aspect of this project. There are other attributes for Survival and Social aspects, which I will introduce later. Creature is every gameObject in sandbox which has and try to uses it's brain.
Each creature will have its own stats which will describe it's shape for combat. I situated it in "Fantasy" scenario, so I'v was thinking about the right created stats and attributes. I was inspired by DnD, partly from WoW and other fantasy game scenarios. I ended (temporary) with these creature attributes:
Intelligence, Strength, Dexterity, Constitution, Charisma and Wisdom.
These main attributes are affected by sublevel attributes:
Mana (Spell Effectivity), Melee Effectivity, Stamina, Endurance, Agility (Attack speed) , Reflexes, Perception, Resistances (Poison, Spell, Disease), Dummy (not yet covered for Charisma path) and WillPower.
Ok, what is the point. I needed to create same simple creature progression, so I'v used/designed this:
Creature progression and training points
Creature will progress with gaining experience. Experience will be gained through killing some other creatures, complete some task, doing their work, like farming, delivering food or something. Experience gaining model is not completed now. After each new level, creature will gain 1 training point which can be spend in trainable attributes. This are yellow fields in sheet. This trainable attributes modifies main attributes. Creature will follow one of the paths for Caster or Melee combatant
This is how look's creature level 1
And here, level 24
I have melee and spell damage. Till now just melee formula. I don't want to restrict weapons for certain levels like in other games. You can use any weapon which you buy, craft or you find it on the ground. Weapon has some it's damage. The final damage which it cause when you will use it is calculated by formula which achieve following result: You should use as most suitable weapon for your level to reach maximum output damage with this weapon. What is most suitable weapon ? Weapon damage requires some stats from your creature calculated by its damage. When you you are level 14 and you use weapon with base damage 2, you are not effective. When you use weapon with base damage 30, you cannot handle such a damage, so output damage will be very low. This curve is like a quadratic curve.
Formula for melle is following:
I have something similar for Spell damage, where damage will be defined by spell "somehow".
All three main attributes, HitPoints, ManaPoints and StaminaPoints will regen through some activity or inactivity.
HitPoints - Through Heal spells (high regen), Resting (low regen), eating/drinking healing nutriments from bushes, flowers, etc...
ManaPoints - Through not casting, resting in calm places, reading spirit books
StaminaPoints - Resting, sleeping, walking (not running), wearing lower weights, standing
Well, that's all for now.
Engine is starting to bring its apport in form of scalability and modularity. Basic overview of world architecture:
World will be core handler for all child objects like a gameObjects, Weather system and Maps. World consist of maximum 32x32 map grids. Shortly, map can be added or removed during running world at any time without any performance disruption. Map has dimensions about 4096x4096 meters, where origin is starting at 0,0. I'll use just coords from 0,0 to 4096,4096. Every map will have its own weather controller which will be also controlled from global weather controller (GWC). GWC will try to do "fluid" weather flow across other maps, as I tried to describe in my previous post.
Types of gameObjects.
World will handle gameObjects or Entity (in previous versions), which can be as type of:
Visual - Just some stationary model of something
Item - Equipment (helm,chest...), Water source, Food source
Building - Tent, house, tower
Light - Source of visibility in game with dynamic position
Nature - Tree, bushes, etc ...
Creature - Most complex and intersting type with "the Brain". It includes Humans, Insects, Undeads, and other different types of Creatures.
That's for now, I'v already implemented combat part of each creature, which I introduce on my next post.
Let me describe implementation of weather system in more details.
Simulation year have 40 days, and 4 seasons (like in real). 1 day has 1000 ticks. 1 tick has 10 smaller ticks, 1 smaller tick is ticking every 250ms.
Base of simulation is temperature of region which can be modified by position of this region, as I mentioned before, regions in higher altitude will have lower temperature and so on.
During the year, which is 40 days, temperature has sine continuance, lowest in winter, highest in summer, lowest at night, highest at noon. There are also modificators like raining/snowing (drops) density, clouds density. At the end formula looks like:
Temperature = HourModifier + DayModifier + DropsModifier + CloudModifier + RegionSpecific +- Random of 0.0 - 0.3
This show region with zero difference, of course, the range of minimum and maximum temperature is very wide, it is already shortened and implemented to have values from -6 to 6 points.
What is optimal temperature for creatures ? Currently around 4-6 points.
Density depends on current day and temperature. As we are closer to summer, we can expect less clouds + as temperature is raising, less density of clouds we will have. There is some threshold, how often and how will be density changed to have cloudy days and to have clear sky above. I also simulate cloud variation, which determines how are clouds morphing (changing), which is also affected by wind speed
Picture show density of clouds during 2 years
This means Rain and Snow. As we have higher density of clouds there is higher chance to have higher density of drops. There are lot of chances, for example chance to start drops, to increase drops density, or to stop drops. This chances are also thresholded to not have random rain, during whole year, but to have rainy and not rainy days/hours.
Nothing special here, as it more rains, humidity is raising and with lower temperature it is raising faster. When there are no drops, humidity is diminishing and with higher temperature faster. Well, currently I don't know exactly how and which part of the simulation will this parameter affect.
Well, this is calculated in very easy way. If we have some clouds, and we are starting to have higher temperature, there is higher chance to Flash or Storm boom, that's it.
Main wind direction and speed is picked from global weather and it is modified per region.
(not yet implemented)
Goal is to implement weather progression across regions. I want to spread wind with direction and velocity, temperature, clouds denstity, etc... Implementation is already on paper, but I dropped it, due to reason, that I really want to finish main aspect of this simulations instead of deep weather system. So I postponed implementation till I'll have acting creatures in simulation world.
I'v attached CSV and XLS file with values from simulation for 1 year.
After a long period, during which was project updated, I finally take courage to write a journal post here. Meanwhile, too many thing were added in to the project, but I also started from scratch. I'v decided to make better approach to base engine, which I will see later on easier implementation of all desired project tasks. Currently I'm working on server side first, which is done for "offline" testing, and also weather system is done for now. It implements about 80% of features which I want to have, but I'm trying to keep focus on main point of this project as on non less important parts .
Another aspect of this simulation will be also weather behavior. As world is divided into parts, each part of world will keep individual information about weather.
We will have global information about Wind direction and velocity, Temperature, Season, and so on. Each node will "somehow" modify this values to have weather zones in each region. For example, wind will move storm from east to west, or cold frontal wave will move along from north to south. Currently each node is handling Temperature, Humidity, Clouds density, Wind modifier, Raining/Snowing density. This variables are wired to each other in easy patterns.
During the "simulation year", temperature is raising and lowering accordingly. During warmer days, there are less clouds, but higher chance to create hudge storms, which will bring dense rain drops, which will increase humidity, which will lower down temperature a little bit. Higher density of clouds affect chance of rain or snow. Wind is affecting temperature too, but also move storm/raining/snowing along other parts of the world. Some regions, let's say hilly, will have lower global temperature, which leads to have more snow or rain, higher humidity, more water in soil, more water resources, when water will will be build. Characters in more dry zones, will have problem with water resources, or plantage will be less effective.
Temperature will affect also Combat part of this simulation. In higher temperatures will cold melt much more faster than in windy and cold zones, and to use fire will be less effective in colder zones.
Currently weather zones are implemented, visualization of this simulation will be added in later posts.
Project NN is about characters which will behave autonomously. Many inputs, crunched by their "minds" will lead to acting. I called entity everything, what is placed in to the world except lights. Currently my entities are:
Building - Will include houses, public places, towers,monuments which have different attributes based on their subtype.
Nature - Trees, mushrooms, bushes, which will have also food attributes, some of them will be as food source, some of them will increase stealth value for hidden characters inside them.
Characters - Main actors of this project, which are moveable, they have personality attributes, will include also RPG stats, and so on.
Entities are handled by Entity manager, which is taking care about creating and deleting entities in world, and also optimizing performance. Entities are rendered and updated by main game loop. Of course, I should not render entities which you cant see, or update entity which have static position for long time, or perform AI operations often when entity is sleeping. Entity manager collects and try to adapt on entities needs to gain best performance for the game. Entity's thinking (entities which have brain) is launched in separate shared thread, which is executed at 4 FPS. For thinking is this enough.
This is the main class for "thinking". How many perceptions per one execution are handled, or how far can character see, will depend on attributes which will be implemented later. Characters are currently:
Collecting things around them (Perceptions)
Checking entities in their cone of vies (distance and FOV), including building positions,characters last position, and so on...
Collecting terrain information, like if position is passable, or reachable by pathfinding
Sounds (will be implemented), act on what character hears
Smells (will be implemented), tracking entities by smell
Collections of entities (characters, buildings, nature) are stored in to Memories
Acting on terrain and entity changes.
Handles all processed perceptions which we want store for character, because acting and decision making will be based on memories and perceptions. Also here, character attributes will affect, how much can each Character remember, how will relationships change when there are no/is interaction with other characters.
When character is spawned in to the world, it knows nothing about world. It starts to collect terrain data in his "territory", till it finds group of entities or Settlement Point which will be home for Character. It will try to explore world around it's home. Currently is also implemented situation, when Character accidentaly falls from high hill, or slides down and it cant reach previous targets, it continues of exploration but with flag, that it needs to find new home, because it is lost and home is no more reachable.
Greetings to all,
From 2d project which was supposed to be AI sandbox I moved into the 3D, because I wanted to interact with characters and test their behaviours like in the "game". That was the main reason to switch project into 3d space.
What I want to implement:
- Autonomously characters which know their environment and can interact with each other
- Personality attributes (traits) and opposites of:
- Food gatherer
- World data gathering, collection of:
- Terrain surface and anatomy
- Safe / Dangerous places
- Other families, villages and factions
- Food sources
- Enemy territories
- Houses and other structures
- Information exchange with others
- Relationship based acting
- Fighting in groups against enemy groups or single creature
- Tactical planning
- Threat prediction
- Home area guarding
- Acting affected by character personality
- Physical and Fantasy combat
- Some RPG elements
- Graphics in toon style
I'm also inspired with other titles like World of Warcraft, Sims, Fallout, Black & White and others, which implemented interesting AI elements in to the their game. That's it ! Next, world introduction.