Jump to content
  • Advertisement
Sign in to follow this  
Norman Barrows

"Knowledge banks" for game entities

This topic is 785 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I'm about to add yet another feature, requiring yet another variable (or more than one) to track some new info the game doesn't track yet.

 

In this particular case its playing a rock toss mini-game using the combat engine, and a flag to indicate that the player is doing so.

Share this post


Link to post
Share on other sites
Advertisement

Seems like a data dictionary would be good.  A combination of key/value pairs with whatever you need.  

 

They can be provided so they work with new values if you use a pair like:

 

value = dictionary.Read( key, value, default);

dictionary.Write( key, value );

Share this post


Link to post
Share on other sites

Looks like the last pat of my original post got lost.

 

it went something like...

 

I was thinking wouldn't it be nice if each PC and NPC had a "knowledge bank", and you could just add "i'm playing rock toss" to the knowledge bank.

 

you could use the knowledge bank for all kinds of things.

 

basically a generic data storage area, probably using some sort of key:value pair system. 

 

but of course the down side is strcmp() speeds, unless you use some sort of opcodes.

 

has this been done before?

 

it may not be very performant, but it could be very handy.

 

it could also be very useful for those nebulous pieces of data such as "who knows what" for dialog, gossip, and quest engines.  and maybe for some sort of learning system as well.

Edited by Norman Barrows

Share this post


Link to post
Share on other sites

I was thinking combine the conversion and getter and setter functions:

 

read int, read float, read string, write int, write float, write string.

 

and return an error code or some reserved value if key not found.

Share this post


Link to post
Share on other sites

but of course the down side is strcmp() speeds, unless you use some sort of opcodes.
If you only need equality checking, you could build a table with unique strings (and perhaps weak references, if strings can disappear), so you can use pointer equality instead.

 

has this been done before?
It seems sufficiently general to answer that with "yes".

Perhaps the biggest problem is how to store your knowledge. I typically already have trouble storing configuration data in an INI file, which is more powerful than a single key/value pair list (since INI files have sections). Hierarchical data may be better (dictionaries of key strings to value strings or value dictionaries).

Share this post


Link to post
Share on other sites

What you are talking about Norman is some kind of/exactly what a blackboard is used for. Doing heavy AI work at the moment so need to work with blackboard too.

Each value is indexed by a name in a dictionary/map (my own implementation based on a vector) using enum indices. The values are object classes that have 8 byte and store either the value directly (bool, int16, int32, float) or as a self managing pointer to the data in heap memory (const char*, string) so all you need to do is call either

Blackboard->Get(Enums::PlaysRockToss).Cast<bool>();

or directly call

Blackboard.GetBool(Enums::PLaysRockToss);

If you dont need types larger than 32bit you could throw the object away and store it in 4 byte chunks instead what is what I do because in my opinion it isnt necessary for an AI to use strings for state storing so int and float are enougth for it.

 

 

 

I typically already have trouble storing configuration data in an INI file, which is more powerful than a single key/value pair list (since INI files have sections).

 

I did that in my engine in the form of a continious range of memory storing document nodes (like HTML, XML do) so you have always your section nodes with next/child indices pointing into the memory block and could traverse your DOM using Next/Child Next to the nodes. Did the same for JSON data, works quite uncomplicated and fast

Share this post


Link to post
Share on other sites

What you are talking about Norman is some kind of/exactly what a blackboard is used for

 

Sounds like it.  I may have to try something like that.  But Caveman is almost done, except for final graphics and help.  The rock toss game is about the last big feature.  That, favorite foods, possibly dust storm and super volcano disasters, and making sure all the inputs added recently are re-map-able. Time for me to get a 3+Ghz PC and a 900 or 1000 series card to do the graphics.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!