Optimizing
Introduction:
We were tasked to optimize a little project of our choice.
I decided to try to optimize a behaviour tree. Sadly due to me getting sick and work, I decided to change my project.
Behaviour Tree: A quick reminder
In video games, a behaviour tree is a model of plan execution used for AIs. The AI can switch between a different set of tasks.
It can create very complex tasks composed of simple tasks, without worrying how the simple tasks are implemented.
What my behaviour tree did:
My AI had different sets of actions. In it's default state, it was doing checks until it spotted an enemy. To determine if an enemy is seen, the AI throwed a dice and if the value was higher than 0 then an enemy was spotted and the battle started. The AI checked if the enemy was healthy and if not then it throwed a new dice to check if the attack connected and then checked once again if the enemy was still alive.
For the sake of having similar simulations, I changed the required value so that each time a dice was thrown, it would succeed automatically.
Once the enemy is dead or wounded, the AI resumed it's patrol.
The problem:
While it was interesting, the project didn't really used the full potential of a behaviour tree, so I had to start all over again.
Due to a small time limit, I switched to a game everyone knows: Pacman. In case you didn't know, each ghosts in Pacman has a different way to stop the player, the perfect simple game to try to implement a behaviour tree.
I found a Github project (https://github.com/Kofybrek/Pacman) and used it as a base for my optimizations.
Checking the performance:
First of all, I checked the project with IntelVtunes to see what I could do before trying to implement a behaviour for the ghosts.
As you can see, after chrono which is used to make the game run, the biggest part is happening in main. After a quick look, I decided to change the arrays with our custom ones which helped speed up the launch and reduced a little the Main % of CPU time.
Looking at the ghosts:
Afterwards, I looked at the ghost and GhostManager.
Conclusion:
Sadly I didn't had enough time to implement my behaviour tree but managed to optimize the game a little. Once I have more time, I'd like to go back to this project and try to do what I wanted.





Commentaires
Enregistrer un commentaire