So i'm working on a freelance combat-simulator for a clients game. The basic structure of it, is that every unit has particular attributes, and fights to the death with the other team. The attributes units have are:
$units = Array(
'Footman' => Array(
'health' => 420,
'armor' => 0.08,
'attack' => 17,
'range' => 5,
'dodge' => 0.2,
'crit' => 25.6
),
'Archer' => Array(
'health' => 505,
'armor' => 0,
'attack' => 28.5,
'range' => 10,
'dodge' => 0.5,
'crit' => 40.3,
),
'Catapult' => Array(
'health' => 700,
'armor' => 0.08,
'attack' => 68,
'range' => 20,
'dodge' => 0,
'crit' => 2.5,
),
);So after a user defines how many of each type of unit they want, I loop through and create individual values for every unit in another array. That way, when combat is simulated, every unit keeps attacking until the defending unit dies (or vice-versa) and then moves onto the next.
Now everything works great, up until I start entering in higher values, such as 50-100k units, then I recieve a lovely error message:
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 41 bytes) in ...I'm aware of WHY i'm getting this message, but I need to figure out another way of doing things. If I haven't made it clear as to how i'm handling everything now, please feel free to ask. But it's something i'm not exactly sure as to what to do. That, or you can see the development of it at
http://arictos.com/_development/public_html which i'll have it showing "live" combat logs as the combat is done, with somewhere like 500 units.
Ideas?