Home
Demo
Program
Fight
Archive
Specs
Feedback
FHP Reference
Edit your code below and press SAVE when done
/* This is the default program for all new bots. ** It just moves in random directions in 5-meter increments, ** while checking for collisions and backing up if needed. */ variable $ang, $dir, $prevmove; // all vars must be declared $prevmove=foo_getstat()->base; // this will be 'S' at the start while (true) { foo_laser(foo_getstat()->range_turret); // fire laser if we see something ahead if (foo_getstat()->blocked) foo_base('R', 1.5); // if we hit something, start to back up if (foo_getstat()->base=='S') // if we are not moving... { if (strpos('SFR', $prevmove)!==false) turn(); // if we weren't turning, start now else foo_base('F', 5); // otherwise start going forward } else $prevmove=foo_getstat()->base; // remember our last direction } function turn() { $ang=rand(0, 180); // pick a random angle $dir=rand(0,1)?'D':'W'; // pick a random direction foo_base($dir, $ang); // start the turning movement }