% !TEX Fiche « La tour » — source générée par la_tour_generateur.php
% Design « fiches » commun au site (cf. coll/latex_fiche_commun.py).
\documentclass[a4paper,11pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[french]{babel}
\usepackage[a4paper,top=3.2cm,bottom=2cm,left=2cm,right=2cm]{geometry}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{fancyhdr}
\usepackage{qrcode}
\usepackage[table]{xcolor}
\usepackage{amsmath,amssymb}
\usepackage{enumitem}
\AtBeginDocument{%
  \setlist[itemize]{leftmargin=1.8em,itemsep=0.5ex,topsep=0.4ex,parsep=0pt}%
  \setlist[itemize,1]{label=\textcolor{red!75!black}{\small\textbullet}}%
  \setlist[itemize,2]{label=\textcolor{red!75!black}{\scriptsize\textbullet}}%
}
\usepackage{titlesec}
\titlespacing*{\section}{0pt}{1.4ex}{0.6ex}
\titlespacing*{\subsection}{0pt}{1.0ex}{0.3ex}
\usepackage{multicol}
\setlength{\columnsep}{1.5em}
\usepackage{needspace}
\usepackage{tikz}
\usetikzlibrary{decorations.text}

\usepackage{tgheros}
\usepackage{xskak,chessboard}
\setchessboard{showmover=false,boardfontsize=12pt}
\pagestyle{fancy}
\fancyhf{}
\setlength{\headheight}{75pt}
\setlength{\headsep}{10pt}

\newcommand{\logowouf}{%
\begin{tikzpicture}[baseline={(current bounding box.center)},scale=0.55,
                    line cap=round,line join=round]
    \path[use as bounding box] (-2.20,-1.45) rectangle (2.20,2.20);
    \path[
        postaction={decorate},
        decoration={
            text along path,
            text={|\fontfamily{qhv}\bfseries\fontsize{9}{9}\selectfont|site2wouf.fr},
            text align={center},
            raise=0.03ex
        }
    ] (-1.29,0.48) arc[start angle=160,end angle=20,radius=1.29];
    \begin{scope}[xshift=-0.06cm]
        \fill[black] (-0.66,0.14) ellipse (0.21 and 0.31);
        \fill[black] ( 0.66,0.14) ellipse (0.21 and 0.31);
        \fill[black] (-0.23,0.49) ellipse (0.22 and 0.35);
        \fill[black] ( 0.23,0.49) ellipse (0.22 and 0.35);
        \fill[black]
            (0,-0.10)
            .. controls (-0.36,-0.02) and (-0.63,-0.24) .. (-0.58,-0.58)
            .. controls (-0.52,-0.93) and (-0.16,-1.12) .. (0,-0.90)
            .. controls (0.16,-1.12) and (0.52,-0.93) .. (0.58,-0.58)
            .. controls (0.63,-0.24) and (0.36,-0.02) .. (0,-0.10)
            -- cycle;
    \end{scope}
\end{tikzpicture}%
}
\newcommand{\titre}{La tour et ses libert\'es}
\newcommand{\soustitre}{Cycle 3 et Cycle 4 · Fiche n\textsuperscript{o}\,158}

\fancyhead[C]{%
\raisebox{4pt}{%
\begin{minipage}[c]{0.15\textwidth}
    \centering
    \logowouf
\end{minipage}
\begin{minipage}[c]{0.62\textwidth}
    \centering
    {\Large\bfseries \titre\par}
    {\small\color{gray} \soustitre}
\end{minipage}
\begin{minipage}[c]{0.21\textwidth}
    \centering
    \qrcode[height=1.5cm]{https://site2wouf.fr/la_tour.php?t=b3.f1-h6}\\[2pt]
    {\small\ttfamily\bfseries\color{red} TOUR0158}
\end{minipage}%
}
}

\begin{document}
\newchessgame

\noindent Aux \'echecs, la \textbf{tour} se d\'eplace sur les \textbf{colonnes} (lettres a--h) et les \textbf{rang\'ees} (chiffres 1--8). Par exemple, depuis la case \textbf{d5}, elle peut aller sur les cases surlign\'ees : \texttt{a5, b5, c5, e5, f5, g5, h5, d1, d2, d3, d4, d6, d7, d8}.
\begin{center}
  \chessboard[clearboard,showmover=false,pgfstyle=color,color=green!45,markfields={a5,b5,c5,e5,f5,g5,h5,d1,d2,d3,d4,d6,d7,d8},setpieces={Rd5}]
\end{center}
\begin{enumerate}[label=\textbf{\arabic*.},leftmargin=*,itemsep=1.4ex]
  \item \textbf{Une tour en b3.} On retire la tour et on en pose une en \textbf{b3}. Sur quelles cases peut-elle aller ? Combien a-t-elle de libert\'es ?
  \item \textbf{Une enqu\^ete.} Une tour peut se rendre en \textbf{f1} et \textbf{h6}. Sur quelle(s) case(s) est-elle situ\'ee ?
  \item \textbf{Les libert\'es selon la case.} \'Etudie, \`a l'aide d'un diagramme colori\'e et l\'egend\'e, le nombre de libert\'es de la tour \emph{en fonction de sa case de d\'epart}. Que remarques-tu ?
\end{enumerate}
\newpage
\section*{Corrig\'e}
\noindent\textbf{1.} La tour en b3 a \textbf{14 libert\'es} : \texttt{a3, c3, d3, e3, f3, g3, h3, b1, b2, b4, b5, b6, b7, b8}.
\begin{center}
  \chessboard[clearboard,showmover=false,pgfstyle=color,color=green!45,markfields={a3,c3,d3,e3,f3,g3,h3,b1,b2,b4,b5,b6,b7,b8},setpieces={Rb3}]
\end{center}
\smallskip\noindent\textbf{2.} Une tour qui peut se rendre en \textbf{f1} et \textbf{h6} se trouve sur \textbf{f6} ou \textbf{h1}. Les fl\`eches montrent, depuis chaque tour, les d\'eplacements vers les deux cases de d\'epart.
\begin{center}
  \chessboard[clearboard,showmover=false,pgfstyle=color,color=yellow!65,markfields={f1},color=blue!30,markfields={h6},setpieces={Rf6, Rh1},pgfstyle=straightmove,arrow=to,linewidth=0.16em,color=green!55!black,markmoves={f6-f1,f6-h6,h1-f1,h1-h6}]
\end{center}
\smallskip\noindent\textbf{3.}
\begin{center}
\begin{tikzpicture}[scale=0.60,line join=round]
  \fill[red!0!yellow] (0,0) rectangle +(1,1);
  \node[font=\tiny,text=black] at (0.5,0.5) {14};
  \fill[red!0!yellow] (1,0) rectangle +(1,1);
  \node[font=\tiny,text=black] at (1.5,0.5) {14};
  \fill[red!0!yellow] (2,0) rectangle +(1,1);
  \node[font=\tiny,text=black] at (2.5,0.5) {14};
  \fill[red!0!yellow] (3,0) rectangle +(1,1);
  \node[font=\tiny,text=black] at (3.5,0.5) {14};
  \fill[red!0!yellow] (4,0) rectangle +(1,1);
  \node[font=\tiny,text=black] at (4.5,0.5) {14};
  \fill[red!0!yellow] (5,0) rectangle +(1,1);
  \node[font=\tiny,text=black] at (5.5,0.5) {14};
  \fill[red!0!yellow] (6,0) rectangle +(1,1);
  \node[font=\tiny,text=black] at (6.5,0.5) {14};
  \fill[red!0!yellow] (7,0) rectangle +(1,1);
  \node[font=\tiny,text=black] at (7.5,0.5) {14};
  \fill[red!0!yellow] (0,1) rectangle +(1,1);
  \node[font=\tiny,text=black] at (0.5,1.5) {14};
  \fill[red!0!yellow] (1,1) rectangle +(1,1);
  \node[font=\tiny,text=black] at (1.5,1.5) {14};
  \fill[red!0!yellow] (2,1) rectangle +(1,1);
  \node[font=\tiny,text=black] at (2.5,1.5) {14};
  \fill[red!0!yellow] (3,1) rectangle +(1,1);
  \node[font=\tiny,text=black] at (3.5,1.5) {14};
  \fill[red!0!yellow] (4,1) rectangle +(1,1);
  \node[font=\tiny,text=black] at (4.5,1.5) {14};
  \fill[red!0!yellow] (5,1) rectangle +(1,1);
  \node[font=\tiny,text=black] at (5.5,1.5) {14};
  \fill[red!0!yellow] (6,1) rectangle +(1,1);
  \node[font=\tiny,text=black] at (6.5,1.5) {14};
  \fill[red!0!yellow] (7,1) rectangle +(1,1);
  \node[font=\tiny,text=black] at (7.5,1.5) {14};
  \fill[red!0!yellow] (0,2) rectangle +(1,1);
  \node[font=\tiny,text=black] at (0.5,2.5) {14};
  \fill[red!0!yellow] (1,2) rectangle +(1,1);
  \node[font=\tiny,text=black] at (1.5,2.5) {14};
  \fill[red!0!yellow] (2,2) rectangle +(1,1);
  \node[font=\tiny,text=black] at (2.5,2.5) {14};
  \fill[red!0!yellow] (3,2) rectangle +(1,1);
  \node[font=\tiny,text=black] at (3.5,2.5) {14};
  \fill[red!0!yellow] (4,2) rectangle +(1,1);
  \node[font=\tiny,text=black] at (4.5,2.5) {14};
  \fill[red!0!yellow] (5,2) rectangle +(1,1);
  \node[font=\tiny,text=black] at (5.5,2.5) {14};
  \fill[red!0!yellow] (6,2) rectangle +(1,1);
  \node[font=\tiny,text=black] at (6.5,2.5) {14};
  \fill[red!0!yellow] (7,2) rectangle +(1,1);
  \node[font=\tiny,text=black] at (7.5,2.5) {14};
  \fill[red!0!yellow] (0,3) rectangle +(1,1);
  \node[font=\tiny,text=black] at (0.5,3.5) {14};
  \fill[red!0!yellow] (1,3) rectangle +(1,1);
  \node[font=\tiny,text=black] at (1.5,3.5) {14};
  \fill[red!0!yellow] (2,3) rectangle +(1,1);
  \node[font=\tiny,text=black] at (2.5,3.5) {14};
  \fill[red!0!yellow] (3,3) rectangle +(1,1);
  \node[font=\tiny,text=black] at (3.5,3.5) {14};
  \fill[red!0!yellow] (4,3) rectangle +(1,1);
  \node[font=\tiny,text=black] at (4.5,3.5) {14};
  \fill[red!0!yellow] (5,3) rectangle +(1,1);
  \node[font=\tiny,text=black] at (5.5,3.5) {14};
  \fill[red!0!yellow] (6,3) rectangle +(1,1);
  \node[font=\tiny,text=black] at (6.5,3.5) {14};
  \fill[red!0!yellow] (7,3) rectangle +(1,1);
  \node[font=\tiny,text=black] at (7.5,3.5) {14};
  \fill[red!0!yellow] (0,4) rectangle +(1,1);
  \node[font=\tiny,text=black] at (0.5,4.5) {14};
  \fill[red!0!yellow] (1,4) rectangle +(1,1);
  \node[font=\tiny,text=black] at (1.5,4.5) {14};
  \fill[red!0!yellow] (2,4) rectangle +(1,1);
  \node[font=\tiny,text=black] at (2.5,4.5) {14};
  \fill[red!0!yellow] (3,4) rectangle +(1,1);
  \node[font=\tiny,text=black] at (3.5,4.5) {14};
  \fill[red!0!yellow] (4,4) rectangle +(1,1);
  \node[font=\tiny,text=black] at (4.5,4.5) {14};
  \fill[red!0!yellow] (5,4) rectangle +(1,1);
  \node[font=\tiny,text=black] at (5.5,4.5) {14};
  \fill[red!0!yellow] (6,4) rectangle +(1,1);
  \node[font=\tiny,text=black] at (6.5,4.5) {14};
  \fill[red!0!yellow] (7,4) rectangle +(1,1);
  \node[font=\tiny,text=black] at (7.5,4.5) {14};
  \fill[red!0!yellow] (0,5) rectangle +(1,1);
  \node[font=\tiny,text=black] at (0.5,5.5) {14};
  \fill[red!0!yellow] (1,5) rectangle +(1,1);
  \node[font=\tiny,text=black] at (1.5,5.5) {14};
  \fill[red!0!yellow] (2,5) rectangle +(1,1);
  \node[font=\tiny,text=black] at (2.5,5.5) {14};
  \fill[red!0!yellow] (3,5) rectangle +(1,1);
  \node[font=\tiny,text=black] at (3.5,5.5) {14};
  \fill[red!0!yellow] (4,5) rectangle +(1,1);
  \node[font=\tiny,text=black] at (4.5,5.5) {14};
  \fill[red!0!yellow] (5,5) rectangle +(1,1);
  \node[font=\tiny,text=black] at (5.5,5.5) {14};
  \fill[red!0!yellow] (6,5) rectangle +(1,1);
  \node[font=\tiny,text=black] at (6.5,5.5) {14};
  \fill[red!0!yellow] (7,5) rectangle +(1,1);
  \node[font=\tiny,text=black] at (7.5,5.5) {14};
  \fill[red!0!yellow] (0,6) rectangle +(1,1);
  \node[font=\tiny,text=black] at (0.5,6.5) {14};
  \fill[red!0!yellow] (1,6) rectangle +(1,1);
  \node[font=\tiny,text=black] at (1.5,6.5) {14};
  \fill[red!0!yellow] (2,6) rectangle +(1,1);
  \node[font=\tiny,text=black] at (2.5,6.5) {14};
  \fill[red!0!yellow] (3,6) rectangle +(1,1);
  \node[font=\tiny,text=black] at (3.5,6.5) {14};
  \fill[red!0!yellow] (4,6) rectangle +(1,1);
  \node[font=\tiny,text=black] at (4.5,6.5) {14};
  \fill[red!0!yellow] (5,6) rectangle +(1,1);
  \node[font=\tiny,text=black] at (5.5,6.5) {14};
  \fill[red!0!yellow] (6,6) rectangle +(1,1);
  \node[font=\tiny,text=black] at (6.5,6.5) {14};
  \fill[red!0!yellow] (7,6) rectangle +(1,1);
  \node[font=\tiny,text=black] at (7.5,6.5) {14};
  \fill[red!0!yellow] (0,7) rectangle +(1,1);
  \node[font=\tiny,text=black] at (0.5,7.5) {14};
  \fill[red!0!yellow] (1,7) rectangle +(1,1);
  \node[font=\tiny,text=black] at (1.5,7.5) {14};
  \fill[red!0!yellow] (2,7) rectangle +(1,1);
  \node[font=\tiny,text=black] at (2.5,7.5) {14};
  \fill[red!0!yellow] (3,7) rectangle +(1,1);
  \node[font=\tiny,text=black] at (3.5,7.5) {14};
  \fill[red!0!yellow] (4,7) rectangle +(1,1);
  \node[font=\tiny,text=black] at (4.5,7.5) {14};
  \fill[red!0!yellow] (5,7) rectangle +(1,1);
  \node[font=\tiny,text=black] at (5.5,7.5) {14};
  \fill[red!0!yellow] (6,7) rectangle +(1,1);
  \node[font=\tiny,text=black] at (6.5,7.5) {14};
  \fill[red!0!yellow] (7,7) rectangle +(1,1);
  \node[font=\tiny,text=black] at (7.5,7.5) {14};
  \draw[gray!55,line width=0.3pt] (0,0) grid (8,8);
  \draw[black,line width=0.7pt] (0,0) rectangle (8,8);
  \node[font=\tiny] at (0.5,-0.32) {a};
  \node[font=\tiny] at (1.5,-0.32) {b};
  \node[font=\tiny] at (2.5,-0.32) {c};
  \node[font=\tiny] at (3.5,-0.32) {d};
  \node[font=\tiny] at (4.5,-0.32) {e};
  \node[font=\tiny] at (5.5,-0.32) {f};
  \node[font=\tiny] at (6.5,-0.32) {g};
  \node[font=\tiny] at (7.5,-0.32) {h};
  \node[font=\tiny] at (-0.32,0.5) {1};
  \node[font=\tiny] at (-0.32,1.5) {2};
  \node[font=\tiny] at (-0.32,2.5) {3};
  \node[font=\tiny] at (-0.32,3.5) {4};
  \node[font=\tiny] at (-0.32,4.5) {5};
  \node[font=\tiny] at (-0.32,5.5) {6};
  \node[font=\tiny] at (-0.32,6.5) {7};
  \node[font=\tiny] at (-0.32,7.5) {8};
\end{tikzpicture}
\end{center}
\nopagebreak\begin{center}\footnotesize
\colorbox{red!50!yellow}{~~}~\textbf{14} libert\'es sur \emph{toutes} les cases
\end{center}
\noindent La tour est un cas \`a part : elle a \textbf{14 libert\'es sur absolument toutes les cases} (7 sur sa rang\'ee + 7 sur sa colonne). Sa libert\'e ne d\'epend \emph{jamais} de sa position --- c'est un \textbf{invariant}.
\end{document}
