commit
4ccc98d1df
@ -0,0 +1,11 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<classpath> |
||||
<classpathentry kind="src" path="src"/> |
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/> |
||||
<classpathentry kind="lib" path="/opt/robocode/libs/robocode.jar" sourcepath="robocode-source/robocode-1.9.2.3-src.zip"> |
||||
<attributes> |
||||
<attribute name="javadoc_location" value="file:/opt/robocode/javadoc/"/> |
||||
</attributes> |
||||
</classpathentry> |
||||
<classpathentry kind="output" path="bin"/> |
||||
</classpath> |
@ -0,0 +1,2 @@ |
||||
*.od* filter=lfs diff=lfs merge=lfs -text |
||||
*.pptx* filter=lfs diff=lfs merge=lfs -text |
@ -0,0 +1,3 @@ |
||||
/bin/ |
||||
/robocode-source/ |
||||
|
@ -0,0 +1,17 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<projectDescription> |
||||
<name>robocode</name> |
||||
<comment></comment> |
||||
<projects> |
||||
</projects> |
||||
<buildSpec> |
||||
<buildCommand> |
||||
<name>org.eclipse.jdt.core.javabuilder</name> |
||||
<arguments> |
||||
</arguments> |
||||
</buildCommand> |
||||
</buildSpec> |
||||
<natures> |
||||
<nature>org.eclipse.jdt.core.javanature</nature> |
||||
</natures> |
||||
</projectDescription> |
@ -0,0 +1,11 @@ |
||||
eclipse.preferences.version=1 |
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled |
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 |
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve |
||||
org.eclipse.jdt.core.compiler.compliance=1.7 |
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate |
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate |
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate |
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error |
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error |
||||
org.eclipse.jdt.core.compiler.source=1.7 |
@ -0,0 +1,3 @@ |
||||
# robocode |
||||
|
||||
Don't forget to link `./src/myrobot/` to `C:/robocode/robots/myrobot/` |
@ -0,0 +1,58 @@ |
||||
package myrobot; |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/******************************************************************************* |
||||
* Copyright (c) 2001-2014 Mathew A. Nelson and Robocode contributors |
||||
* All rights reserved. This program and the accompanying materials |
||||
* are made available under the terms of the Eclipse Public License v1.0 |
||||
* which accompanies this distribution, and is available at |
||||
* http://robocode.sourceforge.net/license/epl-v10.html
|
||||
*******************************************************************************/ |
||||
|
||||
|
||||
|
||||
import robocode.HitByBulletEvent; |
||||
import robocode.Robot; |
||||
import robocode.ScannedRobotEvent; |
||||
|
||||
|
||||
/** |
||||
* MyFirstRobot - a sample robot by Mathew Nelson. |
||||
* <p/> |
||||
* Moves in a seesaw motion, and spins the gun around at each end. |
||||
* |
||||
* @author Mathew A. Nelson (original) |
||||
*/ |
||||
public class FirstRobot extends Robot { |
||||
|
||||
/** |
||||
* MyFirstRobot's run method - Seesaw |
||||
*/ |
||||
public void run() { |
||||
|
||||
while (true) { |
||||
ahead(100); // Move ahead 100
|
||||
turnGunRight(360); // Spin gun around
|
||||
back(100); // Move back 100
|
||||
turnGunRight(360); // Spin gun around
|
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Fire when we see a robot |
||||
*/ |
||||
public void onScannedRobot(ScannedRobotEvent e) { |
||||
fire(1); |
||||
} |
||||
|
||||
/** |
||||
* We were hit! Turn perpendicular to the bullet, |
||||
* so our seesaw might avoid a future shot. |
||||
*/ |
||||
public void onHitByBullet(HitByBulletEvent e) { |
||||
turnLeft(90 - e.getBearing()); |
||||
} |
||||
} |
@ -0,0 +1,73 @@ |
||||
package standalone; |
||||
|
||||
import robocode.control.*; |
||||
//import robocode.control.events.*;
|
||||
|
||||
//asdfafd
|
||||
//...
|
||||
|
||||
public class RouteFinder { |
||||
|
||||
public static void main(String[] args) { |
||||
|
||||
// Create the RobocodeEngine, e.g. "C:/robocode"
|
||||
RobocodeEngine engine = new RobocodeEngine(new java.io.File("/opt/robocode")); |
||||
|
||||
// Show the Robocode battle view
|
||||
engine.setVisible(true); |
||||
|
||||
// Create the battlefield
|
||||
int NumPixelRows = 800; |
||||
int NumPixelCols = 600; |
||||
|
||||
BattlefieldSpecification battlefield = new BattlefieldSpecification(NumPixelRows, NumPixelCols); // 800x600
|
||||
|
||||
// Setup battle parameters
|
||||
int numberOfRounds = 1; |
||||
long inactivityTime = 10000000; |
||||
double gunCoolingRate = 1.0; |
||||
int sentryBorderSize = 50; |
||||
boolean hideEnemyNames = false; |
||||
|
||||
// int NumObstacles = (int) Math.round(NumPixelCols * NumPixelRows * 0.3);
|
||||
int NumObstacles = 5; |
||||
|
||||
/* |
||||
* Create obstacles and place them at random so that no pair of obstacles are at the same position |
||||
*/ |
||||
RobotSpecification[] modelRobots = engine.getLocalRepository("sample.SittingDuck,myrobot.FirstRobot*"); |
||||
|
||||
RobotSpecification[] existingRobots = new RobotSpecification[NumObstacles + 1]; |
||||
RobotSetup[] robotSetups = new RobotSetup[NumObstacles + 1]; |
||||
|
||||
for (int NdxObstacle = 0; NdxObstacle < NumObstacles; NdxObstacle++) { |
||||
|
||||
// double InitialObstacleRow = null;
|
||||
// double InitialObstacleCol = null;
|
||||
existingRobots[NdxObstacle] = modelRobots[0]; |
||||
robotSetups[NdxObstacle] = new RobotSetup(null, null, 0.0); |
||||
} |
||||
|
||||
/* |
||||
* Create the agent and place it in a random position without obstacle |
||||
*/ |
||||
existingRobots[NumObstacles] = modelRobots[1]; |
||||
// double InitialAgentRow = 1;
|
||||
// double InitialAgentCol = 1;
|
||||
robotSetups[NumObstacles] = new RobotSetup(null, null, 0.0); |
||||
|
||||
/* Create and run the battle */ |
||||
BattleSpecification battleSpec = new BattleSpecification(battlefield, numberOfRounds, inactivityTime, gunCoolingRate, |
||||
sentryBorderSize, hideEnemyNames, existingRobots, robotSetups); |
||||
|
||||
// Run our specified battle and let it run till it is over
|
||||
engine.runBattle(battleSpec, true); // waits till the battle finishes
|
||||
|
||||
// Cleanup our RobocodeEngine
|
||||
engine.close(); |
||||
|
||||
// Make sure that the Java VM is shut down properly
|
||||
System.exit(0); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue