308, 'size' => 114 ), /*array( 'buildings' => 538, 'size' => 250 ), array( 'buildings' => 912, 'size' => 228 )*/ ); function getOB($size, $buildings) { $ob = 100 * (exp($buildings/(4*$size)) - exp(1/4)); $ob = ($ob < 0) ? 0 : $ob; return $ob; } function getBuildings($psize, $buildings) { global $cash, $chr, $str; $curbuildings = 0; $ccash = $cash; $cchr = $chr; $cstr = $str; echo "Looking at a planet with a capacity of ".$psize." and a current amount of buildings of ".$buildings."
\n"; echo "Starting off with an OB percentage of ", round(getOB($psize, $buildings), 2), "%.
\n"; do { $curOB = getOB($psize, $curbuildings + $buildings); $ob_cash = cashcost * (1 + ($curOB/100)); $ob_chr = chrcost * (1 + ($curOB/100)); $ob_str = strcost * (1 + ($curOB/100)); $ccash -= $ob_cash; $cchr -= $ob_chr; $cstr -= $ob_str; $curbuildings++; } while(($ccash >= $ob_cash) && ($cchr >= $ob_chr) && ($cstr >= $ob_str)); echo "You could build ".$curbuildings." banks on this planet with an end OB of ".round($curOB, 2)."%.

\n"; return $curbuildings; } ?> Bank Building Reserves:
\n"; echo "Cash: ", $cash, "
\n"; echo "Chromium: ", $chr, "
\n"; echo "Stontium: ", $str, "

\n"; foreach($planets as $planet) { $tobuild[$planet['size']] = getBuildings($planet['size'], $planet['buildings']); } asort($tobuild); $best = array_slice($tobuild, -1, 1, true); foreach($best as $planet => $buildings) echo "The best is to build ".$buildings." banks on the planet with size ".$planet; ?>