You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: artificialintelligence/assignments/maze/README.md
+42-42Lines changed: 42 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ There are many ways to implement a maze generation and one of the most common is
24
24
25
25
## Random Number Generation
26
26
27
-
In order do be consistent with all languages and random functions the pseudo random number generation should follow the following sequence of 100 numbers:
27
+
In order to be consistent with all languages and random functions the pseudo random number generation should follow the following sequence of 100 numbers:
@@ -38,7 +38,7 @@ In order to give consistency on how to decide the direction of the next cell, th
38
38
39
39
1. List all visitable neighbors of the current cell;
40
40
2. Sort the list of visitable neighbors by clockwise order, starting from the top neighbor: UP, RIGHT, DOWN, LEFT;
41
-
3. If there are one visitable, do not call random, just return the first neighbor found;
41
+
3. If there is one visitable, do not call random, just return the first neighbor found;
42
42
4. If there are two or more visitable neighbors, call random and return the neighbor at the index of the random number modulo the number of visitable neighbors. `vec[i]%visitableCount`
43
43
44
44
## Input
@@ -58,12 +58,12 @@ Every line is a combination of underscore `_`, pipe `|` and empty ` ` character
58
58
The initial state of the 2 x 2 map is:
59
59
60
60
```
61
-
_ _
62
-
|_|_|
63
-
|_|_|
61
+
_ _
62
+
|_|_|
63
+
|_|_|
64
64
```
65
65
66
-
In order to interactively solve this, we will, add `(0,0)` to the queue.
66
+
In order to interactively solve this, we will add `(0,0)` to the queue.
67
67
68
68
The neighbors of the current top (0,0) are RIGHT and DOWN, `(0,1)` and `(1,0)` respectively.
69
69
@@ -76,29 +76,29 @@ The random number is `72` and the number of neighbors is `2`, so the index of th
76
76
The wall between `(0,0)` and `(0,1)` is removed, and `(0,1)` is added to the queue. Now it holds `[(0,0), (0,1)]`. The map is now:
77
77
78
78
```
79
-
_ _
80
-
|_ _|
81
-
|_|_|
79
+
_ _
80
+
|_ _|
81
+
|_|_|
82
82
```
83
83
84
84
Now the only neighbor of (0,1) is DOWN, (1,1). So no need to call random, we just choose the only neighbor.
85
85
86
86
The wall between `(0,1)` and `(1,1)` is removed, and `(1,1)` is added to the queue. Now it holds `[(0,0), (0,1), (1,1)]`. The map is now:
87
87
88
88
```
89
-
_ _
90
-
|_ |
91
-
|_|_|
89
+
_ _
90
+
|_ |
91
+
|_|_|
92
92
```
93
93
94
94
Now the only neighbor of `(1,1)` is LEFT, `(1,0)`. So no need to call random, we just choose the only neighbor.
95
95
96
96
The wall between (1,1) and (1,0) is removed, and (1,0) is added to the queue. Now it holds `[(0,0), (0,1), (1,1), (1,0)]`. The map is now:
97
97
98
98
```
99
-
_ _
100
-
|_ |
101
-
|_ _|
99
+
_ _
100
+
|_ |
101
+
|_ _|
102
102
```
103
103
104
104
Now, the current top of the queue is `(1,0)` and there isn't any neighbor to be visited, so we remove the current top `(1,0)` from the queue and backtrack. The queue is now `[(0,0), (0,1), (1,1)]`.
@@ -110,43 +110,43 @@ The current top is `(0,1)` and there isn't any neighbor to be visited, so we rem
110
110
The current top is `(0,0)` and there isn't any neighbor to be visited, so we remove `(0,0)` from the queue and backtrack. The queue is now empty and we finish priting the map state. The final map is:
111
111
112
112
```
113
-
_ _
114
-
|_ |
115
-
|_ _|
113
+
_ _
114
+
|_ |
115
+
|_ _|
116
116
```
117
117
118
118
And this the only one that should be printed. No intermediary maps should be printed.
0 commit comments