I have been designing a simple turn based Civ-like game over the last two days with libGDX to test myself. I have a units class that can be extended to make unit types and I have my game board set up. Everything is almost done... except for the AI, specifically the unit AI. I want to collect all active units into two seperate arrays (the libGDX array), one for the human player and one for the AI units. I will not be using diplomacy for the sake of simplicity.
I first tried
Array<Unit> playerUnits = new Array<Units>(); and calling the
playerUnits.get(index) method to return the unit. My thought process seems to not be logical, though, as I found there was no way to get the
y coordinates of units that do not yet exist (all units have to be built in factories in game). Next, I tried to store
y coords in an XYCoords method, however there was no built in way to add units to the array later.
I have my pathfinder implemented (with a few minor bugs that cause units to flicker once moved) and now need to simply add the reaction to units. I have no idea how to do this and as you have probably guessed by now I have never had to implement a more complex AI than one that follows the player mindlessly. Has anyone had a similar problem that could somehow help me?