Archived

This topic is now archived and is closed to further replies.

array or hash?

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

I am writing a rpg in perl. Before you jump all over me though, it is actually coming along really well... I was quite suprised at how easy it was to translate the perl language into a sutible langauge for game programming. Anyways, I am doing the AI for my game right now, and I need to know if I should store the information in an array or a hash. Since this is OO perl, I am kinda leaning toward hash. But, here''s the type of data I want stored: health = 0,1; weapons = 0,1; food = 0,1; happiness = 0,1; victories = 0,1; defeats = 0,1; tired = 0,1; as you can see, these are simply boolean values, 0 if false, 1 if true. Would this type of information be better stored in an array or a hash? Are there any other types of values I should include?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You could make an object for this in perl, that would be better than a hash. A hash would work, it would just begin to get annoying when you had more then a few instances.

-v

Share this post


Link to post
Share on other sites