Produces GIF animation that visualizes: creation of map in Zen garden approach, shortest path visiting all destinations, deducing new facts from facts that are being collected at certain destinations. The intention behind this project was to improve Python coding skills while practising implementation of some of the most widely mentioned algorithms in AI that don't use machine learning techniques.
git clone https://github.com/freezpmark/artificial-intelligence-algorithms
cd artificial-intelligence-algorithms
pip install -r requirements.txt
python main.py
You can also run this on Discord. It uses ai_algo.py
as cog file. To run it, call <yourPrefix>run_ai
. The GIF file will be shown in the text channel where the command has ran.
Running the main.py
or ai_algo.py
causes to execute feature scripts below in order.
The task is to rake the sand on the entire Zen garden. Character always starts at the edge of the garden and leaves straight shaping path until it meets another edge or obstacle. On the edge, character can walk as he pleases. If it comes to an obstacle - wall or raked sand - he has to turn around, if he is not able to, raking is over.
begin_create
- defines whether to start creating new maps from query, walled map or terrained to propertied mapquery
- defines map size with wallsfname
- name of the text file into which the map will be createdmax_runs
- max number of times to run evolutionary algorithm to find a solutionpoints_amount
- amount of blue nodes (facts) we wish to create randomly in the map
Finds the shortest path to visit all nodes. First node to visit is the black node for which A* algorithm is used. Then, we run Dijkstra's algorithm for each blue node to find the shortest distances to all other blue nodes. To find the shortest path between all blue nodes we can use either greedy Naive permutation or Held–Karp algorithm which is alot faster.
movement
- defines options of movementclimb
- defines the way how the distance between adjacent nodes is calculatedalgorithm
- choses which algorithm to use to find the shortest path between blue nodessubset_size
- amount of blue nodes we wish to visit in the map
Production system belongs to knowledge systems that use data to create new knowledge. In this case, it deduces new facts from facts that are being collected in each blue node. Deduction is defined by set of rules that are loaded from the text file.
save_fname_facts
- name of file into which facts will be savedload_fname_facts
- name of file from which we load factsload_fname_rules
- name of file from which we load rulesstep_by_step
- defines whether we want to run production for each collected factfacts_random_order
- shuffles the order of loaded facts
skip_rake
- defines whether we want to skip raking part in the animation