-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathslides.html
More file actions
211 lines (123 loc) · 3.6 KB
/
Copy pathslides.html
File metadata and controls
211 lines (123 loc) · 3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<!DOCTYPE html>
<html>
<head>
<title>Pipes Solver Implementation</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<style type="text/css">
code {
background-color: #f0f0f0;
}
/* Slideshow styles */
</style>
</head>
<body>
<textarea id="source">
class: center, middle
# Solving The Pipes Problem
--
### (AKA Diving into Toby's brain...and surviving...hopefully)
---
class: center, middle
# How I tried to solve the problem...
---
class: center, middle
# Define the problem
---
class: center, middle
# We have a number of discrete points must be connected with respect to direction
--
### This looked to me like a pathing (graph) problem
--
### DFS, BFS, A*, etc...
---
class: center, middle
# Scope the Problem
--
### (Limited: The Board is Not Infinite)
--
### No worries about stack/heap space, etc...
---
class: center, middle
# So I chose to implement Breadth First Search
--
### I don't think it really made a difference--just needed to pick one
---
class: center, middle
# Getting Started
---
class: center, middle
# Define the board
--
### Doubly-nested dictionary with row major ordering (y, x)
--
### Each coordinate was a tile with a type and orientation (default N)
---
class: center, middle
# Traverse the board and try different possibilities
---
class: center, middle
# Start with a list of all gas tanks
---
class: center, middle
# For each item in the list, mark the tile as visited and try all possibilities with each neighbor
---
class: center, middle
# For each possibility, score how many connections are made
---
class: center, middle
# Set the tile and its currently examined neighbor to the orientation with the highest score
---
class: center, middle
# If we make a connection at all, and the neigbor has not been visited yet, add them to the list to visit
---
class: center, middle
# Note: If a tile is a house, and it is connected, leave it alone (houses only have one connectable edge)
---
class: center, middle
# Things I learned:
---
class: center, middle
# Greedy works pretty well in most cases
--
### Making the best choice at the time tended to work pretty well
---
class: center, middle
# Test all possibilities instead of trying to be too clever
--
### Moved from a strategic approach to just testing all permutations of each tile with its neighbors
---
class: center, middle
# Don't be clever (did I already mention that?)
--
### Like Forrest, I am not a smart man. Be Basic. Iterate. Solutions will reveal themselves.
---
class: center, middle
# Write utility methods early so it is easier to tweak strategies
--
### Get a tile, get its neighbors, fitness evaluation, etc...
---
class: center, middle
# Questions?
---
class: center, middle
Slides were made with http://remarkjs.com/
Source for slides can be found at https://github.com/okcpython/pipes
Heavily borrowed from slides found at https://github.com/okcpython/python3-slow-migration
</textarea>
<!--<script src="https://cdn.rawgit.com/gnab/remark/gh-pages/downloads/remark-0.6.3.min.js" type="text/javascript"></script>-->
<!-- Uncomment this if there is no internet -->
<script src="remark-0.6.3.min.js" type="text/javascript"></script>
<script type="text/javascript">
var slideshow = remark.create( {
// Navigation options
navigation: {
// Enable or disable navigating using scroll
// Default: true
// Alternatives: false
scroll: false,
}
}
);
</script>
</body>
</html>