Die deutschsprachige Zug CoderDojo 2020 Frühlings Herausforderung beginnt am 13. April, bald ist es soweit!
Falls Du teilnehmen möchtest ist es nicht zu spät Dich zu registrieren. Du findest alle nötigen Informationen auf dieser Seite.
The English version Zug CoderDojo 2020 Spring Challenge started on April 6th and ends on April 19th. Ab heute arbeiten die Teilnehmer an Ihren eigenen Kreationen.
How do we change the Color
We had that question earlier today from someone else and put some notes on it here: http://swisscoderdojo.org/code-snippets
in short, you can put the following code in your run() method:
setColors(bodycolor, guncolor, radarcolor);
and your choice of colours are: black, blue, brown, gray, green, orange, purple, red, white yellow
How do I get to turn my Robot to the robot I scanned?
Very similar to how we did the Day3 robot.
Before we explain it, you can find all the variables and methods for your tank here: https://robocode.sourceforge.io/docs/robocode/robocode/JuniorRobot.html
To turn your tank towards a scanned enemy you must modify the the onScannedRobot() method and use the turnTo(degrees) method. There is a variable available to you called scannedAngle which is set to the direction (in degrees) that an enemy is scanned at. The scannedAngle variable is set right before the onScannedRobot() method is called, but it is reset as soon as your gun or your tank starts to turn. The reason this is important is that you want to turn your tank towards the enemy, and then make sure your gun is pointed towards the enemy after your tank is rotated. So you will have to create a local variable to store the scannedAngle so that you can turn both your tank and the gun towards the enemy. Here is what your onScannedRobot() method should look like:
public void onScannedRobot() {
int iScanAngle = scannedAngle;
turnTo(iScanAngle);
turnGunTo(iScanAngle);
}
Ive made a robot similar to RamFire. How do I keep the gun pointing at the Robot I fire and when it ‘runs’ away but put the gun back afterwards?
Predictive Aiming is tricky, but possible. You will have to abandon the JuniorRobot class and start extending the Robot class instead. There is a great tutorial online that deals with Predictive Aiming. Lesson 4 covers it, but here is the full series online:
Lesson 2 (battlefield)
Lesson 3 (scanning)
Lesson 4 (gun)
Lesson 5 (movement)
Also an interesting tutorial on IBMs developer site
IBM Robocode – tracking your opponent
How do I turn the gun back to the same angle as the wheels?
Hi Dillon
Check https://robocode.sourceforge.io/docs/robocode/robocode/JuniorRobot.html
bearGunTo(int angle)
Turns the gun to the specified angle (in degrees) relative to body of this robot.
Which means bearGunTo(0) turns the gun straight ahead.
I tried it but it said “The method bearGunTo(int) is undefined for the type TheEnd”
Are you using a JuniorRobot? The method is defined for JuniorRobot
turnGunTo(heading);
where do I send the robot?
Check this post on the website http://swisscoderdojo.org/2020-spring-home-challenge-submission-rules-and-judging-criteria
Also had sent e-mail this afternoon about it
public void onHitRobot(HitRobotEvent e) {
setTurnGunRight(getHeading() – getGunHeading() + e.getBearing());
if (e.getBearing() >= 0) {
turnDirection = 1;
} else {
turnDirection = -1;
}
turnRight(e.getBearing());
if (e.getEnergy() > 16) {
fire(3);
} else if (e.getEnergy() > 10) {
fire(3);
} else if (e.getEnergy() > 4) {
fire(3);
} else if (e.getEnergy() > 2) {
fire(3);
} else if (e.getEnergy() > .4) {
fire(3);
}
bearGunTo(0);
ahead(40); // Ram him again!
}
That is my onHitRobot
Dillon that method is part of the Robot class and not the JuniorRobot class. If you want me to look at your code, please email your java file to us at home.challenge@swisscoderdojo.org and also tell me in the email what you want your robot to do or what it is not doing for you and I will try and help.
I used advancedrobot
how do you put the sonic pie in a mp3 file or where you can send it to family
Hi Arjun
Sonic Pi doesn’t allow saving the file directly to mp3. But from within Sonic Pi you can click the rec (record) button top/middle, this saves the melody into a .wav file:
– hit the record button
– hit run (the melody plays and records at the same time)
– once the melody has stopped playing hit the rec button again – this will stop the recording and prompt you for a filename to save the file.
The file has filetype .wav, which plays on windows.
If you need an mp3 file you can convert it using windows media player or the open source program vlc (https://www.videolan.org/vlc/download-windows.html). There are also online converters available which do the job (you find these by doing a Google search); please check with your parents before using any of the online tools.
how many projects are we supposed to submit for the spring home challenge 2020?
Just one submission