0

I am having trouble working with this code :

\documentclass[aspectratio=43]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[export]{adjustbox}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{pgfpages}
\setbeamerfont{caption}{size=\scriptsize}
\usepackage{tikz}
\usepackage{enumitem}

\usetheme{Madrid}
\usecolortheme{default}

\lstset{ %
  backgroundcolor=\color{white}, 
  basicstyle=\footnotesize,       
  breakatwhitespace=false,        
  breaklines=true,                 
  captionpos=b,                    
  commentstyle=\color{mygreen},   
  escapeinside={\%*}{*)},        
  extendedchars=true,              
  frame=single,                  
  keywordstyle=\color{blue},       
  language=Prolog,                
  numbers=left,                    
  numbersep=5pt,                   
  numberstyle=\tiny\color{mygray},
  rulecolor=\color{black},        
  showspaces=false,               
  showstringspaces=false,          
  showtabs=false,                  
  stepnumber=2,                    
  stringstyle=\color{mymauve},   
  tabsize=2,                      
  title=\lstname,                  
  morekeywords={not,\},\{,preconditions,effects },            
  deletekeywords={time}            
}

%------------------------------------------------------------
%This block of code defines the information to appear in the
%Title page
\title[Des stratégies pour performer au Blokus en C] %optional
{Des stratégies pour performer au Blokus en C}


\author[Zazie] % (optional)
{Zazie}




%End of title page configuration block
%------------------------------------------------------------



%------------------------------------------------------------
%The next block of commands puts the table of contents at the 
%beginning of each section and highlights the current section:

\AtBeginSection[]
{
  \begin{frame}
    \frametitle{Sommaire}
    \tableofcontents[currentsection]
  \end{frame}
}
%------------------------------------------------------------


\begin{document}

%The next statement creates the title page.
\frame{\titlepage}


%---------------------------------------------------------
%This block of code is for the table of contents after
%the title page
\begin{frame}
\frametitle{Sommaire}
\tableofcontents
\end{frame}
%---------------------------------------------------------


\section{Présentation}
%---------------------------------------------------------
%Changing visivility of the text
\begin{frame}{Présentation}
\begin{columns}
\begin{column}{0.5\textwidth}
    Nombre de joueur : 2\newline
    Plateau de taille : $14\times14$ \newline
    Nombre de pièces : 21\newline
\end{column}
\begin{column}{0.5\textwidth}  %%<--- here
    \begin{center}
     \includegraphics[scale=0.3, center]{pièces_blokus.png}
     \caption{\scriptsize{Issu du document de Chin Hung Chao, Blokus Game Solver}}
     \end{center}
\end{column}
\end{columns}

\end{frame}

\begin{frame}
    \begin{itemize}
        \item Contexte
        \item Problèmatiques
        \begin{itemize}
            \item Comment implémenter de façon optimale le jeu ?
            \item Comment implémenter les différentes stratégies ?
            \item Sont-elles envisageables ?
        \end{itemize}
        \item Objectifs
        \begin{enumerate}
            \item Implémenter le jeu
            \item Implémenter des stratégies
            \item Comparer celles-ci
        \end{enumerate}
    \end{itemize}
\end{frame}
\end{document}

When I compile, it displays the error :

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.110 \end{frame}
                 
You're in trouble here.  Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.

And

\labelenumi ->{
               \labelenumi }
l.128 \end{frame}
                 
If you really absolutely need more capacity,
you can ask a wizard to enlarge me.

Before to return in Overleaf, my code compiled correctly but not now, there doesn't have pdf view.

Thank you for your help !

3
  • your example is too long. Comment parts until you get a short example. Commented Jun 4 at 21:12
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Jun 4 at 21:35
  • I've flagged this because your name and details remain in the edit history of both your question and the answer. If their being public is a real problem for you, you should probably also reach out to SE and I would also delete this question temporarily if the site will let you. (But you should know that some of us can view deleted posts, so it is only a bit less public.)
    – cfr
    Commented Jun 5 at 6:37

1 Answer 1

1

There are a couple of errors in your code:

  • Don't use the enumitem package with beamer

  • you must not use \caption outside of an environment like figure

  • the colour mygray etc. is not defined

  • don't use special characters like ê in your listing

\documentclass[aspectratio=43]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[export]{adjustbox}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{pgfpages}
\setbeamerfont{caption}{size=\scriptsize}
\usepackage{tikz}
%\usepackage{enumitem}

\colorlet{mygray}{gray}
\colorlet{mygreen}{green}

\usetheme{Madrid}
\usecolortheme{default}

\lstset{ %
  backgroundcolor=\color{white}, 
  basicstyle=\footnotesize,       
  breakatwhitespace=false,        
  breaklines=true,                 
  captionpos=b,                    
  commentstyle=\color{mygreen},   
  escapeinside={\%*}{*)},        
  extendedchars=true,              
  frame=single,                  
  keywordstyle=\color{blue},       
  language=Prolog,                
  numbers=left,                    
  numbersep=5pt,                   
  numberstyle=\tiny\color{mygray},
  rulecolor=\color{black},        
  showspaces=false,               
  showstringspaces=false,          
  showtabs=false,                  
  stepnumber=2,                    
  stringstyle=\color{mymauve},   
  tabsize=2,                      
  title=\lstname,                  
  morekeywords={not,\},\{,preconditions,effects },            
  deletekeywords={time}            
}

%------------------------------------------------------------
%This block of code defines the information to appear in the
%Title page
\title[Des stratégies pour performer au Blokus en C] %optional
{Des stratégies pour performer au Blokus en C}


\author[Zazie] % (optional)
{Zazie}


\date[2023-2024] % (optional)
{2023-2024}


%End of title page configuration block
%------------------------------------------------------------



%------------------------------------------------------------
%The next block of commands puts the table of contents at the 
%beginning of each section and highlights the current section:

\AtBeginSection[]
{
  \begin{frame}
    \frametitle{Sommaire}
    \tableofcontents[currentsection]
  \end{frame}
}
%------------------------------------------------------------


\begin{document}

%The next statement creates the title page.
\frame{\titlepage}


%---------------------------------------------------------
%This block of code is for the table of contents after
%the title page
\begin{frame}
\frametitle{Sommaire}
\tableofcontents
\end{frame}
%---------------------------------------------------------


\section{Présentation}
%---------------------------------------------------------
%Changing visivility of the text
\begin{frame}{Présentation}
\begin{columns}
\begin{column}{0.5\textwidth}
    Nombre de joueur : 2\newline
    Plateau de taille : $14\times14$ \newline
    Nombre de pièces : 21\newline
\end{column}
\begin{column}{0.5\textwidth}  %%<--- here
    \begin{figure}
     \includegraphics[scale=0.3, center]{example-image-duck}
     \caption{\scriptsize Issu du document de Chin Hung Chao, Blokus Game Solver}
     \end{figure}
\end{column}
\end{columns}

\end{frame}



\begin{frame}
    \begin{itemize}
        \item Contexte
        \item Problèmatiques
        \begin{itemize}
            \item Comment implémenter de façon optimale le jeu ?
            \item Comment implémenter les différentes stratégies ?
            \item Sont-elles envisageables ?
        \end{itemize}
        \item Objectifs
        \begin{enumerate}
            \item Implémenter le jeu
            \item Implémenter des stratégies
            \item Comparer celles-ci
        \end{enumerate}
    \end{itemize}
\end{frame}

\section{Stratégies}

\begin{frame}{Stratégies}
    \begin{itemize}
        \item Aléatoire
        \item Algorithme glouton
        \item Algorithme glouton avancé
    \end{itemize}
\end{frame}
%---------------------------------------------------------
\section{Implémentation du jeu}
\subsection{Début difficile}

\defverbatim[colored]\lstI{
\begin{lstlisting}[language=C,basicstyle=\ttfamily,keywordstyle=\color{red}, caption=Implémentation naïve]
typedef struct carre carre;
typedef struct piece piece;

struct carre {
    int x;
    int y;
    carre* suiv;
};

struct piece{
    int id;
    int taille;
    int nb_coins;
    float densite;
    int x;
    int y;
    carre* points;
    carre* coins;
    int* points_x;
    int* points_y;
    int* coins_x;
    int* coins_y;
    piece* suiv;
    couple_int* refpt;
};
\end{lstlisting}
}

\begin{frame}[allowframebreaks]
\frametitle{Début difficile}
\lstI
\end{frame}

\defverbatim[colored]\lstII{
\begin{lstlisting}[language=C,basicstyle=\ttfamily,keywordstyle=\color{red}, caption=Implémentation avec trop de zéro]
typedef struct {
    int id;
    int shape[PIECE_SIZE][PIECE_SIZE];
    int size;
    float density;
} piece;

typedef struct {
    int cells[BOARD_SIZE][BOARD_SIZE];
}board;

piece pieces1[MAX_PIECES] = {
// ID 0
{
        .id = 0,
        .shape = {
            {1, 0, 0, 0, 0},
            {0, 0, 0, 0, 0},
            {0, 0, 0, 0, 0},
            {0, 0, 0, 0, 0},
            {0, 0, 0, 0, 0}
        },
        .size = 1,
        .density = 1.0 // 1 block / (1 width * 1 height)
    },
    // ID 1
    {
        .id = 1,
        .shape = {
            {1, 1, 0, 0, 0},
            {0, 0, 0, 0, 0},
            {0, 0, 0, 0, 0},
            {0, 0, 0, 0, 0},
            {0, 0, 0, 0, 0}
        },
        .size = 2,
        .density = 1.0 // 2 blocks / (2 width * 1 height)
    },
// [...]
}
\end{lstlisting}
}

\subsection{Déjà un peu mieux}

\begin{frame}[allowframebreaks]
\frametitle{Déjà un peu mieux}
\lstII
\end{frame}

\defverbatim[colored]\lstR{
\begin{lstlisting}[language=C,basicstyle=\ttfamily,keywordstyle=\color{red}, caption=Implémentation productive]
static int Pieces[21][4][5][5] = {
    // piece 0
    {
        {
            {1}
        },
    },
    // piece 1
    {
        {
            {1},
            {1}
        },
        {
            {1, 1},
        },
    },
    // piece 2
    {
        {
            {1},
            {1},
            {1}
        },
        {
            {1, 1, 1},
        },
    },
    // piece 3
    {
        {
            {1, 0},
            {1, 1}
        },
        {
            {1, 1},
            {1, 0}
        },
        {
            {1, 1},
            {0, 1}
        },
        {
            {0, 1},
            {1, 1}
        },
    },
// [...]
}
// nombre de rotation maximum ; hauteur ; largeur ; taille
static int Piece_Info[21][4] = {
    {1, 1, 1, 1},  // 0
    {2, 2, 1, 2},  // 1
    {2, 3, 1, 3},  // 2
    {4, 2, 2, 3},  // 3
// [...]
}
\end{lstlisting}
}

\subsection{La révélation}

\begin{frame}[allowframebreaks]
\frametitle{La révélation}
\lstR
\end{frame}

\section{Implémentation des stratégies}
\subsection{Aléatoire}
\defverbatim[colored]\lstAlea{
\begin{lstlisting}[language=C,basicstyle=\ttfamily,keywordstyle=\color{red}, caption=Stratégie aléatoire]
bool aleatoireStrat (joueur* player){
    if (player->nbCoins != 0){
        int p = player->nbCoins;
        int* dispoPiece = malloc(p*sizeof(int));
        memset(dispoPiece, 0, p*sizeof(int));
        for (int i = 0 ; i < p ; i++){
            dispoPiece[i] = player->tab[i];
        }
        while (dispoPiece != NULL){
            int aleat = rand()%p;
            for (int i = 0 ; i < Piece_Info[dispoPiece[aleat]][0] ; i++){
                point* movePiece = possibleMovePiece(player, Pieces[dispoPiece[aleat]][i]);
                if (movePiece != NULL){
                    majPlateauJoueurScore(player, Pieces[dispoPiece[aleat]][i], movePiece[0].x, movePiece[0].y, aleat);
                    free(dispoPiece);
                    return true;
                }
            }
            for (int i = aleat ; i < p-1 ; i++){
                dispoPiece[i] = dispoPiece[i+1];
            }
            dispoPiece = realloc(dispoPiece, p-1);
            p --;
        }
        free(dispoPiece);
        return false;
    }
    else if (player->count == 21){
        int x;
        int y;
        if (player->couleur == 1){
            x = 0;
            y = BOARD_SIZE-1;
        }
        else {
            x = BOARD_SIZE-1;
            y = 0;
        }
        int alea = rand()%21;
        bool findPiece = false;
        while (findPiece == false){
            for (int i = 0 ; i < Piece_Info[alea][0] ; i++){
                if (verifPosition(x, y, player, Pieces[alea][i])){
                    majPlateauJoueurScore(player, Pieces[alea][i], x, y, alea);
                    findPiece= true;
                    return true;
                }
            }
        }
        return false; // pas possible mais je le mets tout de meme
    }
    else {
        return false; // ca peut etre une fin de jeu
    }
}
\end{lstlisting}
}
\begin{frame}[allowframebreaks]
\frametitle{Aléatoire}
\lstAlea
\end{frame}

\subsection{Algorithmes gloutons}

\defverbatim[colored]\lstG{
\begin{lstlisting}[language=C,basicstyle=\ttfamily,keywordstyle=\color{red}, caption=Algorithme glouton simple]
bool gloutonStrat (joueur* player){
    qsort(player->tab, player->count, sizeof(int), compareSimple);
    for (int i = 0 ; i < player->count ; i++){
        for (int j = 0 ; j < Piece_Info[i][0] ; j++){
            if (possibleMovePiece(player, Pieces[i][j]) != NULL){
                point* possible = possibleMovePiece(player, Pieces[i][j]);
                majPlateauJoueurScore(player, Pieces[i][j], possible[0].x, possible[0].y, i);
                return true;
            }
        }
    }
    return false;
}
\end{lstlisting}
}

\defverbatim[colored]\lstGA{
\begin{lstlisting}[language=C,basicstyle=\ttfamily,keywordstyle=\color{red}, caption=Algorithme glouton avancé]
bool gloutonAvance (joueur* player){
    qsort(player->tab, player->count, sizeof(int), compareSimple);
    qsort(player->tab, player->count, sizeof(int), compareAvance);
    for (int i = 0 ; i < player->count ; i++){
        for (int j = 0 ; j < Piece_Info[i][0] ; j++){
            if (possibleMovePiece(player, Pieces[i][j]) != NULL){
                point* possible = possibleMovePiece(player, Pieces[i][j]);
                majPlateauJoueurScore(player, Pieces[i][j], possible[0].x, possible[0].y, i);
                return true;
            }
        }
    }
    return false;
}
\end{lstlisting}
}

\begin{frame}[allowframebreaks]
\frametitle{Algorithme glouton simple}
\lstG
\end{frame}

\begin{frame}[allowframebreaks]
\frametitle{Algorithme glouton avancé}
\lstGA
\end{frame}

\section{Résultats}

\begin{frame}{Résultats}
\begin{itemize}
    \item Aléatoire / Aléatoire : Complètement aléatoire, sans aucun avantage
    \item Glouton simple / Glouton simple :
    \item Glouton avancé / Glouton avancé :
    \item Aléatoire / Glouton simple :
    \item Glouton simple / Aléatoire : Victoire à chaque fois éclatante du premier joueur
    \item Glouton avancé / Glouton simple :
    \item Glouton simple / Glouton avancé :
    \item Glouton avancé / Aléatoire :
    \item Aléatoire / Glouton avancé :
\end{itemize}
    
\end{frame}

\section{Conclusion / Au-delà}
\begin{frame}{Conclusion / Au-delà}
    \begin{itemize}
        \item Uniquement des stratégies d'un jeu personnel
        \begin{itemize}
            \item Défense (Exemple : s'éloigner de l'adversaire ou créer des défenses par l'attaque)
            \item Attaque (Exemple : réduire le nombre de coins de l'adversaire)
            \item Contre-attaque
        \end{itemize}
        \item Envisager de comparer les stratégies avec une intelligence artificielle
    \end{itemize}
\end{frame}

\section{Annexe A : pieces.h}

\defverbatim[colored]\lstA{
\lstinputlisting[language=C,caption=pieces.h]{test.C}
}
\begin{frame}[allowframebreaks]
\frametitle{Annexe A : pieces.h}
\lstA
\end{frame}

\section{Annexe B : joueur.h}
\defverbatim[colored]\lstB{
\lstinputlisting[language=C,caption=joueur.h]{test.C}
}

\begin{frame}[allowframebreaks]
\frametitle{Annexe B : joueur.h}
\lstB
\end{frame}

\section{Annexe C : blokus.c}
\defverbatim[colored]\lstC{
\lstinputlisting[language=C,caption=blokus.c]{test.C}
}
\begin{frame}[allowframebreaks]
\frametitle{Annexe C : blokus.c}
\lstC
\end{frame}
\end{document}
4

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .