Monday, October 10, 2011

Your Robot's Way Far! Errr...

     Hey, it's robot's again! Have you been perfecting your's since my last post? I guess you did since you're here. Well, I too have been working on making my robot better. By utilizing some of the things I learned from the katas, I experimented ways to make a robot that could compete with some of the included sample robots of robocode. In my opinion, it's not the best robot, but it's decent and I call it WayFarer! (No, not sunglasses, but thought it sounded to cool to name it after it.)

     For my robot, I took some note from the code katas from the other blog. The design is basically my robot moving back and fourth along an axis. When the robot moves, it scans for enemies, turn its gun towards the enemy and fires every other turn. When the robot hits another robot, it moves away and when the robot gets hit by a bullet, it turns 90 degrees and traverses that axis. So how does this robot perform? Let's see!

     Moving on to testing. I put my robot against 8 of the sample robots:(Corners, Crazy, Fire, RamFire, SittingDuck, SpinBot, Tracker and Walls.) For this test, I ran 100 battles each and recorded the scores. Here are the outcomes:

Enemy Challenged
Rank Against Enemy
Total Score
Survival
Survival Bonus
Bullet Damage
Bullet Bonus
Ram Damage
(x2)
Ram Bonus
1sts
2nds
Corners 1st 15493 (87%) 4850 970 8033 1579 31 0 97 3
Crazy 1st 9380 (69%) 2800 560 5196 700 124 0 60 40
Fire 1st 13177 (92%) 4900 980 9417 1852 29 0 98 2
RamFire 1st 15027 (53%) 3100 620 9492 1201 450 163 62 38
SittingDuck 1st 18034 (100%) 5000 1000 9966 2000 68 0 100 0
SpinBot 1st 9988 (61%) 2900 580 5668 791 49 0 59 41
Tracker 1st 17209 (71%) 4050 810 10366 1742 208 34 81 19
Walls 2nd 3060 (22%) 100 20 2815 41 86 0 2 98

     As you can see, WayFarer is a decent robot, but definitely not the best. It can only defeat one sample robot 100% of the time, but majority, it comes in first place. It;s not perfect, but good. WayFarer is a good robot because it moves constantly and changes direction to dodge incoming bullets. This might be a good strategy, but one robot isn't affected by it, meaning the walls robot as you see on the table. WayFarer doesn't go well against walls because it travels along the "walls" of the battlefield while tracking and shoot. Walls also moves in constant motion, so many bullets shot by WayFarer miss the target. What could be implemented to make WayFarer better is to predict the future location of the enemy to ensure that bullets will hit the target all the time.

     Building more on testing is some JUnit tests I created to tests some robot behaviors. My 4 tests include testing if WayFarer hits a wall, changing direction after being hit, turning its radar to scan enemies and seeing if bullets shot hit the enemy. When WayFarer hits the wall, it confirms that the robot traverses an axis. When WayFarer get's hit by a bullet, it should change directions of the traverse. When WayFarer turns its radar, it ensures that it is scanning and when a shot bullet hits an enemy, it ensures that the gun is pointed at the enemy.

     Overall, designing the perfect robot is not easy. There are some robots that are easier to defeat while others require more thinking. During this development using the Ant build system, inning testing and checking for errors are simple to do and faster than running them manually. Creating projects are now easier to transport for other users to use since the build system automatically installs and downloads required files. I can now see why build systems are viral to many projects and I intend to use it for future projects.

No comments:

Post a Comment