improved AI logic with some boolean variables. feel free to change if this is crap