Code: Select all
<?php
/* ArmagetronAD AI Randomizer v1, 2014 by a really cool guy
* Overwrites aiplayers.cfg with strong values for every named AI
* Place script in directory with the configuration file
*/
$ainames = ["Name1", "Name2", "Name3", "Name4", "Name5"];
// Column header
$ai[] = "# ai-name\trs\ter\tvr\ttr\tcl\tpth\tlp\tcyc\ttun\tdet\tst\tstr\tsch\n";
for ($i=0; $i < count($ainames); $i++) {
$ai[] = $ainames[$i]."\t".
rand(5, 10)."\t". // reaction speed
rand(5, 10)."\t". // emergency reaction
rand(3, 10)."\t". // viewing range
rand(0, 6) * 5 ."\t". // trace
rand(3, 10)."\t". // close combat
rand(3, 10)."\t". // path finding
rand(6, 10)."\t". // loop avoid
rand(3, 10)."\t". // cycle avoid
rand(3, 10)."\t". // avoid tunnel
rand(3, 10)."\t". // trace detect
rand(0, 3)."\t". // initial state
rand(4, 6)."\t". // drive straight
rand(8, 12)."\n"; // state change
}
// Convert array to string and output results to console for user feedback
$outstring = implode($ai);
echo $outstring;
// Write the file
$file_handle = fopen("aiplayers.cfg", "w");
fwrite($file_handle, $outstring);
fclose($file_handle);
?>