... you try, try again. And that is exactly what I needed to do this time around. All the steps leading up to creating the distribution took a lot of trial and error. I was able to follow the steps in the powerpoint to create my own project and successfully run ant. Ant is a build tool that allows you to distribute your program to others regardless of platform and other settings. After that, I needed to run quality assurance tests on my code. The checks I needed to run were Checkstyle, PMD, and FindBugs. Between the 3 of them both errors coding standards and logic in the code are shown. Checkstyle reported 6 errors: 1 for not naming my class with a capital letter, 1 for not including the package.html, 2 for not ending the sentence with a period in the JavaDoc, and 2 for not adding the @param for my event functions. But those were all fixed easily enough. PMD and FindBugs didn't report any errors. Setting up JUnit was easy enough, but a silly oversight had me working on it for a while. It turned out I didn't change a package name which I thought I had. Everything else went smoothly.
It was very clear to me very early on how powerful this automated QA was. It was much quicker to find out exactly what the problem was and go back to make some changes. Then it was very fast to run the check again and see if the problem had been solved. One other thing that I realized was that the error messages are very important. Just like how we learned that descriptive comments are very important to understand the code, the messages that errors give are crucial in raising the chances that the problem can be found and fixed. Even with a good error message, it still took me some time to digest what the error was and how to fix it. If the error message had not been descriptive, I may have never found out what the problem was. This tells me that when I write ant code, I really need to be conscious of what error message I display.
You can download my distribution here
*Updated version: here
Wednesday, September 30, 2009
Sunday, September 20, 2009
Runner
My robot tries to take advantage of going in the corner so the radar doesn't need to move around as much. When it gets hit, it it runs around trying to dodge bullets and waste opponent's energy. Runner's behavior is descibed below.
Movement: It goes to the bottom left corner and stays there unless it gets hit. If it gets hit, It runs along the bottom trying to waste opponents energy.
Targeting: Since it goes in the corner, it only scans 90 degrees.
Firing: It fires whenever it sees a robot using power proportional to the distance.
I tested my robot against 8 sample robots: Walls, RamFire, SpinBot, Crazy, Fire, Corners, Tracker, and SittingDuck. The results are below.
Win: RamFire, Crazy, SittingDuck
Tie: Fire, Corners, Tracker
Lose: Walls, Spinbot
It was much more challenging coming up with my own strategy for this robot. There was more trial and error to try to make it more effective. You think that one thing is going to work, but then it doesn't so you need to scrap it and start over again. Also, trying to make it match up well against 8 different robots made it more challenging.
Next time, I think I'm going to try with a completely different strategy. Now even though my current robot isn't very competitive, at least I know some things to avoid.
Download Here
Movement: It goes to the bottom left corner and stays there unless it gets hit. If it gets hit, It runs along the bottom trying to waste opponents energy.
Targeting: Since it goes in the corner, it only scans 90 degrees.
Firing: It fires whenever it sees a robot using power proportional to the distance.
I tested my robot against 8 sample robots: Walls, RamFire, SpinBot, Crazy, Fire, Corners, Tracker, and SittingDuck. The results are below.
Win: RamFire, Crazy, SittingDuck
Tie: Fire, Corners, Tracker
Lose: Walls, Spinbot
It was much more challenging coming up with my own strategy for this robot. There was more trial and error to try to make it more effective. You think that one thing is going to work, but then it doesn't so you need to scrap it and start over again. Also, trying to make it match up well against 8 different robots made it more challenging.
Next time, I think I'm going to try with a completely different strategy. Now even though my current robot isn't very competitive, at least I know some things to avoid.
Download Here
Tuesday, September 15, 2009
Robocode's Sample Robots Strategies
When you install Robocode, you see a list of sample robots ready for you to test and become familiar with the Robocode universe. When you see these for the first time, not having written any Robots, they seem to be very sophisticated and you begin to question whether you can write a robot that can compete with the default set of robots. Are these seemingly creative and complex robots really that good? Below is a list of 8 robots which are described based on movement, tracking, and shooting.
Walls
1. Movement: This robot moves along the walls, from corner to corner, nonstop.
2. Targeting: Walls' radar doesn't turn and always faces to the opposite side of the battlefield.
3. Firing: It shoots when it is facing a robot.
RamFire
1. Movement: RamFire chases its enemy to ram them to cause damage.
2. Targeting: When this robot doesn't have a target, it spins around until it finds one. If it goes to an enemy, but the enemy is no longer there, it once again spins around until it's radar finds a robot.
3. Firing: It shoots at max power when it rams into an opponent causing a great amount of damage. Very aggressive!
SpinBot
1. Movement: It goes around in a circle over and over, unless it runs into another robot, in which case it was turn so it can continue doing donuts.
2. Targeting: It's radar always faces forwards. So as the robot spins, the radar is able to scan the entire battlefield.
3. Firing: SpinBot's shoots a bullet at max speed when it's radar picks up an enemy.
Crazy
1. Movement: This robot runs around in a very erratic pattern. It consists of movements like a sin/cos wave and semi circles. It is unpredictable for other robots. It even drives backwards when it hits a wall!
2. Targeting: Crazy's radar, like most of the previously review robots, only faces forward; never turning. It crazy, hence the name, movement also results in an unpredictable radar.
3. Firing: When it finds a enemy on its radar, it fires a low power bullet.
Fire
1. Movement: This robot doesn't move unless it gets hit. Then, it just does a simple move forwards or backwards to avoid multiple hits.
2. Targeting: Fire's radar spins until it finds an enemy. It keeps locked on until the radar looses track. Then the radar spins again to find a robot.
3. Firing: It fires hard if it has a lot of energy left and the enemy is close. If not, it just fires with low power.
Sitting Duck
1. Movement: It doesn't move. At all. Not even when it's hit.
2. Targeting: It doesn't turn and doesn't scan.
3. Firing: Can you guess when Sitting Duck fires? Never. Hard not to feel a little bad for this yellow robot.
Corners
1. Movement: This robot goes straight up to the top of the battlefield, then goes to the top left corner and just sits there. If it does poorly this round (75% of robots still alive when it dies), it chooses a new corner for next round.
2. Targeting: When in the corner, Corners sweeps it radar back and forth. Since it is in a corner, it only needs to sweep 90 degrees.
3. Firing: When it finds an opponent, it fires with a strength proportional to the distance to the enemy.
Tracker
1. Movement: Tracker chases a robot until it is 150 pixels away. If the other robot gets closer than 100 pixels it runs 40 pixels to get more space.
2. Targeting: This robot uses a clever tracking system to turn its radar based on the number of turns it loses track of the enemy. This results in a effective targeting system.
3. Firing: When it is at an optimal distance from the opponent and sees it on the radar, Tracker shoots with maximum power since it is so close.
Walls
1. Movement: This robot moves along the walls, from corner to corner, nonstop.
2. Targeting: Walls' radar doesn't turn and always faces to the opposite side of the battlefield.
3. Firing: It shoots when it is facing a robot.
RamFire
1. Movement: RamFire chases its enemy to ram them to cause damage.
2. Targeting: When this robot doesn't have a target, it spins around until it finds one. If it goes to an enemy, but the enemy is no longer there, it once again spins around until it's radar finds a robot.
3. Firing: It shoots at max power when it rams into an opponent causing a great amount of damage. Very aggressive!
SpinBot
1. Movement: It goes around in a circle over and over, unless it runs into another robot, in which case it was turn so it can continue doing donuts.
2. Targeting: It's radar always faces forwards. So as the robot spins, the radar is able to scan the entire battlefield.
3. Firing: SpinBot's shoots a bullet at max speed when it's radar picks up an enemy.
Crazy
1. Movement: This robot runs around in a very erratic pattern. It consists of movements like a sin/cos wave and semi circles. It is unpredictable for other robots. It even drives backwards when it hits a wall!
2. Targeting: Crazy's radar, like most of the previously review robots, only faces forward; never turning. It crazy, hence the name, movement also results in an unpredictable radar.
3. Firing: When it finds a enemy on its radar, it fires a low power bullet.
Fire
1. Movement: This robot doesn't move unless it gets hit. Then, it just does a simple move forwards or backwards to avoid multiple hits.
2. Targeting: Fire's radar spins until it finds an enemy. It keeps locked on until the radar looses track. Then the radar spins again to find a robot.
3. Firing: It fires hard if it has a lot of energy left and the enemy is close. If not, it just fires with low power.
Sitting Duck
1. Movement: It doesn't move. At all. Not even when it's hit.
2. Targeting: It doesn't turn and doesn't scan.
3. Firing: Can you guess when Sitting Duck fires? Never. Hard not to feel a little bad for this yellow robot.
Corners
1. Movement: This robot goes straight up to the top of the battlefield, then goes to the top left corner and just sits there. If it does poorly this round (75% of robots still alive when it dies), it chooses a new corner for next round.
2. Targeting: When in the corner, Corners sweeps it radar back and forth. Since it is in a corner, it only needs to sweep 90 degrees.
3. Firing: When it finds an opponent, it fires with a strength proportional to the distance to the enemy.
Tracker
1. Movement: Tracker chases a robot until it is 150 pixels away. If the other robot gets closer than 100 pixels it runs 40 pixels to get more space.
2. Targeting: This robot uses a clever tracking system to turn its radar based on the number of turns it loses track of the enemy. This results in a effective targeting system.
3. Firing: When it is at an optimal distance from the opponent and sees it on the radar, Tracker shoots with maximum power since it is so close.
Monday, September 14, 2009
Coding Standards For You and For Me
Coding standards are something that all students learn when they first start taking programming courses. At first, when everyone is worried about just figuring out how to make their program work, comments and the like are the last thing on a student's mind. As I have progressed through the ICS courses I have taken, the benefits of coding standards become more and more clear.
The biggest reason that I see for coding standards is for anyone to be able to understand how the code works. While it is beneficial for other to be able to read your code, the advantages extend to the author of the code themself! I have come back to code that I have written months before and took a long time to figure out what I was trying to do. It is never a bad thing for your code to be clear and easy to understand.
Also, the ability for anyone in the coding community to learn and collaborate is extremely powerful. Programmers on a team can quickly understand each others code and when it is put all together, everything that someone was interested in would all be consolidated and is all of the same form. Without coding standards, open source software couldn't exist.
I applied the coding standards that we learned in class to the robocode robots that I have previously written. Some of them didn't work and I had a bunch of trouble figuring them out. Looking at the examples of Kendyll Doi and Kimberly Heu, I was able to get my robots working and improved on my previous implementations. At first, I didn't have any comments and probably broke a majority of the rules. Now that I have applied the standards, it is evident that my code is much cleaner and is much easier for someone else to read.
The coding standards that were applied to my robocode project are below:
Elements of Java Style
ICS Coding Standards
ICS Robocode Standards
Download my robocode project here
The biggest reason that I see for coding standards is for anyone to be able to understand how the code works. While it is beneficial for other to be able to read your code, the advantages extend to the author of the code themself! I have come back to code that I have written months before and took a long time to figure out what I was trying to do. It is never a bad thing for your code to be clear and easy to understand.
Also, the ability for anyone in the coding community to learn and collaborate is extremely powerful. Programmers on a team can quickly understand each others code and when it is put all together, everything that someone was interested in would all be consolidated and is all of the same form. Without coding standards, open source software couldn't exist.
I applied the coding standards that we learned in class to the robocode robots that I have previously written. Some of them didn't work and I had a bunch of trouble figuring them out. Looking at the examples of Kendyll Doi and Kimberly Heu, I was able to get my robots working and improved on my previous implementations. At first, I didn't have any comments and probably broke a majority of the rules. Now that I have applied the standards, it is evident that my code is much cleaner and is much easier for someone else to read.
The coding standards that were applied to my robocode project are below:
Elements of Java Style
ICS Coding Standards
ICS Robocode Standards
Download my robocode project here
Wednesday, September 9, 2009
Battle to the death!
Robocode is a program that lets you program your own robot to fight other robots on a virtual battlefield. The robots can run around, scan for enemies with a radar, and shoot with a gun. The more strategy you put into your robot, the better it will fair in the arena.
Getting Robocode installed and working with eclipse was easy with the help of the video guide. I had no problems getting it all to work. The tricky part came with programming the robots.
We had 12 robots to program. Each focusing on one of the 3 main actions of the robots: running, targeting, and shooting. Getting the robots to move around wasn't too difficult. I couldn't figure out how to use the trigonometry so I had to resort to vertical and horizontal movements. The tracking gave me a lot more trouble and my robots still aren't working the way they're supposed to. I couldn't get the robots that required tracking of a single enemy robot working correctly. The firing wasn't as difficult. The shooting was pretty straightforward after the tracking robots. I used the following page and it was really helpful. Link
Robocode has been a really interesting way to practice programming. It was really different seeing the code you write reflect robots fighting each other on screen. It was certainly more entertaining than the regular coding. I think this is a great way to get students more interested in programming and more courses should try to incorporate something like this to break the cycle of plain programs week after week.
Robocode project: Download
Getting Robocode installed and working with eclipse was easy with the help of the video guide. I had no problems getting it all to work. The tricky part came with programming the robots.
We had 12 robots to program. Each focusing on one of the 3 main actions of the robots: running, targeting, and shooting. Getting the robots to move around wasn't too difficult. I couldn't figure out how to use the trigonometry so I had to resort to vertical and horizontal movements. The tracking gave me a lot more trouble and my robots still aren't working the way they're supposed to. I couldn't get the robots that required tracking of a single enemy robot working correctly. The firing wasn't as difficult. The shooting was pretty straightforward after the tracking robots. I used the following page and it was really helpful. Link
Robocode has been a really interesting way to practice programming. It was really different seeing the code you write reflect robots fighting each other on screen. It was certainly more entertaining than the regular coding. I think this is a great way to get students more interested in programming and more courses should try to incorporate something like this to break the cycle of plain programs week after week.
Robocode project: Download
Subscribe to:
Posts (Atom)