Object detection
We already had functions to detect the opponents with the sonar. But the sonar range is 180 degrees (left to right of the robot). If the opponent is behind the robot it wouldn't "see" it. So we implemented a change in the distance menu controller. If it doesn't detect anything then it rotates 180 degrees and scans again.
Now the robot is always aware of all his surroundings in case of danger.
Improvement of strategy
To determine the butter position we have to pass by it's row or column. So we started making the robot going all the way down to the front until it finds the butter (Position (0,5)). Later we studied the mold movements and figured that we would benefit if the robot did the search going to the right (Position (5,0)).
We realized from game simulations that if the robot goes through either the 1st or last column, it will be easily caught by the mold and trapped without escape. Which means that the robot could never go to the end of the line in search of the butter.
So we made him go to position (4,0). And determined that, if it reaches his target cell but it's not the butter cell, he should choose one of the 2 possible butter cells as a new target.
This behavior will allow it to reach (4,0) and then choose a new target. It will come down column (4,y) (i mean (4,1), (4,2), ...) and not (5,y),..., etc because the mold would have advantage. Even if the butter is in the last column, it will come down (4,y) until he's next to it and then turn left. If the butter is there he wins, else he will go to the other remaining butter cell.
Of course, the existence of obstacles might change the outcome.
We studied some more of the game like the mold moves, where it can be and where it cannot be. Which situations we can't possibly win, like the butter in the first 3 middle diagonal closest to the mold. We didn't use this in the code. It would be improvements we could do to the route calculation algorithm.
Sem comentários:
Enviar um comentário