Good question with a kind-of long answer:
The boss's attack patterns (groups of attacks) are all hard-coded, and always occur in the same order, so for example, the final boss phase 2 goes:
- (4 ground slams + 1 shockwave) x repeat this 3 times
- (Dash to the opposite side of the player, punch + shockwave) x repeat this 3 times
- Dash to 4 preset locations and shoot 2 projectiles
Then it repeats.
The individual attacks themselves depend on the player's position. For example, the boss's punch + shockwave attack will always be on the opposite side of the player (so if the boss is on your right, he will always dash to your left to punch and vice versa).
Similarly, for the ground slams, the boss picks your locations as the 'center' of the slams, and then spaces 3 or 4 (depending on phase 1 or 2) slams around you, clamping to the edges of the arena. Hope that helps! Let me know if you have any other questions, I'm always happy to talk about boss design.