• Lucid Dreaming - Dream Views




    Results 1 to 19 of 19

    Thread: Robocode game.

    1. #1
      Member
      Join Date
      Aug 2003
      Posts
      234
      Likes
      0

      Robocode game.

      Anyone here use Robocode?

      Search for it.

    2. #2
      He will have his revenge Aphius's Avatar
      Join Date
      Oct 2003
      Gender
      Location
      Halloween Town
      Posts
      1,955
      Likes
      4
      Hm... I'm learning Java right now, so maybe I'll have a look at it.
      These are the tears that I dream about...

    3. #3
      Banned
      Join Date
      Oct 2003
      Location
      Omaha, NE
      Posts
      962
      Likes
      0
      don't you just love the way sun can count!

      "Java 2 version 1.3"

    4. #4
      Member Kaniaz's Avatar
      Join Date
      Jan 2004
      Gender
      Location
      England
      Posts
      5,441
      Likes
      9
      Haven't you heard? It's the new "Elite Company" numbering system! It works on the basis you increase the number several times without making any changes to make the software look better than it really is! Works like a charm!

    5. #5
      Banned
      Join Date
      Oct 2003
      Location
      Omaha, NE
      Posts
      962
      Likes
      0
      Eh, this is pretty fun.

    6. #6
      Member
      Join Date
      Aug 2003
      Posts
      234
      Likes
      0

    7. #7
      Banned
      Join Date
      Oct 2003
      Location
      Omaha, NE
      Posts
      962
      Likes
      0
      Code:
      package ddi;
      
      import robocode.*;
      
      import java.awt.Color;
      
      
      
      /**
      
       * Dougs - a robot by (Doug Ives, dougdrums.com)
      
       */
      
      public class Dougs extends Robot
      
      {
      
      ****int turnDirection = 1;****
      
      ****public void run() {
      
       *setColors(Color.orange,Color.red,Color.yellow);
      
       *while(true) {****
      
       *****ahead(100);
      
       *****turnGunRight(360);
      
       *****back(100);
      
       *****turnGunRight(360);****
      
       *}
      
      ****}
      
      
      
      ****public void onScannedRobot(ScannedRobotEvent e) {
      
       *fire(1);
      
       *turnLeft(90 - e.getBearing());
      
       *if (e.getBearing() >= 0)
      
       *****turnDirection = 1;
      
       *else
      
       *****turnDirection = -1;
      
       *****
      
       *turnRight(e.getBearing());
      
       *ahead(e.getDistance() + 5);
      
       *scan();
      
      ****}
      
      
      
      ****public void onHitByBullet(HitByBulletEvent e) {
      
       *turnLeft(90 - e.getBearing());
      
       *ahead(300);
      
      ****}
      
      ****
      
      ****public void onHitWall(HitWallEvent e) {
      
       * * *turnRight(90 - e.getBearing());
      
       *ahead(200);
      
       * *}
      
      ****
      
      ****public void onHitRobot(HitRobotEvent e){
      
       *if (e.getBearing() >= 0)
      
       *****turnDirection = 1;
      
       *else
      
       *****turnDirection = -1;
      
       *****turnRight(e.getBearing());
      
       *****
      
       *if (e.getEnergy() > 99)
      
       *****fire(3);
      
       *else if (e.getEnergy() > 50)
      
       *****fire(2);
      
       *else if (e.getEnergy() > 25)
      
       *****fire(1);
      
       *else if (e.getEnergy() > 10)
      
       *****fire(.75);
      
       *else if (e.getEnergy() > 5)
      
       *****fire(.5);
      
       *ahead(40); // ram
      
      ****}
      
      ****}
      
      ****
      
      ****public void onWin(WinEvent e){
      
       *turnLeft(359);
      
       *ahead(10);
      
       *turnRight(359);
      
       *back(10);
      
      ****}
      
      }

    8. #8
      Member
      Join Date
      Aug 2003
      Posts
      234
      Likes
      0
      HAHAHA!!! You can't fire higher than three! And you should extend to AdvancedRobot. You can then move radar, gon, and tank independently.

    9. #9
      Banned
      Join Date
      Oct 2003
      Location
      Omaha, NE
      Posts
      962
      Likes
      0
      Yeah, figured out the fire no more than three thing. Fixed.

    10. #10
      Member
      Join Date
      Aug 2003
      Posts
      234
      Likes
      0
      Hahaha, Gary Coleman.

    11. #11
      Banned
      Join Date
      Oct 2003
      Location
      Omaha, NE
      Posts
      962
      Likes
      0
      lmao:

      method summary:
      getLife()
      Deprecated.

    12. #12
      Member
      Join Date
      Aug 2003
      Posts
      234
      Likes
      0

    13. #13
      Banned
      Join Date
      Oct 2003
      Location
      Omaha, NE
      Posts
      962
      Likes
      0

    14. #14
      Member Kaniaz's Avatar
      Join Date
      Jan 2004
      Gender
      Location
      England
      Posts
      5,441
      Likes
      9
      Code:
      /* Robocode 'AlwaysWin' robot by Kaniaz */
      
      cheat();

    15. #15
      Banned
      Join Date
      Oct 2003
      Location
      Omaha, NE
      Posts
      962
      Likes
      0
      Give me one of your (non cheating) bots.

      Code:
      package omg;
      
      import robocode.*;
      
      import java.awt.Color;
      
      
      
      /**
      
       * Omg - a robot by (your name here)
      
       */
      
      public class Omg extends Robot
      
      {
      
      ****/**
      
       ** run: Omg's default behavior
      
       **/
      
      ****double i = 0;
      
      ****double speed1 = 0;
      
      ****double speed2 = 0;
      
      ****double ttlSpeed = 0;
      
      ****double base = 0;
      
      ****int count = 0; * * * * *
      
      ****double gunTurnAmt; *
      
      ****String trackName;
      
      ****int turnDirection = 0;
      
      ****
      
      ****public void run() {
      
       *// After trying out your robot, try uncommenting the import at the top,
      
       *// and the next line:
      
       *setColors(Color.white,Color.black,Color.gray);
      
       *while(true){
      
       *****// turn the Gun (looks for enemy)
      
       *****turnRight(gunTurnAmt);//GunRight(gunTurnAmt);
      
       *****// Keep track of how long we've been looking
      
       *****count++;
      
       *****// If we've haven't seen our target for 2 turns, look left
      
       *****if (count > 2) * *****
      
       *****{
      
       * *gunTurnAmt = -10;
      
       *****}
      
       *****// If we still haven't seen our target for 5 turns, look right
      
       *****if (count > 5)
      
       * *gunTurnAmt = 10;
      
       *****// If we *still* haven't seen our target after 10 turns, find another target
      
       *****if (count > 11)
      
       * *trackName = null;
      
       *}
      
      ****}
      
      
      
      ****/**
      
       ** onScannedRobot: What to do when you see another robot
      
       **/
      
      ****public void onScannedRobot(ScannedRobotEvent e) {
      
       *//turnRadarRight(e.getRadarHeading()-e.getRadarHeading()+e.getBearing());
      
       *//base = e.getGunHeading();
      
       *//turnRadarRight(e.getBearing());
      
       *speed1 = e.getBearing();
      
       *speed2 = e.getBearing();
      
       *ttlSpeed = speed2 - speed1;
      
       *//i = e.getBearing()+ttlSpeed;
      
       *gunTurnAmt = normalRelativeAngle(e.getBearing() + (getHeading() - getRadarHeading()));
      
       *turnRight(gunTurnAmt+ttlSpeed);//GunRight(gunTurnAmt+ttlSpeed);
      
       *fire(3);****
      
      ****}
      
      
      
      ****/**
      
       ** onHitByBullet: What to do when you're hit by a bullet
      
       **/
      
      ****public void onHitByBullet(HitByBulletEvent e) {
      
       *turnLeft(90 - e.getBearing());
      
       *ahead(200);
      
      ****}
      
      ****
      
       * public void onHitWall(HitWallEvent e) { 
      
       * * *turnRight(135); 
      
       * * *ahead(100); 
      
       * *} *
      
      
      
       * public void onHitRobot(HitRobotEvent e){ 
      
       * * *if (e.getBearing() >= 0) 
      
       * * * * turnDirection = 1; 
      
       * * *else 
      
       * * * * turnDirection = -1; 
      
       * * * * turnRight(e.getBearing()); 
      
       * * * * *
      
       * * *if (e.getEnergy() > 100) 
      
       * * * * fire(3); 
      
       * * *else if (e.getEnergy() > 50) 
      
       * * * * fire(3); 
      
       * * *else if (e.getEnergy() > 25) 
      
       * * * * fire(2); 
      
       * * *else if (e.getEnergy() > 10) 
      
       * * * * fire(1); 
      
       * * *else if (e.getEnergy() > 5) 
      
       * * * * fire(.5); 
      
       * * *ahead(40); // ram 
      
       * } 
      
      
      
      ****public double normalRelativeAngle(double angle) {
      
       *if (angle > -180 && angle <= 180)
      
       *****return angle;
      
       *double fixedAngle = angle;
      
       *while (fixedAngle <= -180)
      
       *****fixedAngle += 360;
      
       *while (fixedAngle > 180)
      
       *****fixedAngle -= 360;
      
       *return fixedAngle;
      
      ****}
      
      ****
      
      }

    16. #16
      Member
      Join Date
      Aug 2003
      Posts
      234
      Likes
      0
      You should check out the winning bots. The coding records everything and targets expected future coordinates of enemy bots. Rapture is a great example of a 1 vs. 1 bot. It dodges bullets and has an excellent gun.

      http://www.robocoderepository.com/BotDetail.jsp?id=15

      The site is messed up right now, I had to log in using an admin's password to find it.

    17. #17
      Banned
      Join Date
      Oct 2003
      Location
      Omaha, NE
      Posts
      962
      Likes
      0
      Well, I'll put in the cosine rule (http://www.mathsdirect.co.uk/pure/purtuttrisin.htm) and make it circle around the enemy tonight. That should give it a little more accuracy than the guessing code I used in 0mg.

    18. #18
      Member
      Join Date
      Aug 2003
      Posts
      234
      Likes
      0

    19. #19
      Banned
      Join Date
      Oct 2003
      Location
      Omaha, NE
      Posts
      962
      Likes
      0
      yeah, saw that. Neat stuff.

    Bookmarks

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •