sábado, 25 de janeiro de 2014

The end

Hey!

It was really fun to build this robot we had some priceless moments while studying the game and building everything. Soon enough we will have a video with some of that fun (:D)! But not everything was good. We had some problems trying to create the tree, it took us two days to start to code it. We couldn't figure out where to start (>_<). Shame on us!

I leave here the link to our code whether you want to take a peak our try it.
Defender Bot code

Check some photos of the first and second deliver.
Defender Bot Photo


Goodbye dear followers! :D

Heuristics

Dear Friends,

Our project has finally come to an end. Last Friday we delivered our Defender bot to our professor. Let's hope he liked it. Even tough we haven been posting this late week we have been working hard. With the end of the Semester it has been non-stop.

So, after being able to create the tree. we began to play the game to understand which would be our best heuristic. Soon enough all of us agreed that we should maximize both life and energy. But that's not something easy to "teach" a robot. Later on, we figured out that the energy is more important in the beginning and the lack of life was more concerning in the last rounds. Thus we divided the game in three big sectors. The first when there were 4 or less enemies shown, the second when there were five enemies as lastly when all the six enemies appeared.

When there are less than four enemies we don't want to lose more than 200 energy points. So, at the end of the round we want to have 300 or more energy points. Since we are regaining 50% of the energy left in the next round the bot will have a minimum of 450 energy points. If there are 4 enemies already out the robot will be able to use 250 energy points. Then, after finding all the possibilities that waste less than the maximum energy defined for that amount of enemies the robot will choose the one that keeps the most of life. If there are two possibilities that leaves the bot with the same HP(hit-points) the robot will choose the one that uses less energy. If the amount of life and energy are the same between two possibilities it will choose the one that kills more enemies.

If five enemies have already shown up in different round the bot will play the same way as if there were four or less enemies. The difference will be the amount of energy that can be used. If we are early in the game the bot will use only 250 energy points. If the game has reached the 6th round (3 rounds for the bot, 3 for the enemies) it will use the maximum of 300 energy points. Choosing the which branch of the tree to use is the same way as if there were 4 or less enemies. Another big difference is if by any chance the robot is able to kill all the enemies remaining and keep more than 500 life point it will choose to kill all the enemies even if it wastes all the energy that is left. Why? Because one enemy can take the maximum of 500 life points, since there will be only one enemy left the robot will make that choice guaranteeing its win. If the five enemies appear all at once and the no way of killing all of then and keep more than 500 HP, the robot will use the sound attack on all the five enemies. The sound attack has proven the be the most efficient attack when there are too many enemies since it takes little energy to use it.

If the last enemy is out, meaning all the 6 enemies have shown, the defender bot will try to kill all the enemies. If there is not possible to kill all the enemies it will chose the one that takes the most of the enemies out without losing all its energy. If by any change all the six enemies show in one round the bot will use only the sound attack. For the same reason we explained before.

It took us quite a while to figure out all of this but with the simulator built by our college Frederico we were able to test all the possibilities a lot faster and efficiently. Thanks Frederico!

quarta-feira, 8 de janeiro de 2014

Testing

Hi there,

While trying to make the bot intelligent we have been filming some of the games. Some we won, other we let them win (hahaha).


segunda-feira, 6 de janeiro de 2014

How to Think?

Dear Friends,

Our first post of 2014 (:-D). I hope all of you have a great year.

After changing the world and the robot. Since we got an extra RGB sensor that we are using to to detect the yellow and green stripes, which are the limits of each slot, instead of the light sensor. I cannot even begin to describe how easier it is with the RGB sensor.

The next question and our main problem was how to make it [the robot] think. After some research throughout the class papers and some discussion we figured out that the best way to make the robot intelligent was to create a little tree and look for the best attack sequence. 

This was our first draft of the tree and its nodes.


While trying to make the tree we missed the good old c++ pointers and structs..Since there is no pointer in Java we got a bit confused when trying to point to other nodes. 

In each node we save the energy spent, the hp the bot still has, the parent node, the sub-nodes, the total number of attacks of all the enemies, the number of enemys killed, and how many enemies it needs to attack.

The sub-nodes are the result of each attack the robot can use on the enemy. Therefore the number of sub-nodes will change accordingly to the type. 3 sub-nodes (do nothing and 2 attacks) if the enemy is an Infantry. 4 sub-nodes (do nothing and 3 attacks) if the enemy is a Tank.

To begin with, our strategy will be to kill every Artillery that shows up so, in order to reduce the tree, the Artillery will not take part in the tree. The robot has a small "brain" so we are trying not to overdo it.