Greedy Robot Fight | Post Mortem | Part 2
Part 1: https://ldjam.com/events/ludum-dare/40/greedy-robot-fight/greedy-robot-fight-post-mortem
Day 3
- GUI
- Fixed a weird lua class system problem
- After fixing that i am able to add the bad bot, then i create the sprite!
Day 3 (AI):
And now its the time to create the AI (Bad Bot Movement), i had the idea to create a full features AI, that can be offensive (Shoot to the player), and defensive too (Hide if the player can attack), but for time reasons it just rush the player
Basic checkingWhen its the bad bot turn, it first check if can attack you, then send the attack, otherwise it search for a movements
Searching for a movementThe AI has to search a tile where it can use the laser to damage the player, then i make this:

This make the same as the laser attack, but instead of attack it calculate the distance between the tile and the bot, as you can see the "Near Tile" says 1, and the other tiles are 3-2 tiles far, ok now we know the quick way to attack player, now lest move the bot there!!! ...but how?
Path FindingThere is another life saver lib "Jumper" https://github.com/Yonaba/Jumper its a PathFinding library, super easy to setup very fast, and lightweight
Then i simply generate a path from the bot to the nearest tile, make a move check it can attack and otherwise continue moving until can attack
This is probably one of the coolest things i ever do, i feel done when the bot starts moving in the first turn =D
Release
I record a video and yay! Its uploaded, now lets review the first bugs
First Bug
The first bug was that the levels save the player and bot position, and sometimes that break walls, or other things, very strange but after a lot of research i found a solution
SolutionI didn't notice that if you set a table in a variable from another table and then you modify the variable, it change the original table too, then i fix it by making a clone of the original table
I am a bit disappointed about lua, i will try to learn more about it before making another game
Thanks for playing and rate my game, cya in LD41 :wink: