s-games-2023.mkxl /size: 6132 b    last modification: 2024-01-16 10:22
1%D \module
2%D   [      file=s-games-2023,
3%D        version=2023.12.20,
4%D          title=\CONTEXT\ Style File,
5%D       subtitle=A Simple Card Game,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14%D This style is a side track of the 2023 X-mas card which is similar
15%D but on a 100 by 100 grid. Because the shapes are rather nice and
16%D intriguing we decided to see if we could make it into a match them
17%D game. So here it is. Maybe at the 2023 \CONTEXT\ meeting we will
18%D play a bit with different formulas.
19
20\startluacode
21    local sin, cos, tan, log = math.sin, math.cos, math.tan, math.log
22
23    local N = 20
24    local M = 0
25
26    M = math.random(100)/100
27
28    local mybitmaps = {
29        [1] = function(x,y)
30            x = x + M
31            y = y + M
32            local z = sin(x*x) - cos(y*y)
33            if z > 0 then
34                return '1'
35            else
36                return '0'
37            end
38        end,
39        [2] = function(x,y)
40            x = x + M
41            y = y + M
42            local z = sin(x*x) + cos(y*y) + tan(x*y)
43            if z > 0 then
44                return '1'
45            else
46                return '0'
47            end
48        end,
49        [3] = function(x,y)
50            x = x + M
51            y = y + M
52            local z = tan(x*x) + tan(y*y) + tan(y*x)
53            if z > 0 then
54                return '1'
55            else
56                return '0'
57            end
58        end,
59        [4] = function(x,y)
60            x = x + M
61            y = y + M
62            local z = sin(sin(x*x)) - sin(sin(y*y))
63            if z > 0 then
64                return '1'
65            else
66                return '0'
67            end
68        end,
69        [5] = function(x,y)
70            x = x + M
71            y = y + M
72            local z = (100*(log(x*x) - log(y*y))) // 2
73            if (z % 2) == 1 then
74                return '1'
75            else
76                return '0'
77            end
78        end
79    }
80
81    local mybitmap = mybitmaps[1]
82 -- local mybitmap = mybitmaps[4]
83
84    -- generate a N * N bitmap of "1" and "0" and store it
85
86    function MP.setmybitmap(n)
87        N = n
88        potrace.setbitmap("MyBitMap",potrace.contourplot(N,N,mybitmap))
89        M = M + math.pi/24
90    end
91\stopluacode
92
93\definecolor[colortwo][h=0057b7] % the ukraine flag colors
94\definecolor[colorone][h=ffd700] % yellowish and blueish
95
96\setMPvariables[whatever][n=100,a=1]
97
98\startuseMPgraphic{whatever}{n,a}
99    MP.setmybitmap(\MPvar{n});
100    % let potrace generate outlines from the stored bitmap
101    picture r ; r := image (
102        draw lmt_potraced [
103            stringname = "MyBitMap",
104            value      = "1",
105            size       = 0,
106        ] ;
107    ) xysized (10cm,10cm) ;
108    setbounds r to
109        boundingbox r
110        enlarged 5mm
111    ;
112    % actually it's one path as we used &&&
113    if \MPvar{a} = 2 :
114        draw boundingbox r
115            withcolor .5white
116            withpen pencircle scaled 5 ;
117        draw r
118            withcolor .3white ;
119    else :
120        fill boundingbox r
121            withcolor "colorone" ;
122        draw r
123            withcolor "colortwo" ;
124    fi ;
125\stopuseMPgraphic
126
127\protected\def\MakeSet#1#2#3#4#5{
128    \dorecurse{#1} {
129        \startTEXpage[offset=1cm]
130            \vbox \bgroup
131                \offinterlineskip
132                \dorecurse{#2} {%
133                    \hbox \bgroup
134                        \dorecurse{#3} {%
135                            \useMPgraphic{whatever}{n=#4,a=#5}%
136                            \hskip5mm
137                        }%
138                        \unskip
139                    \egroup
140                    \vskip5mm
141                }%
142                \removelastskip
143            \egroup
144        \stopTEXpage
145    }
146}
147
148\setuplayout[tight]
149
150\startbuffer[game-2023]
151
152\page \setupwhitespace[big]
153
154\subject{The addendum to the 2023 X-mas card}
155
156This is a \quote {find matching shapes} game for all ages, inspired by the
157\PRAGMA\ 2023 X-mas card. You can invent the rules yourself but this is how we
158played it during the holidays:
159
160\startitemize
161    \startitem
162        We took the (3 by 5, 12 page, complexity 20) version and printed two
163        copies on 160-200 gram paper. Any decent printer will scale to fit and it
164        looks quite okay on a proper inkjet printer.
165    \stopitem
166    \startitem
167        The print is cut into rectangles. You don't need to be too precise but try
168        to get through the middle of the white lines. Shuffle the cards and make a
169        stack.
170    \stopitem
171    \startitem
172        Best let one person lay out the cards slowly till there are some six by
173        four on the table and at some point matching pairs will show up.
174    \stopitem
175    \startitem
176        Add more card if needed. After a while players will start calling the
177        cards names, because human pattern recognition kicks in.
178    \stopitem
179    \startitem
180        When a player extracts a match the emptyt spaces will be filled with new
181        samples.
182    \stopitem
183    \startitem
184        Of course once you run out of new cards to lay out, the collection of
185        pairs speeds up. Some players can catch up at the end.
186    \stopitem
187\stopitemize
188
189Nothing prohibits to play with three copies and we can make it as complex as
190needed. Afterwards you can try to figure out the logic behind the shapes. If
191there is demand more variants can be provided and we can introduce more
192randomness. Just ask for it on the mailing list.
193
194\blank
195
196\startlines
197Hans Hagen & Ton Otten
198PRAGMA ADE, Hasselt NL
199December 2023
200\stoplines
201
202\page
203
204\stopbuffer
205
206\continueifinputfile{s-games-2023.mkxl}
207
208\setupbodyfont[dejavu] \setupwhitespace[big]
209
210\starttext
211
212% \MakeSet {8}{6}{4} {10} {1} %  8 * 24
213% \MakeSet{10}{5}{3} {15} {1} % 10 * 15
214% \MakeSet{10}{5}{3} {15} {1} % 10 * 15
215% \MakeSet{1}{40}{30} {20} {1} % 10 * 12
216\MakeSet{1}{40}{30} {15} {1} % 10 * 12
217\MakeSet{1}{40}{30} {20} {1} % 10 * 12
218
219% \getbuffer[game-2023]
220
221\stoptext
222