Skip to content
Snippets Groups Projects
ai.tex 4.32 KiB
Newer Older
\subtitle{Artificial Intelligence}
\date{Monday, 21 May 2018}

\tikzset{
	treenode/.style = {align=center, inner sep=0pt, text centered,
		font=\sffamily},
	arn_n/.style = {treenode, circle, white, font=\sffamily\bfseries, draw=black,
		fill=black, text width=1.5em},% arbre rouge noir, noeud noir
	arn_r/.style = {treenode, circle, red, draw=red, 
		text width=1.5em, very thick},% arbre rouge noir, noeud rouge
	arn_x/.style = {treenode, rectangle, draw=black,
		minimum width=0.5em, minimum height=0.5em},% arbre rouge noir, nil	
	box/.style = {draw, align=center, text centered, rectangle, draw=black, minimum height=1.25cm, minimum width=2cm}
}

\DeclareMathOperator*{\argmax}{arg\,max}


\begin{document}
	
	\begin{frame}
	\titlepage
	\end{frame}

	\begin{frame}{Artificial Intelligence}
		\begin{itemize}
			\item Production Rule Agents
			\item Monte-Carlo Tree Search
			\item Genetic Algorithms
			\item Neural Networks
		\end{itemize}
	\end{frame}

\begin{frame}[fragile]{Production Rule Agents}
\begin{minted}[breaklines,tabsize=2,fontsize=\footnotesize]{Java}
@FunctionalInterface
public interface Rule
{

default boolean canFire(int playerID, GameState state)
{
return execute(playerID, state) != null;
}		
Action execute(int playerID, GameState state);	
}
\end{minted}
\end{frame}
\begin{frame}{Production Rule Agents}
	\begin{tikzpicture}[]
		\node[state,initial] (0) {\tiny Pop next rule};
		\node[state] (1) [above right=of 0] {\tiny Check if fires};
		\node[state,accepting] (1y) [above =of 1]{\tiny Return action};
		\node[state] (2) [below right=of 1] {\tiny Rule Remaining};
		\node[state, accepting] (3) [right= of 2] {\tiny Return null};
		\path[->]
		(0) edge [bend left] node [ above] {} (1)
		(1) edge node [left] {\tiny Yes} (1y)
		(1) edge [bend left] node [ below] {\tiny No} (2)
		(2) edge [bend left] node [ below] {\tiny Yes} (0)
		(2) edge [bend left] node [ below] {\tiny No} (3);
	\end{tikzpicture}	
\end{frame}
\begin{frame}{Production Rule Agents}
	\begin{center}
		\includegraphics[scale=0.175]{hanabiBuilder}
	\end{center}

	\begin{block}{Exercise}
		\href{http://hanabi.fosslab.uk/builder.html}{Try it out!} 
		
		\note{
			Do live demo - 
			First Agent
			\begin{enumerate}
				\item Play If Certain
				\item Tell Randomly
				\item Discard Randomly
			\end{enumerate}
		Second Agent
		\begin{enumerate}
			\item Play Probably Safe Card: 0.8
			\item Tell Randomly
			\item Discard Randomly
		\end{enumerate}
	
		Place Discard at top of order and run. Order of rules important
	}
	\end{block}
\end{frame}


\begin{frame}[fragile]{Monte-Carlo Tree Search}
	\begin{center}
	\begin{tikzpicture}[->,>=stealth',level/.style={sibling distance = 5cm/#1,
		level distance = 1.5cm},scale=1,every node/.style={transform shape}] 
	\node [arn_n] {0}
	child{ 
		node [arn_r] (c1) {0}
		child{ node [arn_n] (c) {0} edge from parent node[above left] {Tell 1}}
		child{ node [arn_n] (d) {1} edge from parent node[above right] {Play 1}}     
		edge from parent node[above left] {Tell 1}                     
	}
	child{ node [arn_r] {0}
		child{ node [arn_n] (a) {0} edge from parent node[above left] {Tell 1}}
		child{ node [arn_n] (b) {1} edge from parent node [above right] {Play 1}
		}
		edge from parent node [above right]{Discard 1}
	}
	;
	\path (a) -- (b) node [midway] {$\cdots$};
	\path (c) -- (d) node [midway] {$\cdots$};
	\end{tikzpicture}
	\end{center}
\end{frame}

\begin{frame}{Monte-Carlo Tree Search}
	\begin{itemize}
		\item Selection
		\begin{itemize}
			\item $\argmax_i f(i) = \frac{w_i}{n_i} + c\sqrt{\frac{\ln N_i}{n_i}} $
		\end{itemize}
		\item Expansion
		\item Simulation
		\item Back-propagation
	\end{itemize}
\end{frame}

\begin{frame}{Genetic Algorithms}

	\begin{tikzpicture}
		\node[box](init) at (-1, 0){Initial \\ Population};
		\node[box](decode) at (2, 0){Decode \\ Population};
		\node[box](fitness) at (5, 0){Calculate \\ Fitness};
		\node[box](selection) at (8, 0){Selection};
		\node[box](cross) at (8, -2.5){Crossover};
		\node[box](mutate) at (8, -5){Mutation};
		\node[box](newPop) at (2, -5){New Population};
		
		\path[->]
		(init) edge [] node [] {} (decode)
		(decode) edge [] node [] {} (fitness)
		(fitness) edge [] node [] {} (selection)
		(selection) edge [] node [] {} (cross)
		(cross) edge [] node [] {} (mutate)
		(mutate) edge [] node [] {} (newPop)
		(newPop) edge [] node [] {} (decode)
		;
	\end{tikzpicture}
\end{frame}

\end{document}