Jump to content
  • Advertisement
Sign in to follow this  
Orymus3

Noob question on hashmaps

This topic is 1548 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

Hi,

 

I'm currently programming a system where a series of AI-governed units have to make an assessment of what their best target to attack is.

They are looking at a hashmap that contains all AI units and check if these are hostile towards them.

The problem I'm faced with is that I also have a 'player' which is a different class that I would like to be listed in there, but quite unsurprisingly, the hashmap is typed and won't allow for my player class to be included.

 

My best solution so far is to make two standalone checks (one with the hashmap, and a single one with the player) but I'm assuming there must be an easier way (perhaps an untyped hashmap?).

 

Any way to solve this easily without having to rebuild a matrix that contains data that is similar between AIs and the player?

 

Thanks

Share this post


Link to post
Share on other sites
Advertisement
I thought about this actually.
Started looking into interfaces a few weeks ago actually (never used them yet).
I will try it thanks!

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!