Karel-AI is an Artificial Intelligence created in Processing. This program is inspired on the educational programming language Karel
This is an evolutionary algorithm. While is running it will calculate how much efficiency have each DNA strings in all maps. Each Karel instance will search for a beeper and when he pick up in his bag he will stop, wait until the other instances take a beeper or until all runs exactly 200 loops. Then the efficiency will be calculated and the genetic process will start
The efficiency depends of how many errors and how many steps Karel did for getting a beeper.
- More errors means less efficiency.
- Less steps means more efficiency
The Artificial Intelligence will follow the next steps
- Each training cycle will take max. 200 loops trying to take a beeper and calculate the Efficiency of each DNA string
- The AI will take the higher efficiency DNA strings and will prepare to reproduce them
- The AI will take more or less part of the DNA strings (Randomly)
- The AI will take these parts to create two new DNA strings (Mixing the DNA string of the parents). This will continue in pairs for others DNA strings
- The AI will select only one instruction of the DNA (Randomly). Then this instruction will be mutated to another instruction of the instructions posible
Each complete iteration of AI <From 1. to 5.> should improve efficiency and achieve better DNA. Let the AI keep training for as long as you like. The more you train, the better results you will have.
Below you can see a diagram that explains the algorithm obtained from the book (Russell & Norvin, 2004, Page 132)
Reference: Russell S., Norvig P. 2004. Inteligencia Artificial: Un Enfoque Moderno 2° Ed. Pearson Prentice Hall. Madrid- Download and Install Processing 3.x stable release
- Download and Install Java SE 8.x
- Download the last version of Karel-AI Click here or...
If you have git command line installed in your PC you can use
git clone https://github.com/LuisFer666/karel-AI.git
If you have GitHub command line installed in your PC you can use
gh repo clone LuisFer666/karel-AI
- Open "KarelRobot" directory and open "KarelRobot.pde" file using Processing program installed
- Click on the "play" button of the Processing Graphic User Interface (GUI) and you will see the GUI of Karel-AI
- ¡Now you can use Karel-AI!
- Click on the "play" button of the Karel-AI GUI and look how all Karel instances try to find a beeper using random moves
- Maybe zero or more instances take a beeper. It will be better with more time of training. You need to wait untill all Karel instances take a beeper or all reach 200 cycles
- Look at the boxes under the maps, the best DNA strings will appeare. If there is not at least one, the first DNA strings will be taken. This four DNA strings will be improve using the genetic algorithm explained previously and will take the first four places. The four places remaining will be filled with random DNA strings and all the eight DNA strings will try to be the best for reproduce next time
- Three seconds after the initial population based on best efficiency, the next four boxes will be filled with a random selection.
- Three seconds later a DNA strand will appear based on the section of its two corresponding parents
- Three seconds later, the last four boxes will show the character to be mutated.
- After this the training will continue and begin an infinite cycle of constant improvement
Enjoy using Karel-AI. Remember, you can play, pause and reload the training process at any time
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.