diff --git a/documents/2048/2048.tex b/documents/2048/2048.tex new file mode 100644 index 0000000..0878ce4 --- /dev/null +++ b/documents/2048/2048.tex @@ -0,0 +1,42 @@ +\documentclass[a4paper]{scrartcl} +\usepackage{amssymb, amsmath} % needed for math +\usepackage[utf8]{inputenc} % this is needed for umlauts +\usepackage[english]{babel} % this is needed for umlauts +\usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf +\usepackage[margin=2.5cm]{geometry} %layout +\usepackage{hyperref} % links im text +\usepackage{parskip} +\usepackage{csquotes} + +\title{The Game '2048'} +\author{Martin Thoma} + +\hypersetup{ + pdfauthor = {Martin Thoma}, + pdfkeywords = {Game, combinatorics, 2048}, + pdftitle = {The Game '2048'} +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Begin document % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{document} +\maketitle +\begin{abstract} +\enquote{2048} is a single-player game with random elements and a score. +\end{abstract} + +\section{Rules of '2048'} +\enquote{2048} is played on a $4 \times 4$ grid. + +\section{Best reachable highscore} + +\section{Algorithms} + +\section{Related} +\begin{itemize} + \item \url{http://math.stackexchange.com/q/716469/6876} + \item +\end{itemize} + +\end{document} diff --git a/documents/2048/Makefile b/documents/2048/Makefile new file mode 100644 index 0000000..3470522 --- /dev/null +++ b/documents/2048/Makefile @@ -0,0 +1,7 @@ +SOURCE = 2048 +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux *.out diff --git a/documents/2048/template/Makefile b/documents/2048/template/Makefile new file mode 100644 index 0000000..66e1c8e --- /dev/null +++ b/documents/2048/template/Makefile @@ -0,0 +1,35 @@ +SOURCE = pixel-art +DELAY = 80 +DENSITY = 300 +WIDTH = 512 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux *.data *.gnuplot *.gz *latexmk + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + make + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg + rsvg-convert -a -w $(WIDTH) -f svg $(SOURCE).svg -o $(SOURCE)2.svg + inkscape $(SOURCE)2.svg --export-plain-svg=$(SOURCE).svg + rm $(SOURCE)2.svg diff --git a/documents/2048/template/pixel-art.tex b/documents/2048/template/pixel-art.tex new file mode 100644 index 0000000..19f569e --- /dev/null +++ b/documents/2048/template/pixel-art.tex @@ -0,0 +1,44 @@ +\documentclass[tikz]{standalone} +\usepackage{ifthen} +\renewcommand\familydefault{\sfdefault} +\usepackage{tikz} +\usetikzlibrary{calc} +\def\pixels{ +{0,2,0,0}, +{0,8,0,4}, +{2,2,4,16}, +{8,16,128,2}, +} + +% Font color for 2 and 4: #776e65 +% Font color for rest: #f9f6f2 +% Grid color: #bbada0 +% Font family: "Clear Sans", "Helvetica Neue", Arial, sans-serif + +\definecolor{pixel 0}{HTML}{CCC0B3} +\definecolor{pixel 2}{HTML}{EEE4DA} +\definecolor{pixel 4}{HTML}{EEE4DA} +\definecolor{pixel 8}{HTML}{F2B179} +\definecolor{pixel 16}{HTML}{F59563} +\definecolor{pixel 32}{HTML}{F2B179} % TODO +\definecolor{pixel 64}{HTML}{F2B179} +\definecolor{pixel 128}{HTML}{EDCF72} +\definecolor{pixel 256}{HTML}{F2B179} % TODO +\definecolor{pixel 512}{HTML}{F2B179} % TODO +\definecolor{pixel 1024}{HTML}{F2B179} % TODO +\definecolor{pixel 2048}{HTML}{F2B179} % TODO +\definecolor{pixel 4096}{HTML}{F2B179} % TODO +\begin{document} +\begin{tikzpicture} + \foreach \line [count=\y] in \pixels { + \foreach \pix [count=\x] in \line { + \draw[fill=pixel \pix] (\x,-\y) rectangle +(1,1); + + \ifthenelse{\equal{0}{\pix}} + {} + {\node at ($(\x,-\y) + (0.5,0.5)$) {\Huge \pix};} + } + } + +\end{tikzpicture} +\end{document} diff --git a/tikz/2048/2048.png b/tikz/2048/2048.png new file mode 100644 index 0000000..eb1db7c Binary files /dev/null and b/tikz/2048/2048.png differ diff --git a/tikz/2048/2048.tex b/tikz/2048/2048.tex new file mode 100644 index 0000000..4b45561 --- /dev/null +++ b/tikz/2048/2048.tex @@ -0,0 +1,66 @@ +\documentclass[tikz]{standalone} +\renewcommand\familydefault{\sfdefault} +\usepackage{tikz} +\usetikzlibrary{fit,backgrounds} +% +\definecolor{grid color}{HTML}{BBADA0} +\definecolor{pixel 0}{HTML}{CCC0B3} +\definecolor{pixel 2}{HTML}{EEE4DA} +\definecolor{pixel 4}{HTML}{EDE0C8} +\definecolor{pixel 8}{HTML}{F2B179} +\definecolor{pixel 16}{HTML}{F59563} +\definecolor{pixel 32}{HTML}{F67C5F} +\definecolor{pixel 64}{HTML}{F65E3B} +\definecolor{pixel 128}{HTML}{EDCF72} +\definecolor{pixel 256}{HTML}{EDCC61} +\definecolor{pixel 512}{HTML}{EDC850} +\definecolor{pixel 1024}{HTML}{EDC53F} +\definecolor{pixel 2048}{HTML}{EDC22E} +\definecolor{pixel 4096}{HTML}{3E3933} +% +\definecolor{small color}{HTML}{776E65} +\definecolor{big color}{HTML}{F9F6F2} +% +\tikzset{ + case 2048 base/.style={minimum size=9mm,rounded corners=.3mm,text=#1,inner sep=0}, + % + case 2048 LARGE/.style={font=\LARGE\bfseries\sffamily,case 2048 base=#1}, + case 2048 Large/.style={font=\Large\bfseries\sffamily,case 2048 base=#1}, + case 2048 large/.style={font=\large\bfseries\sffamily,case 2048 base=#1}, + case 2048 normal/.style={font=\normalsize\bfseries\sffamily,case 2048 base=#1}, + % + case 2048 0/.style={case 2048 Large=black,fill=pixel 0,node contents={}}, + case 2048 2/.style={case 2048 Large=small color,fill=pixel 2,node contents={2}}, + case 2048 4/.style={case 2048 Large=small color,fill=pixel 4,node contents={4}}, + case 2048 8/.style={case 2048 Large=big color,fill=pixel 8,node contents={8}}, + case 2048 16/.style={case 2048 Large=big color,fill=pixel 16,node contents={16}}, + case 2048 32/.style={case 2048 Large=big color,fill=pixel 32,node contents={32}}, + case 2048 64/.style={case 2048 Large=big color,fill=pixel 64,node contents={64}}, + case 2048 128/.style={case 2048 large=big color,fill=pixel 128,node contents={128}}, + case 2048 256/.style={case 2048 large=big color,fill=pixel 256,node contents={256}}, + case 2048 512/.style={case 2048 large=big color,fill=pixel 512,node contents={512}}, + case 2048 1024/.style={case 2048 normal=big color,fill=pixel 1024,node contents={1024}}, + case 2048 2048/.style={case 2048 normal=big color,fill=pixel 2048,node contents={2048}}, + case 2048 4096/.style={case 2048 normal=big color,fill=pixel 4096,node contents={4096}}, +} +\begin{document} +\begin{tikzpicture} + \def\pixels{ + {0,2,32,64}, + {256,8,512,4}, + {1024,2048,4,16}, + {4096,16,128,2}, + } + + \foreach \line [count=\y] in \pixels { + \foreach \pix [count=\x] in \line { + \path (\x,-\y) node[name=c2048-\x-\y,case 2048 \pix]; + } + } + + \begin{scope}[on background layer] + \node[fill=grid color,fit=(c2048-1-1)(c2048-4-4), + inner sep=1mm,rounded corners=.3mm]{}; + \end{scope} +\end{tikzpicture} +\end{document} \ No newline at end of file diff --git a/tikz/2048/Makefile b/tikz/2048/Makefile new file mode 100644 index 0000000..36997be --- /dev/null +++ b/tikz/2048/Makefile @@ -0,0 +1,31 @@ +SOURCE = 2048 +DELAY = 80 +DENSITY = 300 +WIDTH = 512 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux *.data *.gnuplot + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/2048/Readme.md b/tikz/2048/Readme.md new file mode 100644 index 0000000..4f4e549 --- /dev/null +++ b/tikz/2048/Readme.md @@ -0,0 +1,7 @@ +Compiled example +---------------- +![Example](2048.png) + +Source +------ +[How can I create a template for 2048 game situations?](http://tex.stackexchange.com/q/174806/5645) \ No newline at end of file