Archived

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

neo88

array or hash?

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
heh, if perl really was OO, you''d use a class for that. But it''s not, so go for a hash! An array will be less intuitive.

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