Hello, I am working on a 2D top-down racing game. I've implemented CPU opponents as well as a system for calculating the player's current position (1st, 2nd, etc.) But I've been struggling with how to calculate the CPU's current position.
The system I made is that each racer (both the player and all of the CPUs) have an instance variable called PosScore. Basically, the higher the PosScore, the further you are in the race. For the player, I can just compare the PosScore against all the other CPU's PosScores in order to calculate your current position. But for the CPUs it's different because I have to compare the PosScore against both the player and all the other CPUs.
The preferable solution would be for every CPU to have a "CurrentPosition" instance variable that updates accordingly like it does for the player.
Here's how I'm calculating the PosScore variables for both the CPUs and the player: