Skip to content

Commit

Permalink
Add probability change maze database and other small updates (#17)
Browse files Browse the repository at this point in the history
* Update to organize probability change mazes into groups

* Read Xulu's excel file into a maze database

* Add database of good probability change mazes

* Add function to check similarity against isomorphic mazes
  • Loading branch information
calderast authored Oct 4, 2024
1 parent bdf5a9f commit 8025a5e
Show file tree
Hide file tree
Showing 15 changed files with 79,766 additions and 96 deletions.
38,209 changes: 38,209 additions & 0 deletions Barrier_Sequence_Databases/maze_database_probability_change.csv

Large diffs are not rendered by default.

Binary file not shown.
38,209 changes: 38,209 additions & 0 deletions Barrier_Sequence_Databases/probability_change_mazes.csv

Large diffs are not rendered by default.

Binary file not shown.
901 changes: 901 additions & 0 deletions Tutorials/Generate_Probability_Change_Database.ipynb

Large diffs are not rendered by default.

1,956 changes: 1,956 additions & 0 deletions Tutorials/Generate_Probability_Change_Database_part2.ipynb

Large diffs are not rendered by default.

193 changes: 133 additions & 60 deletions Tutorials/Hex_Maze_Functions.ipynb

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions Tutorials/Plotting_Hex_Mazes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@
"source": [
"# 5. Visually evaluate a barrier sequence\n",
"\n",
"We can use `plot_evaluate_barrier_sequence` to print comparison plots between each maze in a barrier sequence and all othber mazes in the sequence. \n",
"We can use `plot_evaluate_maze_sequence` to print comparison plots between each maze in a barrier sequence and all othber mazes in the sequence. \n",
"\n",
"For the maze being evaluated, optimal paths are highlighted in green. Differences in optimal paths on this maze and all other mazes in the sequence are highlighted in orange.\n",
"\n",
Expand All @@ -1162,9 +1162,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Help on function plot_evaluate_barrier_sequence in module hex_maze_utils:\n",
"Help on function plot_evaluate_maze_sequence in module hex_maze_utils:\n",
"\n",
"plot_evaluate_barrier_sequence(barrier_sequence, **kwargs)\n",
"plot_evaluate_maze_sequence(barrier_sequence, **kwargs)\n",
" Given a sequence of barrier sets that each differ by the movement of\n",
" a single barrier, plot each maze in the sequence showing a comparison of\n",
" how different it is from every other maze in the sequence.\n",
Expand All @@ -1189,10 +1189,10 @@
}
],
"source": [
"from hex_maze_utils import plot_evaluate_barrier_sequence\n",
"from hex_maze_utils import plot_evaluate_maze_sequence\n",
"\n",
"# View the documentation for this function\n",
"help(plot_evaluate_barrier_sequence)"
"help(plot_evaluate_maze_sequence)"
]
},
{
Expand Down Expand Up @@ -1253,7 +1253,7 @@
}
],
"source": [
"from hex_maze_utils import plot_evaluate_barrier_sequence\n",
"from hex_maze_utils import plot_evaluate_maze_sequence\n",
"\n",
"# Example barrier sequence to evaluate\n",
"example_barrier_sequence = [{37, 7, 39, 41, 14, 46, 20, 23, 30}, {37, 39, 7, 46, 14, 16, 20, 23, 30},\n",
Expand All @@ -1262,7 +1262,7 @@
"\n",
"\n",
"# Plot an evaluation of a barrier sequence\n",
"plot_evaluate_barrier_sequence(example_barrier_sequence)"
"plot_evaluate_maze_sequence(example_barrier_sequence)"
]
}
],
Expand Down
Binary file added Tutorials/Xulu/BraveLu_experimental_notes.xlsx
Binary file not shown.
222 changes: 222 additions & 0 deletions Tutorials/Xulu/Read_Excel_Into_Database.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{34, 29, 45, 20, 25, 46, 5, 14, 11}\n",
"{33, 23, 44, 20, 30, 46, 21, 5, 32, 11, 27}\n",
"{28, 44, 15, 24, 36, 46, 17, 22, 6, 38}\n",
"{34, 35, 45, 12, 30, 13, 37, 22, 6}\n",
"{39, 23, 15, 45, 25, 10, 32, 18}\n",
"{28, 44, 12, 30, 25, 7, 31, 37, 18}\n",
"{33, 40, 35, 12, 16, 31, 22, 6}\n",
"{34, 19, 45, 30, 13, 42, 5, 22, 11}\n",
"{34, 40, 15, 41, 16, 7, 26, 47, 14, 27}\n",
"{33, 29, 40, 12, 21, 10, 26, 37, 18}\n",
"{39, 23, 44, 12, 30, 9, 46, 21, 6, 11, 38}\n",
"{28, 34, 45, 25, 7, 21, 31, 37, 11}\n",
"{34, 44, 15, 45, 20, 31, 47, 8, 22}\n",
"{43, 23, 29, 45, 16, 36, 10, 26, 47, 11}\n",
"{43, 23, 40, 15, 30, 16, 37, 22, 11}\n",
"{19, 29, 41, 13, 31, 5, 14, 38}\n",
"{39, 34, 20, 9, 16, 13, 31, 47, 27}\n",
"{43, 19, 29, 45, 46, 7, 21, 37, 18}\n",
"{33, 24, 35, 45, 9, 13, 26, 37, 27}\n",
"{34, 19, 45, 30, 13, 5, 37, 14, 27}\n",
"{34, 44, 24, 9, 36, 13, 26, 6, 18, 38}\n",
"{23, 29, 16, 36, 46, 5, 17, 37, 18}\n",
"{39, 34, 20, 9, 16, 13, 31, 47, 27}\n",
"{43, 19, 29, 41, 36, 13, 14, 38}\n",
"{23, 34, 15, 45, 30, 13, 5, 14, 32}\n",
"{39, 44, 29, 15, 16, 36, 26, 14, 11}\n",
"b1 = {34, 15, 24, 20, 41, 31, 10, 14, 38}\n",
"\n",
"b2 = {34, 15, 24, 12, 20, 41, 31, 14, 38}\n",
"\n",
"b3 = {34, 40, 15, 12, 20, 41, 31, 14, 38}\n",
"b1 = {43, 23, 35, 45, 12, 9, 21, 10, 32, 18}\n",
"\n",
"b2 = {43, 23, 35, 45, 12, 9, 25, 10, 32, 18}\n",
"\n",
"b3 = {43, 23, 35, 45, 9, 25, 10, 37, 32, 18}\n",
"{33, 29, 15, 45, 30, 10, 37, 11, 27}\n",
"{28, 34, 9, 25, 21, 10, 37, 47, 18}\n",
"b1 = {34, 44, 24, 9, 36, 13, 26, 18, 38}\n",
"\n",
"b2 = {34, 44, 30, 9, 36, 13, 26, 18, 38}\n",
"\n",
"b3 = {34, 44, 24, 30, 9, 36, 13, 26, 38}\n",
"b1 = {34, 19, 45, 12, 25, 21, 32, 6, 18}\n",
"\n",
"b2 = {34, 40, 45, 12, 25, 21, 32, 6, 18}\n",
"\n",
"b3 = {34, 40, 45, 12, 25, 13, 21, 32, 6}\n",
"{43, 19, 29, 41, 9, 13, 37, 6, 18}\n",
"{23, 34, 45, 20, 9, 36, 17, 8, 32}\n",
"b1 = {44, 15, 24, 36, 7, 21, 10, 37, 27}\n",
"\n",
"b2 = {44, 29, 24, 36, 7, 21, 10, 37, 27}\n",
"\n",
"b3 = {44, 29, 24, 7, 21, 10, 17, 37, 27}\n",
"b1 = {39, 44, 45, 12, 20, 36, 7, 5, 26, 11}\n",
"\n",
"b2 = {39, 44, 12, 20, 36, 7, 5, 26, 14, 11}\n",
"\n",
"b3 = {39, 44, 29, 20, 36, 7, 5, 26, 14, 11}\n",
"{43, 23, 29, 45, 16, 17, 26, 32, 27}\n",
"{28, 35, 45, 20, 31, 5, 10, 37, 27}\n",
"{33, 29, 40, 12, 41, 21, 37, 14, 18}\n",
"b1 = {19, 29, 45, 13, 5, 17, 47, 22, 27}\n",
"\n",
"b2 = {19, 45, 13, 31, 5, 17, 47, 22, 27}\n",
"\n",
"b3 = {19, 45, 20, 13, 31, 5, 17, 47, 27}\n",
"{39, 44, 15, 35, 36, 13, 5, 26, 11}\n",
"{43, 15, 24, 35, 46, 31, 10, 17, 11}\n",
"b1 = {28, 35, 45, 30, 9, 10, 17, 37, 27}\n",
"\n",
"b2 = {28, 35, 45, 9, 31, 10, 17, 37, 27}\n",
"\n",
"b3 = {28, 35, 45, 20, 9, 31, 10, 37, 27}\n",
"b1 = {44, 15, 24, 46, 21, 10, 37, 6, 18}\n",
"\n",
"b2 = {44, 15, 30, 46, 21, 10, 37, 6, 18}\n",
"\n",
"b3 = {44, 15, 24, 30, 46, 21, 10, 37, 6}\n",
"{34, 44, 24, 30, 9, 36, 13, 26, 6, 38}\n",
"{33, 29, 15, 45, 30, 13, 17, 37, 5, 22}\n",
"b1 = {34, 19, 15, 45, 30, 9, 17, 47, 6, 18}\n",
"\n",
"b2 = {34, 19, 15, 45, 9, 25, 17, 47, 6, 18}\n",
"\n",
"b3 = {34, 15, 45, 9, 25, 31, 17, 47, 6, 18}\n",
"b1 = {28, 34, 15, 30, 16, 46, 26, 37, 11}\n",
"\n",
"b2 = {28, 34, 30, 16, 46, 13, 26, 37, 11}\n",
"\n",
"b3 = {28, 34, 35, 30, 16, 46, 13, 37, 11}\n",
"b1 = {34, 19, 45, 12, 25, 21, 10, 37, 32, 18}\n",
"\n",
"b2 = {34, 40, 45, 12, 25, 21, 10, 37, 32, 18}\n",
"\n",
"b3 = {34, 40, 45, 12, 16, 25, 21, 10, 37, 32}\n",
"[{34, 5, 11, 45, 46, 14, 20, 25, 29}]\n",
"[{32, 33, 5, 11, 44, 46, 20, 21, 23, 27, 30}]\n",
"[{36, 6, 38, 44, 46, 15, 17, 22, 24, 28}]\n",
"[{34, 35, 37, 6, 12, 45, 13, 22, 30}]\n",
"[{32, 39, 10, 45, 15, 18, 23, 25}]\n",
"[{37, 7, 12, 44, 18, 25, 28, 30, 31}]\n",
"[{33, 35, 6, 40, 12, 16, 22, 31}]\n",
"[{34, 5, 42, 11, 13, 45, 19, 22, 30}]\n",
"[{34, 7, 40, 41, 14, 15, 16, 47, 26, 27}]\n",
"[{33, 37, 40, 10, 12, 18, 21, 26, 29}]\n",
"[{6, 39, 38, 9, 11, 12, 44, 46, 21, 23, 30}]\n",
"[{34, 37, 7, 11, 45, 21, 25, 28, 31}]\n",
"[{34, 8, 44, 45, 15, 47, 20, 22, 31}]\n",
"[{36, 10, 43, 11, 45, 47, 16, 23, 26, 29}]\n",
"[{37, 40, 43, 11, 15, 16, 22, 23, 30}]\n",
"[{5, 38, 41, 13, 14, 19, 29, 31}]\n",
"[{34, 39, 9, 13, 47, 16, 20, 27, 31}]\n",
"[{37, 7, 43, 45, 46, 18, 19, 21, 29}]\n",
"[{33, 35, 37, 9, 45, 13, 24, 26, 27}]\n",
"[{34, 5, 37, 13, 45, 14, 19, 27, 30}]\n",
"[{34, 36, 6, 38, 9, 44, 13, 18, 24, 26}]\n",
"[{36, 5, 37, 46, 16, 17, 18, 23, 29}]\n",
"[{34, 39, 9, 13, 47, 16, 20, 27, 31}]\n",
"[{36, 38, 41, 43, 13, 14, 19, 29}]\n",
"[{32, 34, 5, 45, 13, 15, 14, 23, 30}]\n",
"[{36, 39, 11, 44, 14, 15, 16, 26, 29}]\n",
"[{34, 38, 41, 10, 14, 15, 20, 24, 31}, {34, 38, 41, 12, 14, 15, 20, 24, 31}, {34, 38, 40, 41, 12, 14, 15, 20, 31}]\n",
"[{32, 35, 9, 10, 43, 12, 45, 18, 21, 23}, {32, 35, 9, 10, 43, 12, 45, 18, 23, 25}, {32, 35, 37, 9, 10, 43, 45, 18, 23, 25}]\n",
"[{33, 37, 10, 11, 45, 15, 27, 29, 30}]\n",
"[{34, 37, 9, 10, 47, 18, 21, 25, 28}]\n",
"[{34, 36, 38, 9, 44, 13, 18, 24, 26}, {34, 36, 38, 9, 44, 13, 18, 26, 30}, {34, 36, 38, 9, 44, 13, 24, 26, 30}]\n",
"[{32, 34, 6, 12, 45, 18, 19, 21, 25}, {32, 34, 6, 40, 12, 45, 18, 21, 25}, {32, 34, 6, 40, 12, 45, 13, 21, 25}]\n",
"[{37, 6, 41, 9, 43, 13, 18, 19, 29}]\n",
"[{32, 34, 36, 8, 9, 45, 17, 20, 23}]\n",
"[{36, 37, 7, 10, 44, 15, 21, 24, 27}, {36, 37, 7, 10, 44, 21, 24, 27, 29}, {37, 7, 10, 44, 17, 21, 24, 27, 29}]\n",
"[{36, 5, 39, 7, 11, 12, 44, 45, 20, 26}, {36, 5, 39, 7, 11, 44, 12, 14, 20, 26}, {36, 5, 39, 7, 11, 44, 14, 20, 26, 29}]\n",
"[{32, 43, 45, 16, 17, 23, 26, 27, 29}]\n",
"[{35, 5, 37, 10, 45, 20, 27, 28, 31}]\n",
"[{33, 37, 40, 41, 12, 14, 18, 21, 29}]\n",
"[{5, 45, 13, 47, 17, 19, 22, 27, 29}, {5, 13, 45, 47, 17, 19, 22, 27, 31}, {5, 13, 45, 47, 17, 19, 20, 27, 31}]\n",
"[{35, 36, 5, 39, 11, 44, 13, 15, 26}]\n",
"[{35, 10, 43, 11, 46, 15, 17, 24, 31}]\n",
"[{35, 37, 9, 10, 45, 17, 27, 28, 30}, {35, 37, 9, 10, 45, 17, 27, 28, 31}, {35, 37, 9, 10, 45, 20, 27, 28, 31}]\n",
"[{37, 6, 10, 44, 46, 15, 18, 21, 24}, {37, 6, 10, 44, 46, 15, 18, 21, 30}, {37, 6, 10, 44, 46, 15, 21, 24, 30}]\n",
"[{34, 36, 6, 38, 9, 44, 13, 24, 26, 30}]\n",
"[{33, 37, 5, 45, 13, 15, 17, 22, 29, 30}]\n",
"[{34, 6, 9, 45, 15, 47, 17, 18, 19, 30}, {34, 6, 9, 45, 15, 47, 17, 18, 19, 25}, {34, 6, 9, 45, 15, 47, 17, 18, 25, 31}]\n",
"[{34, 37, 11, 46, 15, 16, 26, 28, 30}, {34, 37, 11, 13, 46, 16, 26, 28, 30}, {34, 35, 37, 11, 13, 46, 16, 28, 30}]\n",
"[{32, 34, 37, 10, 12, 45, 18, 19, 21, 25}, {32, 34, 37, 40, 10, 12, 45, 18, 21, 25}, {32, 34, 37, 40, 10, 12, 45, 16, 21, 25}]\n"
]
}
],
"source": [
"import pandas as pd\n",
"import ast\n",
"import re\n",
"import sys\n",
"sys.path.append(\"..\") # Use sys to add the parent directory (where hex_maze_utils lives) to the path\n",
"\n",
"# Read the excel file into a DataFrame\n",
"excel_file_path = 'BraveLu_experimental_notes.xlsx'\n",
"df = pd.read_excel(excel_file_path, sheet_name='Daily configs and notes_BanditT', skiprows=1) \n",
"\n",
"# will include b1 = , b2 = , b3 = if barrier shift\n",
"\n",
"def extract_sets_from_string(value):\n",
" if isinstance(value, str):\n",
" # Regular expression to find all the sets in the string\n",
" sets = re.findall(r'\\{.*?\\}', value)\n",
" return [ast.literal_eval(s) for s in sets]\n",
" return None\n",
"\n",
"def flatten_sets(nested_list):\n",
" flat_list = []\n",
" for item in nested_list:\n",
" if isinstance(item, list):\n",
" # Flatten sublists of sets (from barrier sequences)\n",
" flat_list.extend(flatten_sets(item)) \n",
" elif isinstance(item, set):\n",
" # Or if the list element is just a set, add it\n",
" flat_list.append(item)\n",
" return flat_list\n",
"\n",
"rows_with_mazes = df[df['barrier location'].notna()]\n",
"\n",
"list_of_sets = rows_with_mazes['barrier location'].apply(extract_sets_from_string).tolist()\n",
"\n",
"for set in list_of_sets:\n",
" print(set)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit 8025a5e

Please sign in to comment.