Skip to main content
gamedev.net
🔒 Locked

array or hash?

Started by neo88 Oct 16, 2003 at 9:08 AM 1 replies 550+ views
Original Post
neo88
neo88
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
alexjc
alexjc
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!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.