Importorg.robochina.airobot.tank.*;Importorg.robochina.math.*;Importjava.awt.geom.*;ImportJava.util.*;/*** This class corresponds to a robot, and according to the need to implement the corresponding action function, * can be customized for their own robot. */ Public classTextextendssimplerobot{//first you need to define two speeds, one is the speed of movement, and the speed of rotation Private Static Final DoubleTurn_velocity = Math.toradians (3); Private Static Final DoubleGo_velocity = 5; //The arc radius can be computed based on these two variables. Private Static Final DoubleR = go_velocity/turn_velocity; /*** Each unit time will be triggered*/ Public voidOnTick (tickaction action) {move (go_velocity); Turn (turn_velocity); Waitjiao (Math.toradians (270)); Turn (0); Waitdistance (R* *); Turn (-turn_velocity); Waitjiao (Math.toradians (270)); Turn (0); Waitdistance (R* *); } /*** Triggers when a new round of games is started*/ Public voidOnroundbegin (roundbeginaction action) {}//wait for the robot to walk the length of this line. Private voidWaitdistance (Doubledisplance) { intTime = (int) (displance/go_velocity); for(inti = 0; I <time; i++) {delay (); } } Private voidWaitjiao (DoubleJiaodu) { intTime = (int) (jiaodu/turn_velocity); for(inti = 0; I <time; i++) {delay (); } } /*** Triggered at the end of a round of matches*/ Public voidOnroundfinish (roundfinishaction action) {}/*** Triggers when a new game is started*/ Public voidOnmatchbegin (matchbeginaction action) {}/*** Triggers when the whole game is over*/ Public voidOnmatchfinish (matchfinishaction action) {}/*** Triggers when a teammate sends a message to himself*/ Public voidonmessagereceived (messagereceivedaction action) {}/*** Triggered when hitting another robot*/ Public voidOnhitrobot (hitrobotaction action) {}/*** Triggered when hitting a wall*/ Public voidOnhitwall (hitwallaction action) {}/*** triggered when any robot fires*/ Public voidOnfire (fireaction action) {}/*** Triggers when a robot dies*/ Public voidOnrobotdeath (robotdeathaction action) {}/*** Triggers when your own bullets hit an enemy*/ Public voidOnbullethit (bullethitaction action) {}/*** triggered when hit by someone else's bullet*/ Public voidOnhitedbybullet (hitedbybulletaction action) {}/*** Robot Program Entry *@paramargs*/ Public Static voidMain (string[] args) {startup (args,NewText ()); }} 2:Importorg.robochina.airobot.tank.*;Importorg.robochina.math.*;Importjava.awt.geom.*;ImportJava.util.*;/*** This class corresponds to a robot, and according to the need to implement the corresponding action function, * can be customized for their own robot. */ Public classFirgureextendssimplerobot{//first you need to define two speeds, one is the speed of movement, and the speed of rotation Private Static Final DoubleTurn_velocity = Math.toradians (3); Private Static Final DoubleGo_velocity = 5; //The arc radius can be computed based on these two variables. Private Static Final DoubleR = go_velocity/turn_velocity; /*** Each unit time will be triggered*/ Public voidOnTick (tickaction action) {}/*** Triggers when a new round of games is started*/ Public voidOnroundbegin (roundbeginaction action) { while(true) {move (go_velocity); Turn (turn_velocity); Waitjiao (Math.toradians (270)); Turn (0); Waitdistance (R* *); Turn (-turn_velocity); Waitjiao (Math.toradians (270)); Turn (0); Waitdistance (R* *); } } //wait for the robot to walk the length of this line. Private voidWaitdistance (Doubledisplance) { intTime = (int) (displance/go_velocity); for(inti = 0; I <time; i++) {delay (); } } Private voidWaitjiao (DoubleJiaodu) { intTime = (int) (jiaodu/turn_velocity); for(inti = 0; I <time; i++) {delay (); } } /*** Triggered at the end of a round of matches*/ Public voidOnroundfinish (roundfinishaction action) {}/*** Triggers when a new game is started*/ Public voidOnmatchbegin (matchbeginaction action) {}/*** Triggers when the whole game is over*/ Public voidOnmatchfinish (matchfinishaction action) {}/*** Triggers when a teammate sends a message to himself*/ Public voidonmessagereceived (messagereceivedaction action) {}/*** Triggered when hitting another robot*/ Public voidOnhitrobot (hitrobotaction action) {}/*** Triggered when hitting a wall*/ Public voidOnhitwall (hitwallaction action) {}/*** triggered when any robot fires*/ Public voidOnfire (fireaction action) {}/*** Triggers when a robot dies*/ Public voidOnrobotdeath (robotdeathaction action) {}/*** Triggers when your own bullets hit an enemy*/ Public voidOnbullethit (bullethitaction action) {}/*** triggered when hit by someone else's bullet*/ Public voidOnhitedbybullet (hitedbybulletaction action) {}/*** Robot Program Entry *@paramargs*/ Public Static voidMain (string[] args) {startup (args,Newfirgure ()); }}
Import Org.robochina.airobot.tank.*;import org.robochina.math.*;import java.awt.geom.*;import java.util.*;/** * This class corresponds to a robot, and the corresponding action handler function is implemented as needed, and the robot can be customized. */public class Firgure extends simplerobot{//first need to define two speed one is moving speed, and turning speed private static final double turn_velocity = Math.toradians (3);p rivate static final double go_velocity = 5;//According to these two variables can be computed out arc radius private static final double R = go_velocit y/turn_velocity;/** * Each unit time will trigger */public void OnTick (Tickaction action) {}/** * trigger */public void when starting a new round of matches Onroundbeg In (Roundbeginaction action) {while (true) {move (go_velocity); turn (turn_velocity); Waitjiao (Math.toradians (360)); Turn (0); waitdistance (r*2);}} Wait for this robot to pass the length of this straight line private void waitdistance (double displance) {int time = (int) (displance/go_velocity); for (int i = 0; I &l T;time; i++) {delay ();}} private void Waitjiao (double jiaodu) {int time = (int) (jiaodu/turn_velocity); for (int i = 0; I <time; i++) {delay ()}} /** * triggers */public void onroundfinish (Roundfinishaction action) {}/** * When the end of a round match)When starting a new match trigger */public void Onmatchbegin (Matchbeginaction action) {}/** * When the entire game is over, */public void Onmatchfinish is triggered ( Matchfinishaction action) {}/** * triggers */public void onmessagereceived (messagereceivedaction action) when a teammate sends a message to himself {}/** * Trigger */public void Onhitrobot (Hitrobotaction action) {}/** * when hitting a wall) */public void Onhitwall (hitwallaction action) {}/** * triggers */public void Onfire (Fireaction action) {}/** * when any robot fires) */public void Onrobotdeath When a robot dies (robotdeathacti On action) {}/** * triggers */public void Onbullethit (bullethitaction action) when its own bullets hit an enemy {}/** * triggers */public void when hit by someone else's bullet onhite Dbybullet (hitedbybulletaction action) {}/** * Robot program entry * @param args */public static void main (string[] args) {startup (args, New Firgure ());}}
This code is to walk a circle and walk a straight line, and keep repeating
There are move rules 2