• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Game Blackboard

 
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I want to implement a blackboard for my game I"m designing. Basically, it registers and stores any object and lets me retrieve that object again at a later time. How would I go about doing this?


This is what I have so far:



 
Saloon Keeper
Posts: 10687
85
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have not idea what you're talking about.

Do you know about Maps? Do you know about Serialization? Do you know about databases?

"some time later", how much later?
 
Saloon Keeper
Posts: 15488
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't extend the Thread class. If you need tasks performed in the background, use an ExecutorService. It doesn't seem like your class represents a task anyway.

What kind of game are you making, and why do you need a central place to store variables?
 
Ted Gress
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Yesterday ‎10‎:‎58‎:‎15‎ ‎PM     Subject: Game Blackboard

I have not idea what you're talking about.

Do you know about Maps? Do you know about Serialization? Do you know about databases?

"some time later", how much later?  



Yes I know about maps. And I know about Serialization. And I know about databasesI don't think any of that that applies to this situation though.


Yesterday ‎10‎:‎58‎:‎15‎ ‎PM     Subject: Game Blackboard

I have not idea what you're talking about.

Do you know about Maps? Do you know about Serialization? Do you know about databases?

What kind of game are you making, and why do you need a central place to store variables?  



I am making a 3D MMORPG. I read about them as an algorithm for use when there is a lot of cross-information s haring.
I wish I had the reference.

But that is a moot point. Can somebody answer my question?

 
Stephan van Hulst
Saloon Keeper
Posts: 15488
363
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's not a moot point, because knowing the reasons why will help find the correct solution.

Why do you think that using maps is not the correct solution? That's the first thing I would consider when I want to store variables in memory.
 
Ted Gress
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using maps makes perfect sense in this situation. H ow else would you store a key value pair?
 
Stephan van Hulst
Saloon Keeper
Posts: 15488
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does that mean you've found something that works for you?
 
Ted Gress
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not really. I want to store instances of classes in the blackboard. I'm thinking maybe Java Generics would work?
 
Stephan van Hulst
Saloon Keeper
Posts: 15488
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maps are generic.

Can you give us concrete examples of the things you want to store?
 
Ted Gress
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok. Wrong term. I don't know what its called in Java, I thought it was Generics. I want to use something like templates in C++.


Here is some pseudocode:



Blackboard.register(variable's name, variable's value)

Blackboard.register(pointLight, pointLight.value)

--

vector pointLight = Blackboard.retrieve(variable's name)

--
TextureMap t;

Blackboard.register(t, t.value);

(rendering loop)

TextureMap t = Blackboard,.retrieve(t);

--------------


So, these are just examples. I wouldn't necessarily use the BlackBoard to store those values, but it shoujld clear things up.



 
Carey Brown
Saloon Keeper
Posts: 10687
85
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Map's are collections. They use generics to specify the types they're dealing with.
To declare a Map you need Map<K,V> where 'K' is the object type for the key, and 'V' is the object type for the value. Keys stored in the Map must be unique. Map entries are "registered" using the put() method, and "retrieved" with the get() method.

Blackboard blackboard = new Blackboard(...);

// asuming your Blackboard class has a Map variable by the name of "map"
blackboard.map.put( "unique name", variable );
blackboard.map.put( "pointLight", pointLight );

--

PointLight pointLight = blackboard.map.get( "pointLight" );

--
TextureMap t;
blackboard.map.put( "textureMap", t );

(rendering loop)

TextureMap t = blackboard.map.get( "textureMap" );

--------------
Here I'm assuming that your Map declaration inside your Blackboard class would look like

 
Ted Gress
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need something more along the lines of:

Map<"String Identifier", Object>

Where object is any type. AIs t his possible?
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ted Gress wrote:. . . Map<"String Identifier", Object> . . .

No, you have to write types not objects in the <>. Map<String, Object> will work.
 
Ted Gress
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, does that mean I can do the following? (for example)


Hashmap<String, T> myBlackboard = new Hashmap<String, T>

variables:

ambientlight = 1.0f;
long frameTime = endTime - FrameTime
WSObject WSFirstPersonPlayerCharacter = new WSFirstPersonPlayerCharacter();

then

myBlackboard.put("ambientlight", ambientlighit);

myBlackboarrd.put("frameTime", frameTime);

myBlackboard.put("FIrstPersonPlayerCharacter", WSFirstPersonPlayerCharacter());



 
Ted Gress
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Correction: That last line is supposed to be:

myBlackboard.put("WSFirstPersonPlayerCharacter", WSFirstPersonPlayerCharacter)
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic