Tikz を使用してこの図を完成させるにはどうすればよいでしょうか?

Tikz を使用してこの図を完成させるにはどうすればよいでしょうか?

プエルトリコ数学オリンピックで次の写真を見ました。図はカーペットが広がっているところです。

ここに画像の説明を入力してください

シリンダーの部分はできなかったし、黒い四角に記号を入れられなかった

\documentclass{exam}
\usepackage{tikz}           
\usepackage{amsmath}   
\usepackage{amssymb}   
\usepackage{amsfonts}  
\usepackage{latexsym}       %simbolos do Latex    
\usepackage{bbm}        %simbolos de conjuntos   
\usepackage{pstricks}   
\usepackage{pstricks-add, pst-eucl, here}  
\usepackage{MnSymbol}

\begin{document}  
\begin{center}   
\begin{tikzpicture}[scale=0.8, angle=90]

\draw[ultra thick](0,0)--(7,0)--(7,9)--(0,9)--(0,0);    
\draw[thick] (1,0)--(1,9);    
\draw[thick] (2,0)--(2,9);    
\draw[thick] (3,0)--(3,9);   
\draw[thick] (4,0)--(4,9);   
\draw[thick] (5,0)--(5,9);
\draw[thick] (6,0)--(6,9);   
\draw[thick] (7,0)--(7,9);   
\draw[thick] (0,1)--(7,1); 
\draw[thick] (0,2)--(7,2);  
\draw[thick] (0,3)--(7,3);   
\draw[thick] (0,4)--(7,4);   
\draw[thick] (0,5)--(7,5);   
\draw[thick] (0,6)--(7,6);  
\draw[thick] (0,7)--(7,7);  
\draw[thick] (0,8)--(7,8);  
\draw[thick] (0,9)--(7,9);

\draw[thick,<-] (-0.5,0)--(-0.5,4);  
\draw[thick,->] (-0.5,4.5)--(-0.5,9);   
\draw[thick,<-] (0,-0.5)--(2.6,-0.5);  
\draw[thick,->] (3.7,-0.5)--(7,-0.5);

\draw[fill=black] (0,1) rectangle (1,2);  
\draw[fill=black] (2,1) rectangle (3,2);
\draw[fill=black] (4,1) rectangle (5,2);    
\draw[fill=black] (6,1) rectangle (7,2);
\draw[fill=black] (0,3) rectangle (1,4);   
\draw[fill=black] (2,3) rectangle (3,4);  
\draw[fill=black] (4,3) rectangle (5,4);   
\draw[fill=black] (6,3) rectangle (7,4);   
\draw[fill=black] (0,5) rectangle (1,6);    
\draw[fill=black] (2,5) rectangle (3,6);   
\draw[fill=black] (4,5) rectangle (5,6);    
\draw[fill=black] (6,5) rectangle (7,6);    
\draw[fill=black] (0,7) rectangle (1,8);    
\draw[fill=black] (2,7) rectangle (3,8);    
\draw[fill=black] (4,7) rectangle (5,8);    
\draw[fill=black] (6,7) rectangle (7,8);   
\draw[fill=black] (1,6) rectangle (2,7);    
\draw[fill=black] (3,6) rectangle (4,7);   
\draw[fill=black] (5,6) rectangle (6,7);   
\draw[fill=black] (3,0) rectangle (4,1);   
\draw[fill=black] (5,0) rectangle (6,1);   
\draw[fill=black] (1,0) rectangle (2,1);   
\draw[fill=black] (1,2) rectangle (2,3);   
\draw[fill=black] (3,2) rectangle (4,3);   
\draw[fill=black] (5,2) rectangle (6,3);   
\draw[fill=black] (1,4) rectangle (2,5);    
\draw[fill=black] (3,4) rectangle (4,5);   
\draw[fill=black] (5,4) rectangle (6,5);   
\draw[fill=black] (1,8) rectangle (2,9);   
\draw[fill=black] (3,8) rectangle (4,9);
\draw[fill=black] (5,8) rectangle (6,9);

\node at (0.5,0.5) {\LARGE{\textbf{$\ostar$}}};  
\node at (0.5,2.5) {\LARGE{\textbf{$\ostar$}}};   
\node at (0.5,4.5) {\LARGE{\textbf{$\ostar$}}};   
\node at (0.5,6.5) {\LARGE{\textbf{$\ostar$}}}; 
\node at (0.5,8.5) {\LARGE{\textbf{$\ostar$}}};    
\node at (1.5,1.5) {\LARGE{\textbf{$\ostar$}}};    
\node at (1.5,3.5) {\LARGE{\textbf{$\ostar$}}};   
\node at (1.5,5.5) {\LARGE{\textbf{$\ostar$}}};   
\node at (1.5,7.5) {\LARGE{\textbf{$\ostar$}}};    
\node at (2.5,0.5) {\LARGE{\textbf{$\ostar$}}};    
\node at (2.5,2.5) {\LARGE{\textbf{$\ostar$}}};   
\node at (2.5,4.5) {\LARGE{\textbf{$\ostar$}}};   
\node at (2.5,6.5) {\LARGE{\textbf{$\ostar$}}};   
\node at (2.5,8.5) {\LARGE{\textbf{$\ostar$}}};   
\node at (3.5,1.5) {\LARGE{\textbf{$\ostar$}}};   
\node at (3.5,3.5) {\LARGE{\textbf{$\ostar$}}};    
\node at (3.5,5.5) {\LARGE{\textbf{$\ostar$}}};   
\node at (3.5,7.5) {\LARGE{\textbf{$\ostar$}}};   
\node at (4.5,0.5) {\LARGE{\textbf{$\ostar$}}};   
\node at (4.5,2.5) {\LARGE{\textbf{$\ostar$}}};  
\node at (4.5,4.5) {\LARGE{\textbf{$\ostar$}}};  
\node at (4.5,6.5) {\LARGE{\textbf{$\ostar$}}};  
\node at (4.5,8.5) {\LARGE{\textbf{$\ostar$}}};  
\node at (5.5,1.5) {\LARGE{\textbf{$\ostar$}}};   
\node at (5.5,3.5) {\LARGE{\textbf{$\ostar$}}};  
\node at (5.5,5.5) {\LARGE{\textbf{$\ostar$}}};  
\node at (5.5,7.5) {\LARGE{\textbf{$\ostar$}}};  
\node at (6.5,0.5) {\LARGE{\textbf{$\ostar$}}};  
\node at (6.5,2.5) {\LARGE{\textbf{$\ostar$}}}; 
\node at (6.5,4.5) {\LARGE{\textbf{$\ostar$}}}; 
\node at (6.5,6.5) {\LARGE{\textbf{$\ostar$}}};  
\node at (6.5,8.5) {\LARGE{\textbf{$\ostar$}}};   
\node at (6.5,1.5) {\LARGE{\textbf{$\ostar$}}};   
\node at (6.5,3.5) {\LARGE{\textbf{$\ostar$}}};
\node at (6.5,5.5) {\LARGE{\textbf{$\ostar$}}};  
\node at (6.5,7.5) {\LARGE{\textbf{$\ostar$}}};  
\node at (1.5,8.5) {\LARGE{\textbf{$\leftmoon$}}};  
\node at (1.5,5.5) {\LARGE{\textbf{$\leftmoon$}}};  
\node at (3.5,0.5) {\LARGE{\textbf{$\leftmoon$}}}; 
\node at (3.5,2.5) {\LARGE{\textbf{$\leftmoon$}}}; 
\node at (3.5,6.5) {\LARGE{\textbf{$\leftmoon$}}}; 
\node at (5.5,4.5) {\LARGE{\textbf{$\leftmoon$}}};  
\node at (5.5,8.5) {\LARGE{\textbf{$\leftmoon$}}};   
\node at (-0.7, 4.25) {36dm};  
\node at (3.1, -0.5) {36dm}; 
\end{tikzpicture}  
\end{center}    
\end{document}

ここに画像の説明を入力してください

答え1

マトリックスを使用してコードを簡略化することもできます。

\documentclass{exam}
\usepackage{tikz}           
\usepackage{amsmath}   
\usepackage{amsfonts}  
\usepackage{latexsym} 
\usepackage{mathabx} 
\usepackage{MnSymbol}

\usetikzlibrary{shapes.geometric}

\begin{document}  
\begin{center}   
\begin{tikzpicture}[scale=0.8]
  \def\B{\node[fill=black,text=white,minimum width=1cm,minimum height=1cm] {\LARGE$\leftmoon$};}%
  \def\W{\node[fill=white,minimum width=1cm,minimum height=1cm] {\LARGE$\ostar$};}%

\node[matrix,draw=black,ultra thick,inner sep=1pt] (grid)
{
  \W & \B & \W & \B & \W \\
  \B & \W & \B & \W & \B \\
  \W & \B & \W & \B & \W \\
  \B & \W & \B & \W & \B \\
  \W & \B & \W & \B & \W \\
  \B & \W & \B & \W & \B \\
  \W & \B & \W & \B & \W \\
  \B & \W & \B & \W & \B \\
  \W & \B & \W & \B & \W \\
};

\node[xshift=1cm,yshift=-.1cm,cylinder,rotate=90,
  draw=black,thick,fill=gray,
  minimum height=9.35cm,minimum width=2cm] at (grid.east) {};

\end{tikzpicture}  
\end{center}    
\end{document}

デモ画像

答え2

私の「シリンダー」はあまりリアルに見えないことを認めざるを得ませんが、いずれにしても、結果ははるかに短いコードで実現できます。何かわからないことがあれば、遠慮なく質問してください。たくさん定義が\node面倒になります。

パッケージ リストをそのまま残したのは、ドキュメント内の他の場所でそれらを使用しているかどうかわからないためですが、これらの多くはこのコードには必要ありません。

出力

ここに画像の説明を入力してください

コード

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}           
\usepackage{amsmath}   
\usepackage{amssymb}   
\usepackage{amsfonts}  
\usepackage{latexsym}       %simbolos do Latex    
\usepackage{bbm}        %simbolos de conjuntos   
\usepackage{pstricks}   
\usepackage{pstricks-add, pst-eucl, here}  
\usepackage{MnSymbol}
\usepackage{wasysym}

\usetikzlibrary{arrows.meta, patterns, shadings}

\begin{document}  
\begin{tikzpicture}

\foreach \y [count=\nrow starting from 0] in {0,1,...,9} {
\foreach \x in {0,1,...,7} {
    \pgfmathsetmacro\color{int(mod(\y + \x, 2)) ? "black" : "white"}
    \fill[draw,fill=\color] (\x,\y) rectangle (\x+1,\y+1);
    \ifnum\pdfstrcmp{\color}{white}=0
        \node[font=\bfseries\LARGE] at (\x+.5,\y+.5) {$\ostar$}; 
    \else
        \node[font=\bfseries\LARGE, text=white] at (\x+.5,\y+.5) {$\leftmoon$};
    \fi 
    }
}

\draw[left color=gray!50!black, right color=gray!50!black, middle color=gray!80, pattern color=black] (7.3,.3) --++ (0,9.7) arc (180:0:.7 and .3) -- (8.7,.3) -- cycle;
\fill[gray!30!black] (8,.25) ellipse (.7 and .3);

\draw[{Latex}-{Latex}] (0,-1) -- (8,-1)  node[fill=white, midway] {60dm};
\draw[{Latex}-{Latex}] (-1,0) -- (-1,10) node[fill=white, midway] {36dm};
\end{tikzpicture}    
\end{document}

関連情報