# 用于比较装甲集的复杂阵列

perhaps I'm having a dumb moment, but I just can't seem to work this out in my head.

I'll try and explain:-

I have three 'sets.' Each set contains 6 objects. I need a loop (or series of nested loops) to result every combination of these sets.

It's for a game, I'm trying to write a script to compare armor sets - sad I know. The array of sets looks like this:-

``````class => array(
set1 => array(
hat item => array(stats)
glove item => array(stats)
...
set2 => array(
hat item => array(stats)
...
set3 => array(
...

)
``````

This may be a lot simpler (or a lot more difficult?) than I thought.

Ideas welcome!

Thanks, Ruu.

EDIT:-

Ok here's an array sample, I've stripped out a LOT of the extra stats, and just left one for each piece:-

``````\$setinfo = array(
'rk' => array(
'set1' => array(
'hat' => array(
'will' => 114,
),
'shoulders' => array(
'will' => 78,
),
'shirt' => array(
'will' => 78,
),
'gloves' => array(
'will' => 78,
),
'trousers' => array(
'will' => 78,
),
'boots' => array(
'will' => 114,
),
),
'set2' => array(
'hat' => array(
'will' => 78,
),
'shoulders' => array(
'will' => 78,
),
'shirt' => array(
'will' => 114,
),
'gloves' => array(
'will' => 78,
),
'trousers' => array(
'will' => 114,
),
'boots' => array(
'will' => 78,
),
),
'set3' => array(
'hat' => array(
'will' => 78,
),
'shoulders' => array(
'will' => 114,
),
'shirt' => array(
'will' => 78,
),
'gloves' => array(
'will' => 114,
),
'trousers' => array(
'will' => 78,
),
'boots' => array(
'will' => 78,
),
),
)
);
``````

From this example (I will worry about comparing other stats later,) the 'ideal' pieces would be, the hat and boots from set1, with the shirt and trousers from set2, and the gloves and shoulders from set3.

My query is how best to work out a loop which can generate a 'result' array with every permutation, for comparison later.

2012/10/24 09:07
• php
• arrays
• 点赞
• 收藏
• 回答
私信