![]() |
|
more useful options | |
PerlMonks |
Re: Hierarchical Data Structuresby kvale (Monsignor) |
on Mar 11, 2004 at 05:57 UTC ( #335727=note: print w/replies, xml ) | Need Help?? |
The relationships between players is clearly a tree structure, but you didn't say why Tree:MultiNode isn't good for you...
So I will suggest a hash based approach. Each player has a boss (except for the top player), three subordinates, and points. A suitable hierarchical data structure is like the following Obviously, you will want to use loops to populate %players, the assignments above were just to be clear on the structure. Given this structure, you can determine points by iterating through all the players and collecting points from his slaves. To exchange positions, you smply swap bosses and slaves for the two positions. -Mark
In Section
Seekers of Perl Wisdom
|
|