Newer
Older
\subtitle{\textbf{Lab} - Searchable Design Spaces}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\section{Intro}
\begin{frame}{Design Spaces}
\item In this morning's session we talked about \keyterm{Game Parameters}
\item These are properties which help to define the game
\item These are often \textbf{dependant} on one another. \note{\item Why is this dependance possibly an issue?}
\end{frame}
\section{Flappy Bird}
\begin{frame}{Exercise: Game Parameters}
\begin{block}{Question}
What game parameters are there for \gametitle{Flappy Bird}?
\end{block}
\begin{center}
\includegraphics[width=0.9\textwidth]{images/game_new}
\end{center}
\end{frame}
\begin{frame}{Answer: Game Parameters}
\begin{figure}
\includegraphics[width=0.9\textwidth]{images/flappy_params}
\caption{paramters by Isaksen et al @ NYU}
\end{figure}
\end{frame}
\begin{frame}{Flappy Birds}
\begin{block}{Activity}
Go to the \href{http://game.engineering.nyu.edu/projects/exploring-game-space/}{\gametitle{Flappy Bird} demo} and change the sliders.\\
How does changing the parameters affect the gameplay?
\end{block}
\url{http://game.engineering.nyu.edu/projects/exploring-game-space/} \cite{isaksen2015exploring}
\end{frame}
\begin{frame}{How does this relate to us?}
Isaksen et al basically did the following:
\begin{enumerate}
\item Select parameters
\item Repeat $N$ times
\begin{enumerate}
\item Generate games
\item Evaluate games
\item Record results
\end{enumerate}
\item Output result
\end{enumerate}
This is how we're going to think about tuning our own game parameters.
\end{frame}
\begin{frame}{The Role of AI}
\begin{description}[<+->]
\item[Problem] Doing evaluations is time consuming
\item[Solution] Make AIs that play them
\end{description}
\end{frame}
\section{Asteroids}
\begin{frame}{Asteroids}
\begin{center}
Lets look at a more complicated example
\begin{figure}
\includegraphics[width=0.8\textwidth]{images/asteroids}
\begin{frame}[label={parameters}]{Parameters}
\end{block}
\pause
\begin{itemize}
\item Number of bullets
\item Speed of bullets
\item Number of asteroids
\item Number of asteroid children
\item Ship speed
\item Ship turn rate
\end{itemize}
\end{frame}
\begin{frame}{Metrics}
\begin{block}{Question}
\item Rankings
\item Score difference
\item Time to win (game ticks)
\item Distance travelled
\end{itemize}
\end{frame}
\begin{frame}{Metrics}
\begin{block}{Exercise}
Create a version of \textit{Asteroids} that \textbf{disadvantages} the rotate and shoot player over the other agents.
\section{Asteroids Codebase}
\begin{frame}{Overview}
\begin{itemize}
\item Relatively simple
\item Easy to change parameters
\item Can customise it further if you particularly want something else
\item Genetic algorithm included to assist you
\begin{itemize}
\item Only thing it needs ... a better Fitness Function
\end{itemize}
\end{itemize}
\end{frame}
\begin{minted}[breaklines,tabsize=2,fontsize=\footnotetext]{Java}
SimpleBattle battle = new SimpleBattle(true, params);
BattleController p1 = new SingleMCTSPlayer(new Random());
battle.playGame(
p1,
new MultiRecorder(scoreRecorder, bulletRecorder)
);
\end{minted}
\note{Most examples shortened for fitting in the slides}
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
\begin{frame}[fragile]{Parameters?}
\begin{minted}[breaklines,tabsize=2,fontsize=\footnotetext]{Java}
int[] params = new int[N_PARAMS];
Arrays.fill(params, -1);
params[N_MISSILES] = 200;
\end{minted}
The set of parameters currently supported is in that handy list from slide \ref{parameters}
\end{frame}
\begin{frame}{Searching the space}
\begin{itemize}[<+->]
\item Searching design spaces can require a lot of computational power.
\item We can do better
\item Genetic Algorithms can aid us here \note{We will cover how they work later}
\item We have implemented a basic searcher using a GA Library
\item It'll do for now
\item Head to class ``com.fossgalaxy.games.asteroids.battle.jenetics.Jenetics''
\end{itemize}
\end{frame}
\begin{frame}[fragile]{Jenetics: Parameters}
\begin{minted}[breaklines,tabsize=2,fontsize=\footnotetext]{Java}
Arrays.fill(USING, false);
USING[N_MISSILES] = true;
USING[BULLET_TIME_TO_LIVE] = true;
USING[SHIP_MAX_SPEED] = true;
USING[SHIP_STEER_RATE] = true;
USING[BULLET_KILL_SHIP] = true;
\end{minted}
\end{frame}
\begin{frame}[fragile]{Jenetics: Limits}
\begin{minted}[breaklines,tabsize=2,fontsize=\footnotetext]{Java}
int[][] limits = {
{10, 500}, // N_MISSILES
{20, 100}, // BULLETT_TIME_TO_LIVE
{1, 10},
{5, 50},
{0, 1}
};
\end{minted}
\end{frame}
\begin{frame}[fragile]{Jenetics: Chromosomes}
\begin{minted}[breaklines,tabsize=2,fontsize=\footnotetext]{Java}
// Convert limits to the chromosomes
List<Chromosome<IntegerGene>> genes = Arrays
.stream(limits)
.map(x -> IntegerChromosome.of(x[0], x[1], 1))
.collect(Collectors.toList());
// Chromosomes to genotype
Factory<Genotype<IntegerGene>> genotype = Genotype.of(genes);
\end{minted}
\end{frame}
\begin{frame}[fragile]{Jenetics: Fitness}
\begin{minted}[breaklines,tabsize=2,fontsize=\footnotetext]{Java}
int[] params = getParamsFromGenotype(genotype);
AIExperiment experiment = new AIExperiment(5, controllerFunctions, params);
Map<String, List<Integer>> scores = experiment.run();
Map<String, Integer> avg = new HashMap<>();
for(Map.Entry<String, List<Integer>> entry : scores.entrySet()){
avg.put(
entry.getKey(),
entry.getValue().stream().mapToInt(Integer::new).sum() / 5);
}
return avg.get("PiersMCTS") - avg.get("RotateAndShoot");
\end{minted}
\end{frame}
\begin{frame}[fragile]{Jenetics: Engine}
\begin{minted}[breaklines,tabsize=2,fontsize=\footnotetext]{Java}
ExecutorService exec = Executors.newFixedThreadPool(3);
final Engine<IntegerGene, Double> engine = Engine
.builder(Jenetics::fitness, genotype)
.populationSize(50)
.executor(exec)
.optimize(Optimize.MAXIMUM)
.build();
\end{minted}
\end{frame}
\begin{frame}[fragile]{Jenetics: Running it}
\begin{minted}[breaklines,tabsize=2,fontsize=\footnotetext]{Java}
final Genotype<IntegerGene> result = engine.stream()
.limit(limit.byExecutionTime(Duration.ofMinutes(120)))
.limit(300)
.peek( x-> {
System.out.println("Generation: " + x.getGeneration());
System.out.println("Best Fitness: " + x.getBestFitness());
}
)
.collect(EvolutionResult.toBestGenotype());
System.out.println(result);
\end{minted}
\end{frame}
\begin{frame}[allowframebreaks]
\frametitle{References}
\bibliography{shared/references.bib}
\end{frame}