<?php

// Bot info
$key '########################';
$version '0.1a';

// Required to show source
if (isset($_GET['displaySource']) || isset($_GET['describe'])) {
    
$source file_get_contents(__FILE__);
    
$source str_replace($key"########################"$source);
    
highlight_string($source);
    exit;
}

// Get the library
require 'SG_WBB.php';

// Turn handler
function first_turnHandlerSG_WBB_Bot $bot ) {
    if( !isset(
$bot->angle) ) {
        
$bot->angle rand(0,360);
        
$bot->targets = array();
    }
    
    if( 
count($bot->targets) > ) {
        
// We know targets from last round
        
foreach( $bot->targets AS $k => $t ) {
            
$fire $bot->fire$t->getAngle(), );
            if( 
$fire == 0  ) {
                
// Target is no longer there
                
unset($bot->targets[$k]);
                
// Look 15 degrees prior to its last know angle
                
$bot->angle $t->getAngle() - 15;
            }
        }
    }
    
    
// Look for targets
    
while( count$bot->targets ) == && $bot->getEnergy() >= ) {
        
$scan $bot->scan$bot->angle );
        
$bot->angle = ($bot->angle 10) % 360;
        
        if( 
$scan ) {
            
$bot->targets += $scan;
        }
    }
    
    
// Shoot at known targets
    
if( count($bot->targets) > ) {
        foreach( 
$bot->targets AS $t ) {
            
$bot->fire$t->getAngle(), floor($bot->getEnergy() / count($bot->targets)) );
        }
    }
    

    return 
true;
}

// Setup
SG_WBB::setKey($key);
SG_WBB::setBotVersion($version);
SG_WBB::setTurnHandler'first_turnHandler' );

// Run
SG_WBB::takeTurn();