Optimizes the bot by keeping track of blank and dirty positions