"Knowledge banks" for game entities

Started by
6 comments, last by Norman Barrows 7 years, 6 months ago

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.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

Advertisement

Is this what you are thinking of blackboard?

Interested in Fractals? Check out my App, Fractal Scout, free on the Google Play store.

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 );

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.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

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.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

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).

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

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.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement