Tag 5+ – 2020 Frühlings Home Challenge

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.

20 thoughts on “Tag 5+ – 2020 Frühlings Home Challenge

    • CoderDojo Zug

      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

  1. Dillon

    How do I get to turn my Robot to the robot I scanned?

    • CoderDojo Zug

      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);
      }

  2. Dillon

    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?

  3. Dillon

    How do I turn the gun back to the same angle as the wheels?

  4. Dillon

    I tried it but it said “The method bearGunTo(int) is undefined for the type TheEnd”

    • Peter Pircher Post author

      Are you using a JuniorRobot? The method is defined for JuniorRobot

  5. Dillon

    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

    • CoderDojo Zug

      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.

  6. arjun

    how do you put the sonic pie in a mp3 file or where you can send it to family

    • Peter Pircher Post author

      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.

  7. Adarsh

    how many projects are we supposed to submit for the spring home challenge 2020?

Comments are closed.