changed some logic and add an AI
changed some logic and add an AI