array or hash?

Started by
1 comment, last by neo88 20 years, 6 months ago
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?
My Kung Fu is stronger.May the Source be with you.neo88
Advertisement
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.

Join us in Vienna for the nucl.ai Conference 2015, on July 20-22... Don't miss it!

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

This topic is closed to new replies.

Advertisement