Mu Alpha Theta
Would you like to react to this message? Create an account in a few clicks or log in to continue.

RoboCode

4 posters

Go down

RoboCode Empty RoboCode

Post by Ani Fri Mar 06, 2009 3:07 pm

I found this really neat game which incorporates java programming into it, check it out:
http://robocode.sourceforge.net/
http://robocode.sourceforge.net/help/

In essence, you create your own robot using the java programming language, then battle with it with anyone you want. We could hold competitions on the forums for fun =P
Ani
Ani
Vice-President
Vice-President

Male Number of posts : 236
Age : 31
Location : Kanto
Registration date : 2008-05-02

Back to top Go down

RoboCode Empty Re: RoboCode

Post by Michael Fri Mar 06, 2009 8:15 pm

can we run private servers for a private tournament?
Michael
Michael
Graduated member
Graduated member

Male Number of posts : 151
Age : 32
Registration date : 2008-04-30

http://elkinschess.forummotion.com

Back to top Go down

RoboCode Empty Re: RoboCode

Post by Ani Fri Mar 06, 2009 9:51 pm

Michael wrote:can we run private servers for a private tournament?

I'm not sure how, but I believe so.
In any case, we can use flashdrives to move the programs with our robots around, so that we may battle on the same computer
Ani
Ani
Vice-President
Vice-President

Male Number of posts : 236
Age : 31
Location : Kanto
Registration date : 2008-05-02

Back to top Go down

RoboCode Empty Re: RoboCode

Post by Michael Tue Mar 17, 2009 5:49 pm

how are the bots going? mine manages to get stuck on the walls Sad
Michael
Michael
Graduated member
Graduated member

Male Number of posts : 151
Age : 32
Registration date : 2008-04-30

http://elkinschess.forummotion.com

Back to top Go down

RoboCode Empty Re: RoboCode

Post by Ani Thu Apr 23, 2009 11:33 pm

Michael wrote:how are the bots going? mine manages to get stuck on the walls Sad

Lol, my bot got deleted, but was epic fail while it lasted.
I couldnt make it target properly, so I simply made it spin around and shoot bullets.
Problem solved Smile
Anyone else interested in making a bot?
Its actually really cool!
Ani
Ani
Vice-President
Vice-President

Male Number of posts : 236
Age : 31
Location : Kanto
Registration date : 2008-05-02

Back to top Go down

RoboCode Empty Re: RoboCode

Post by HTang Fri Apr 24, 2009 4:16 pm

Concept seems interesting and could be just the sort of mini-time-waster I've been looking for – for which I've been looking. I'll give it a look later.
HTang
HTang
Graduated member
Graduated member

Male Number of posts : 44
Registration date : 2009-01-28

Back to top Go down

RoboCode Empty Re: RoboCode

Post by Ani Fri Apr 24, 2009 8:32 pm

HTang wrote:Concept seems interesting and could be just the sort of mini-time-waster I've been looking for – for which I've been looking. I'll give it a look later.

Lol, if any of you guys make any bots, post them here so we can check them out
Ani
Ani
Vice-President
Vice-President

Male Number of posts : 236
Age : 31
Location : Kanto
Registration date : 2008-05-02

Back to top Go down

RoboCode Empty Re: RoboCode

Post by Thunderflash Fri Apr 24, 2009 10:37 pm

I'm cosidering it, though I don't know if I have the programming experience

Edit:
I've got a basic robot up, and it does track.
You lose Ani!
Post your robots so we can put them in robocode!
Thunderflash
Thunderflash
Member
Member

Male Number of posts : 90
Age : 30
Location : Formalhaut B
Registration date : 2008-09-05

Back to top Go down

RoboCode Empty Re: RoboCode

Post by Thunderflash Sat Apr 25, 2009 8:39 pm

Well here's what I have so far:
Code:
 package rjh;
import robocode.*;
import java.awt.Color;

/**
 * WallFightRobot - a robot by (Thunder)
 */
public class WallRobot extends Robot
{

   double moveAmount;


   public void run() {



      moveAmount = Math.max(getBattleFieldWidth(), getBattleFieldHeight());

      turnLeft(getHeading() % 90);
      ahead(moveAmount);

      turnGunRight(90);
      turnRight(90);

      while (true) {

         ahead(moveAmount);


         turnRight(90);
      }
   }

   public void onHitRobot(HitRobotEvent e) {

      if (e.getBearing() > -90 && e.getBearing() < 90) {
         back(100);
      }
      else {
         ahead(100);
      }
   }


   public void onScannedRobot(ScannedRobotEvent e) {
                          if(e.getDistance()>500)
      fire(2);
                          else
                          fire(3);
      double enemyBearing = this.getHeading() + e.getBearing();
      double enemyX = getX() + e.getDistance() * Math.sin(Math.toRadians(enemyBearing));
      double enemyY = getY() + e.getDistance() * Math.cos(Math.toRadians(enemyBearing));
      setGun(new Point(enemyX,enemyY));
      }
   
   public void setGun(Point p)
   {
      double dx = p.getX() - this.getX();
      double dy = p.getY() - this.getY();
      double theta = Math.toDegrees(Math.atan2(dx, dy));
      turnGunRight(theta - getGunHeading());
   }
}                     

To use this robot you might need to bring the Point class into the same folder - you can find it under sampleteams-> Point.
You will need to change the package name as well.
Thunderflash
Thunderflash
Member
Member

Male Number of posts : 90
Age : 30
Location : Formalhaut B
Registration date : 2008-09-05

Back to top Go down

RoboCode Empty Re: RoboCode

Post by Michael Sat Apr 25, 2009 10:00 pm

Code:
package testbot2;

import robocode.*;
import java.util.*;
import robocode.util.Utils;

public class TestBot extends AdvancedRobot
{

   private String path;
   
   private boolean stuck;
   
   private double FORWARD=1.8;
   
   public void run()
   {
      double FORWARD=1.8;
      
      do
       {
          execute();
          setTurnGunRight(360);
 
          
          
          stuck=false;
      }
      while (true);

   }

   public void onScannedRobot(ScannedRobotEvent e)
   {
      int dist=(int)e.getDistance();
      
      if(dist<400)
      {
      
         double absoluteBearing = getHeading() + e.getBearing();
         double bearingFromGun = Utils.normalRelativeAngleDegrees(absoluteBearing - getGunHeading());
   
         
         if (getGunHeat() == 0) {
            fire((int)Math.ceil((400-dist)/50.0));
         }
         
      }

      
      if(!stuck)
      {
      
         if (getDistanceRemaining() == 0)
         {
            FORWARD = -FORWARD;
            setAhead(185 * FORWARD);
         }
         
         if(Math.random()<0.5)
            setTurnRightRadians(e.getBearingRadians() + Math.PI/2 - 0.5236 * FORWARD * (e.getDistance() > 200 ? 1 : -1));
         else
            setTurnLeftRadians(e.getBearingRadians() + Math.PI/2 - 0.5236 * FORWARD * (e.getDistance() > 200 ? 1 : -1));
      }
   }
   public void turnTo(double angle)
   {
      setTurnLeft(angle-getHeading());
   }
   public void turnGunTo(double angle)
   {
      setTurnGunLeft(angle-getGunHeading());
   }
   public void onHitWall(HitWallEvent e)
   {
      int mag=10;
      
      stop();
      
      stuck=true;
      
      if(getX()<mag)
      {
      
         turnTo(270+((getY()<getBattleFieldHeight()/2)?-30:30));
         waitFor(new TurnCompleteCondition(this));
         setAhead(200);
      }
      else if(getX()>getBattleFieldWidth()-mag)
      {
         turnTo(90+((getY()<getBattleFieldHeight()/2)?-30:30));
         setAhead(200);
      }
      else if(getY()<mag)
      {
         turnTo(0+((getX()<getBattleFieldWidth()/2)?-30:30));
         setAhead(200);
      }
      else if(getY()>getBattleFieldHeight()-mag)
      {
         turnTo(180+((getX()<getBattleFieldWidth()/2)?-30:30));
         setAhead(200);
      }
   }
}
Michael
Michael
Graduated member
Graduated member

Male Number of posts : 151
Age : 32
Registration date : 2008-04-30

http://elkinschess.forummotion.com

Back to top Go down

RoboCode Empty Re: RoboCode

Post by Ani Sun Apr 26, 2009 12:29 pm

I'm too ashamed to post my robot.... =(
Maybe when I've modified it a bit
Ani
Ani
Vice-President
Vice-President

Male Number of posts : 236
Age : 31
Location : Kanto
Registration date : 2008-05-02

Back to top Go down

RoboCode Empty Re: RoboCode

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum