Skip to main content
import java.util.LinkedList;

public class SideShooter extends Bot {
  
    int[] launcher = new int[]{1, 3, 2, 2, 2};
    String[] right = {"1100000077", "100000007"};
    String[] left  = {"7700000011", "700000001"}; 
    int position = -1;
    int turns = 0;
  
    public String name(){
        return "SideShooter";
    }
    
    public LinkedList<Integer> fireRocket(Rocket[][] g){
      LinkedList<Integer> directions = new LinkedList<Integer>();
            
      do{
          position = (position + 1) % 5;
          curSlot = launcher[position] - 1;
      }while(!getSlot(curSlot));
      
      if(position == 0)
      {
          String shoot = left[((int) (Math.random() * left.length))];
          for(int i=0; i < shoot.length(); i++)
              directions.push(shoot.charAt(i)-'0');
      }else if(position == 1)
      {
          String shoot = right[((int) (Math.random() * right.length))];
          for(int i=0; i < shoot.length(); i++)
              directions.push(shoot.charAt(i)-'0');
      }else
      {
          if(turns < 30)
          {
            if(position == 2 )
                directions.push(0);
            else if(position == 3)
                directions.push(1);
            else if(position == 4)
                directions.push(7);
          }else
              for(int i=0; i < 10; i++)
                  directions.push(0); 
      }
      turns ++;
      return directions;
    }
    
}
import java.util.LinkedList;

public class SideShooter extends Bot {
  
    int[] launcher = new int[]{1, 3, 2, 2, 2};
    String[] right = {"1100000077", "100000007"};
    String[] left  = {"7700000011", "700000001"}; 
    int position = -1;
    int turns = 0;
  
    public String name(){
        return "SideShooter";
    }
    
    public LinkedList<Integer> fireRocket(Rocket[][] g){
      LinkedList<Integer> directions = new LinkedList<Integer>();
      
      if(getSlot(0) || getSlot(1) || getSlot(2))      
          do{
              position = (position + 1) % 5;
              curSlot = launcher[position] - 1;
          }while(!getSlot(curSlot));
      
      if(position == 0)
      {
          String shoot = left[((int) (Math.random() * left.length))];
          for(int i=0; i < shoot.length(); i++)
              directions.push(shoot.charAt(i)-'0');
      }else if(position == 1)
      {
          String shoot = right[((int) (Math.random() * right.length))];
          for(int i=0; i < shoot.length(); i++)
              directions.push(shoot.charAt(i)-'0');
      }else
      {
          if(turns < 30)
          {
            if(position == 2 )
                directions.push(0);
            else if(position == 3)
                directions.push(1);
            else if(position == 4)
                directions.push(7);
          }else
              for(int i=0; i < 10; i++)
                  directions.push(0); 
      }
      turns ++;
      return directions;
    }
    
}
import java.util.LinkedList;

public class SideShooter extends Bot {
  
    int[] launcher = new int[]{1, 3, 2, 2, 2};
    String[] right = {"1100000077", "100000007"};
    String[] left  = {"7700000011", "700000001"}; 
    int position = -1;
    int turns = 0;
  
    public String name(){
        return "SideShooter";
    }
    
    public LinkedList<Integer> fireRocket(Rocket[][] g){
      LinkedList<Integer> directions = new LinkedList<Integer>();
            
      do{
          position = (position + 1) % 5;
          curSlot = launcher[position] - 1;
      }while(!getSlot(curSlot));
      
      if(position == 0)
      {
          String shoot = left[((int) (Math.random() * left.length))];
          for(int i=0; i < shoot.length(); i++)
              directions.push(shoot.charAt(i)-'0');
      }else if(position == 1)
      {
          String shoot = right[((int) (Math.random() * right.length))];
          for(int i=0; i < shoot.length(); i++)
              directions.push(shoot.charAt(i)-'0');
      }else
      {
          if(turns < 30)
          {
            if(position == 2 )
                directions.push(0);
            else if(position == 3)
                directions.push(1);
            else if(position == 4)
                directions.push(7);
          }else
              for(int i=0; i < 10; i++)
                  directions.push(0); 
      }
      turns ++;
      return directions;
    }
    
}
import java.util.LinkedList;

public class SideShooter extends Bot {
  
    int[] launcher = new int[]{1, 3, 2, 2, 2};
    String[] right = {"1100000077", "100000007"};
    String[] left  = {"7700000011", "700000001"}; 
    int position = -1;
    int turns = 0;
  
    public String name(){
        return "SideShooter";
    }
    
    public LinkedList<Integer> fireRocket(Rocket[][] g){
      LinkedList<Integer> directions = new LinkedList<Integer>();
      
      if(getSlot(0) || getSlot(1) || getSlot(2))      
          do{
              position = (position + 1) % 5;
              curSlot = launcher[position] - 1;
          }while(!getSlot(curSlot));
      
      if(position == 0)
      {
          String shoot = left[((int) (Math.random() * left.length))];
          for(int i=0; i < shoot.length(); i++)
              directions.push(shoot.charAt(i)-'0');
      }else if(position == 1)
      {
          String shoot = right[((int) (Math.random() * right.length))];
          for(int i=0; i < shoot.length(); i++)
              directions.push(shoot.charAt(i)-'0');
      }else
      {
          if(turns < 30)
          {
            if(position == 2 )
                directions.push(0);
            else if(position == 3)
                directions.push(1);
            else if(position == 4)
                directions.push(7);
          }else
              for(int i=0; i < 10; i++)
                  directions.push(0); 
      }
      turns ++;
      return directions;
    }
    
}
Source Link
Spikatrix
  • 1.9k
  • 1
  • 17
  • 33

SideShooter

First shoots via the first ( rightmost ) turret in one of two different ways. Then, it shoots via the last ( leftmost ) turret in one of two different ways. Then it makes a "wall" with the second ( middle ) turret by exploding rockets in front of each turret. This process is repeated.

If the game lasts for more than 30 turns, SideShooter grows bored and changes in a small way. Instead of making a "wall" with the second ( middle ) turret, it shoots straight. The rest of the turrets behave the same way.

import java.util.LinkedList;

public class SideShooter extends Bot {
  
    int[] launcher = new int[]{1, 3, 2, 2, 2};
    String[] right = {"1100000077", "100000007"};
    String[] left  = {"7700000011", "700000001"}; 
    int position = -1;
    int turns = 0;
  
    public String name(){
        return "SideShooter";
    }
    
    public LinkedList<Integer> fireRocket(Rocket[][] g){
      LinkedList<Integer> directions = new LinkedList<Integer>();
            
      do{
          position = (position + 1) % 5;
          curSlot = launcher[position] - 1;
      }while(!getSlot(curSlot));
      
      if(position == 0)
      {
          String shoot = left[((int) (Math.random() * left.length))];
          for(int i=0; i < shoot.length(); i++)
              directions.push(shoot.charAt(i)-'0');
      }else if(position == 1)
      {
          String shoot = right[((int) (Math.random() * right.length))];
          for(int i=0; i < shoot.length(); i++)
              directions.push(shoot.charAt(i)-'0');
      }else
      {
          if(turns < 30)
          {
            if(position == 2 )
                directions.push(0);
            else if(position == 3)
                directions.push(1);
            else if(position == 4)
                directions.push(7);
          }else
              for(int i=0; i < 10; i++)
                  directions.push(0); 
      }
      turns ++;
      return directions;
    }
    
}