I talked about robocode in one of my previous blogs and practiced with them by using a kata. I went back to those robots and I thought I could improve on them and make a better robot that can battle a bunch of the sample robots that Robocode has already implemented. So I hope to show you what I wanted to try with my battling robot.
I wanted my robot to move in some type of random pattern before acquiring a target, so that it won't be some sitting target while waiting to get a target itself. I devised a random pattern to movement using the random generator in java as well as the modulus of another number and using that to sort through through a switch to randomize the robot's movement. Once the robot has a target, i want it to follow the target in a slow arching pattern while still keeping track of the target.
Obviously, the robot needs to track the target, so the robot needs to scan the field for an appropriate target to track. Once the robot has a suitable target, it should track the target and also keep the robot on line with the target. When the robot fires, the target should be close enough to fire without missing.
Firing on a moving target is difficult, so I programmed the robot to fire with variable power when the target is within range. Firing a bullet takes energy so I wanted the robot to fire a small bullet when the target is at far range and a large bullet when the target is at close range.
Robocode provides several prepacked robots, of note are Walls, RamFire, Fire, Corners, Crazy, Tracker, SpinBot, and of course a SittingDuck. After a long night of coding and debugging, I wanted to see which of these robots can stand up to my robot. I started up with the SittingDuck first and I felt good that my robot easily beat that one. I started on SpinBot and I was disappointed with the way my robot was performing, winning only 4 out of 10 times. I shrugged my shoulders and started on the next challenger and I was in for more hurt. Against the Tracker and Corners, I won two times each and none for the rest.
I felt disheartened at my robot's performance and decided to take another crack at it. I wanted to tighten up the gun tracking and radar tracking, so that my robot could target the enemy faster and smoother. I also want to improve my robot's random movement when there is no target acquired and modify the shadow movement that my robot makes when it has a viable target.
I also incorporated some tests to determine if my robot was giving me the correct movements and actions that I wanted the robot to take. I developed a firing test, to see if my variable fire worked. I also made a movement test to find out if my robot was moving away from walls if it bumped into a wall. I also made two tracking tests, one for the gun and one for the radar. Both tests, try to find out if the radar or the gun is pointing at the enemy within five degrees of the center. I ran these tests as well as some performance test that pitted my robot against one of the included robots. The utility tests that tested my robot's basic functions worked, but the performance test still showed me that I had more work to do on my robot.
After everything I did, I still need to improve my robot in order to beat the other sample robots. I knew that this was no easy task and yet it still challenged me to take a crack at it and try to beat these simple robots. Although I tried my best, I found something sorely lacking within the basic robot class. The basic robot class gives few additional extras that the advanced robot class has. I could have tried to learn and used the advanced robot class, I already created the base design of my competitive robot using the basic robot class and decided to finish it using the basic class. I might just get this to do better if I import most of the functionality into the advanced class.
No comments:
Post a Comment