Ejemplo n.º 1
0
function start()
{
    global $stopTime, $iterations, $N, $T, $res;
    $stopTime = microtime(true) + $T;
    // NOW + T seconds
    while (microtime(true) < $stopTime) {
        reinit();
        calc($N);
        $iterations++;
    }
    $iterations--;
    // last iteration started before time was up but finished after time was up
    // required '>' mark for automatic benchmark
    print "> {$iterations} iterations\n";
    print "Resulting F({$N}) = {$res[$N - 1 & 3]}\n";
}
Ejemplo n.º 2
0
function start()
{
    global $stopTime, $iterations, $T, $res, $n, $m;
    $stopTime = microtime(true) + $T;
    // NOW + T seconds
    while (microtime(true) < $stopTime) {
        reinit();
        calc();
        $iterations++;
    }
    $iterations--;
    // last iteration started before time was up but finished after time was up
    // required '>' mark for automatic benchmark
    print "> {$iterations} iterations\n";
    print "Resulting LCS(X, Y) = {$res[$n][$m]}\n";
    outputLCS();
}
Ejemplo n.º 3
0
		$varsline = Array();
		$sql = "SELECT * FROM $par->varstable";
		$res = mysql_query($sql);
		while($line = mysql_fetch_array($res,MYSQL_ASSOC))
		{
			$varsline[$line['fieldname']] = $line['fieldvalue'];
		}
*/		
		$sql = "SELECT * FROM $par->varstable";
		$res = mysql_query($sql);
		$varsline = mysql_fetch_array($res,MYSQL_ASSOC);

		return $varsline;
	}
	
	reinit();
	
    function reinit()
    {
    	global $par,$varsline;
	
	$par->document_root = $_SERVER['DOCUMENT_ROOT'];


		$varsline = GetVars();

		$par->adminemail=$varsline['adminemail'];

		$par->params = Array(

			//actname - для какого act определяем url
Ejemplo n.º 4
0
function runstep()
{
    global $nplots, $nplowed, $nfallow, $gold, $xp, $level, $cropvalue;
    global $nextharvest, $nextharvestitem, $maxplots;
    global $crops, $cropToPlant, $goldToReserve;
    reinit();
    $nplowed = count(getPlots("plowed"));
    $nfallow = count(getPlots("fallow"));
    $nplanted = count(getPlots("planted"));
    $ngrown = count(getPlots("grown"));
    $nplots = $nplowed + $nfallow + $nplanted + $ngrown;
    print "{$nplots} plots ({$nplanted} planted, {$ngrown} grown, {$nplowed} plowed, {$nfallow} fallow), {$gold} coins, {$xp} xp (level {$level})\n";
    print "crop value: at least {$cropvalue}; net asset value (1xp=10c): " . ($nplowed * 15 + $cropvalue + $gold + 10 * $xp) . "\n";
    if ($nextharvest != -1) {
        print "next harvest: " . strftime("%a %r", $nextharvest) . " ({$nextharvestitem})\n";
    }
    if (count(harvestPlots(getPlots("grown"))) > 0) {
        # if we harvested anything, we want to reinit here to get the exact amount
        # of gold we have
        reinit();
        #    print("### cleaning up old fallow plots ###\n");
        #    clearPlots(getPlots('fallow'));
    }
    if ($gold > $goldToReserve + 300) {
        $gold -= $goldToReserve;
        $crop = $crops[$cropToPlant];
        if (!isset($crop['cost'])) {
            die("can't look up cost of {$cropToPlant}");
        }
        $cropcost = $crop['cost'];
        # whee, unlimited space; this could become somewhat nuts as it will grow exponentially
        $nplowed = count($plowed = getPlots('plowed'));
        $nfallow = count($fallow = getPlots('fallow'));
        $n1 = min($nplowed, floor($gold / $cropcost));
        $gold -= $n1 * $cropcost;
        $n2 = floor($gold / ($cropcost + 15));
        $n3 = $n2 - $nfallow;
        assert($n1 == $nplowed);
        print "### plowing/planting {$nfallow} fallow, {$n1} plowed, and {$n3} new {$cropToPlant} ###\n";
        plantPlots($cropToPlant, array_merge(plowPlots($fallow), $plowed, makePlots($n3)));
        return;
    }
    if ($nextharvest != -1) {
        $delay = min(45 * 60, $nextharvest - gettimeofday(true) + 60);
        print "waiting " . floor($delay / 60) . " minutes...";
        sleep($delay);
        print "\n";
    }
}