s-games-2023.mkxl /size: 6753 b    last modification: 2025-02-21 11:03
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    ) xysized (5cm,5cm) ;
109    setbounds r to
110        boundingbox r
111%         enlarged 5mm
112        enlarged 2.5mm
113    ;
114    % actually it's one path as we used &&&
115    if \MPvar{a} = 2 :
116        draw boundingbox r
117            withcolor .5white
118%             withpen pencircle scaled 5 ;
119            withpen pencircle scaled 2.5 ;
120        draw r
121            withcolor .3white ;
122    else :
123        fill boundingbox r
124            withcolor "colorone" ;
125        draw r
126            withcolor "colortwo" ;
127    fi ;
128\stopuseMPgraphic
129
130\setupTEXpage[offset=1cm]
131
132\protected\def\MakeOneSet#1#2#3#4{
133    \vbox \bgroup
134        \offinterlineskip
135        \dorecurse{#1} {%
136            \hbox \bgroup
137                \dorecurse{#2} {%
138                    \useMPgraphic{whatever}{n=#3,a=#4}%
139                    \hskip5mm
140                }%
141                \unskip
142            \egroup
143            \vskip5mm
144        }%
145        \removelastskip
146    \egroup
147}
148
149\protected\def\MakeSet#1#2#3#4#5{
150    \dorecurse{#1} {
151        \startTEXpage
152            \MakeOneSet{#2}{#3}{#4}{#5}%
153        \stopTEXpage
154    }
155}
156
157
158\setuplayout[tight]
159
160\startbuffer[game-2023]
161
162\page \setupwhitespace[big]
163
164\subject{The addendum to the 2023 X-mas card}
165
166This is a \quote {find matching shapes} game for all ages, inspired by the
167\PRAGMA\ 2023 X-mas card. You can invent the rules yourself but this is how we
168played it during the holidays:
169
170\startitemize
171    \startitem
172        We took the (3 by 5, 12 page, complexity 20) version and printed two
173        copies on 160-200 gram paper. Any decent printer will scale to fit and it
174        looks quite okay on a proper inkjet printer.
175    \stopitem
176    \startitem
177        The print is cut into rectangles. You don't need to be too precise but try
178        to get through the middle of the white lines. Shuffle the cards and make a
179        stack.
180    \stopitem
181    \startitem
182        Best let one person lay out the cards slowly till there are some six by
183        four on the table and at some point matching pairs will show up.
184    \stopitem
185    \startitem
186        Add more card if needed. After a while players will start calling the
187        cards names, because human pattern recognition kicks in.
188    \stopitem
189    \startitem
190        When a player extracts a match the emptyt spaces will be filled with new
191        samples.
192    \stopitem
193    \startitem
194        Of course once you run out of new cards to lay out, the collection of
195        pairs speeds up. Some players can catch up at the end.
196    \stopitem
197\stopitemize
198
199Nothing prohibits to play with three copies and we can make it as complex as
200needed. Afterwards you can try to figure out the logic behind the shapes. If
201there is demand more variants can be provided and we can introduce more
202randomness. Just ask for it on the mailing list.
203
204\blank
205
206\startlines
207Hans Hagen & Ton Otten
208PRAGMA ADE, Hasselt NL
209December 2023
210\stoplines
211
212\page
213
214\stopbuffer
215
216\continueifinputfile{s-games-2023.mkxl}
217
218\setupbodyfont[dejavu] \setupwhitespace[big]
219
220\starttext
221
222% \MakeSet {100}{1}{1} {10} {1} %  8 * 24
223% \MakeSet {100}{1}{1} {10} {1} %  8 * 24
224% \MakeSet {100}{1}{1} {15} {1} %  8 * 24
225% \MakeSet {100}{1}{1} {20} {1} %  8 * 24
226% \MakeSet {8}{6}{4} {10} {1} %  8 * 24
227% \MakeSet{10}{5}{3} {15} {1} % 10 * 15
228% \MakeSet{10}{5}{3} {15} {1} % 10 * 15
229% \MakeSet{1}{40}{30} {20} {1} % 10 * 12
230% \MakeSet{1}{40}{30} {15} {1} % 10 * 12
231% \MakeSet{1}{40}{30} {20} {1} % 10 * 12
232
233% \MakeSet{1}{40}{20} {20} {1} % 10 * 12
234% \MakeSet{1}{40}{20} {15} {1} % 10 * 12
235
236% \setupTEXpage[offset=overlay]
237% \MakeSet {5}{1}{1} {100} {1} %  8 * 24
238
239% 80 cm x 200
240
241
242% \setMPvariables[whatever][n=100,a=5]
243
244% \startTEXpage[width=80cm,height=200cm,offset=1cm,strut=no]
245%     \dontleavehmode\scale[width=78cm]{\MakeOneSet{50}{20}{15}{1}} % 10 * 12
246% \stopTEXpage
247
248% \getbuffer[game-2023]
249
250\stoptext
251