[BUG] Fix bugs in game engine and AI