From b36c972b1b8ecb6916e2bc5cf0c016b750a9a78d Mon Sep 17 00:00:00 2001 From: Alexandre B A Villares <3694604+villares@users.noreply.github.com> Date: Mon, 28 Oct 2024 01:01:08 -0300 Subject: [PATCH] 27 --- 2024/sketch_2024_10_27/free.png | Bin 0 -> 10735 bytes 2024/sketch_2024_10_27/polyomino.py | 108 +++++++++++++++++++ 2024/sketch_2024_10_27/sketch_2024_10_27.png | Bin 0 -> 16558 bytes 2024/sketch_2024_10_27/sketch_2024_10_27.py | 54 ++++++++++ docs/README.md | 10 ++ 5 files changed, 172 insertions(+) create mode 100644 2024/sketch_2024_10_27/free.png create mode 100644 2024/sketch_2024_10_27/polyomino.py create mode 100644 2024/sketch_2024_10_27/sketch_2024_10_27.png create mode 100644 2024/sketch_2024_10_27/sketch_2024_10_27.py diff --git a/2024/sketch_2024_10_27/free.png b/2024/sketch_2024_10_27/free.png new file mode 100644 index 0000000000000000000000000000000000000000..33e9a31892090b5a64f7ebfcb7e3dcd1add376fc GIT binary patch literal 10735 zcmeHsXH-*Z*EXY$gMtNAkTB|mCLN6gFrYX=A|L?`1f+x@MLI|aA)wMmF$#nth#)15 zCJ-b*kN}Co80km}p`#)aKzi@r0iEYr&mUat``-8Y^G$waopnw)?0et$wXbVm``#6U zOZ)bM_VV!X?9MIYA3{Cgq@5TYCW4-6@9#RMWd_{|O zODFZ^9vh*LkAFV6AofS+u6u{twP3M-veN^FSc}H?;cf6VBIDh(NK!$OR{+uBi;tx&jo=vW^7QgVI*&I{S%U> z3a%m-!MUx#z6QNHavQ@2CC?!85P#&vdYRzUI$fznZl>dtJ!;8O!N0YcAB!|USKJ^< za1Q5o;UbC% zvcXOP0pWIMJvn5txylX@l@EnxUlP8@xNog>E+UPO~(esS*tB{4&RkOR~~;4J&a2B zx7J)--6*D`OPJj zk#e@LBO5cpZ(K0+N{s_r1^CifC9(hvm8dOtpb1~-C=ln&o=5H1I%}Ap9qspXeqJ0T zhYJifW)>ce^e0U|adGXub0rP(csa6V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d-PwOUj zw_CFI)Y$5paSt>#odutjx##dmAv?M-_X8|V$eS@=Dea~%-TZ4uZ(3rIu@t( z42FZ^6a}7tWzdCsVveYUN1VUHwE~{M?oMO;0Gz-enC;U$-OaFmtoqyM5T8XQuOn7> z1^|y~Ex!aiei>Z&d<~KLKyh#AW!SzAqLT`r*>$aJ+(Y*Avj{x^&#I%_N&NpiAb&8Q zP+9BN+ybtuyrZ;3N&i>~KT~s}iR1~m&K#!SyNRkMC13&?y5`0NEa+8SD>I|b83Wb( z9r-XSL&$K{N^e+{2&%KH9dx#%vCQ(|q~N2tKtE>7?&tAS|2`52|K|__$bFJ{ zSYpHuw$~F&;giMsPV@F}0n%Oa0Mo7XZnzkWfPFXD^{8sw>UFXNfj^Qjeqp#dUPpEF z_rJw$f9l77g(B{P&0K-S`kjc}_*k-4HhFjlw@dKtLsxA*-fyXp5z^Mg@8+@XN%Id- zP*}*X>FJsiD8R~GFg4k47J)i46oX5E@M(}+j+_6PyYG*lYxIS@J|N*$-qAu f`2R8k>kS(`2;q#3;Y1tJ%>?Lb8(gHot?&LHtj#32 literal 0 HcmV?d00001 diff --git a/2024/sketch_2024_10_27/polyomino.py b/2024/sketch_2024_10_27/polyomino.py new file mode 100644 index 00000000..178dbfc6 --- /dev/null +++ b/2024/sketch_2024_10_27/polyomino.py @@ -0,0 +1,108 @@ +""" +Based on a talk by Hamish Campbell +https://pyvideo.org/kiwi-pycon-2013/polyominoes-an-exploration-in-problem-solving-w.html +""" + +from collections import namedtuple + +import py5 + +Square = namedtuple('Square', 'x y') + +class Polyomino(object): + + REMOVE_MIRRORED = False + + def __init__(self, iterable): + self.squares = tuple([Square(*s) for s in sorted(iterable)]) + + def __repr__(self): + return f'{self.__class__.__name__}({repr(self.squares)})' + + def __iter__(self): + return iter(self.squares) + + def __len__(self): + return len(self.squares) + + def __eq__(self, other): + return hash(self) == hash(other) + + def __lt__(self, other): + return self.squares < other.squares + + def __hash__(self): + """ + Determine the hash (an integer "key/id" number) + it is the smaller number (hash) of the square tuples + of itself and its 3 rotated siblings + """ + p = self.translate() + h = hash(p.squares) + for _ in range(3): + p = p.rotate().translate() + h = min(h, hash(p.squares)) + if self.REMOVE_MIRRORED: + f = self.flip().translate() + h = min(h, hash(f.squares)) + for _ in range(3): + f = f.rotate().translate() + h = min(h, hash(f.squares)) + return h + + def rotate(self): + """Return a Polyomino rotated clockwise""" + return Polyomino((-y, x) for x, y in self) + + def flip(self): + """Return a Shape flipped""" + return Polyomino((-x, y) for x, y in self) + + + def translate(self): + """Return a Polyomino Translated to 0,0""" + minX = min(s.x for s in self) + minY = min(s.y for s in self) + return Polyomino((x - minX, y - minY) for x, y in self) + + def raise_order(self): + """Return a list of higher order Polyonominos evolved from self""" + polyominoes = [] + for s in self: + adjacents = (adjacent for adjacent in ( + (s.x + 1, s.y), + (s.x - 1, s.y), + (s.x, s.y + 1), + (s.x, s.y - 1), + ) if adjacent not in self) + for adjacent in adjacents: + polyominoes.append( + Polyomino(list(self) + [adjacent]) + ) + return polyominoes + +# def render(self): +# """ +# Returns a string map representation of the Polyomino +# """ +# p = self.translate() +# order = len(p) +# return ''.join( +# ['\n{}'.format(''.join(["X" if (x, y) in p.squares else "-" +# for x in range(order)])) +# for y in range(order)] +# ) + + def draw(self, w, c=False): + """ + draw + """ + p = self.translate() + #order = len(p) + with py5.push_matrix(): + py5.color_mode(py5.HSB) + for i, (x, y) in enumerate(p.squares): + if c: + py5.fill(i * 24, 255, 200) + py5.rect(x * w, y *w, w, w) + diff --git a/2024/sketch_2024_10_27/sketch_2024_10_27.png b/2024/sketch_2024_10_27/sketch_2024_10_27.png new file mode 100644 index 0000000000000000000000000000000000000000..8c36065b4a9b8199716e4009e55a866083a9d806 GIT binary patch literal 16558 zcmd6OXH=7EyES741s$qD1P8@PK%_{K>PQnJ0SScA0t!S45D+Ak(43JXO%MV~5k?>& zEfghaXgV=e6(NQI5fJHw-aFre&b()x^?gfco%Nn~ef-D@S@7h}oqJ!`zV_Zv)K!zq zJc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;6y#?l7-3wm--ypl!ib6d$ciMnE#}-1j zwKqrQR8xi+C$s@0VEn7yvTZ%Hfm`M6zYo-)Mh8|19cDThLOM1`pIwR{)RzU?kud?J z3`7@bql3jjT1bgh?O+NRqKkwW^4vP6*mXB*6T(w)A5;Vgy3Ae+NR?7@Z(dY0Hj@2L zi-@_3QXvD?nVsCh)N|;U(hU{`{w^ChBb5o==F1>e4;h0ue;nfYF!s;7ndki@U9y8R zlFoyfmkzDSG*s9Tj20UUUG8BYT%w6N6_bR36izkK)fnFra{Uf_se+D#_*y*3bwt`gnF2ZDcxhxPM>|4NhZ87bG8)c_d#%KP=HMSIF?;gNTD195vrhd0z<3GIQFOn5Rz}{W|go z5Bs~c0X1XL90~axnz(y~$#>sBw%H9<`uF(x$%9X}REJc8Q&@W97=Iu!*Z2L2 z7VH{}7`nha%}(%Mg0&#xO?6LiUgaA4y7nKxGsnHTZw7nm@!7zRS>R@}+V3*W|4~!< ffB(}R+pUZC3wliS8Q;^pe_^C=qDRuX_WS<<3rt)~ literal 0 HcmV?d00001 diff --git a/2024/sketch_2024_10_27/sketch_2024_10_27.py b/2024/sketch_2024_10_27/sketch_2024_10_27.py new file mode 100644 index 00000000..a92d01d3 --- /dev/null +++ b/2024/sketch_2024_10_27/sketch_2024_10_27.py @@ -0,0 +1,54 @@ +from collections import Counter + +import py5 # check out https://py5coding.org + +from polyomino import Polyomino # Based on a talk by Hamish Campbell + +M = 20 # margin +w = 5 # component square size + + +def setup(): + py5.size(1850, 750) + py5.background(0) + # Polyomino.REMOVE_MIRRORED = True # generates 369 free octominoes + polyominoes = get_polyominoes(8, up_to=False) # 704 one-sided octominoes + print(len(polyominoes)) + + x, y = M, M + for i, p in enumerate(sorted(polyominoes, key=long), 1): + with py5.push_matrix(): + py5.translate(x, y) + p.draw(w, c=True) + x += len(p) * w + w + if x > py5.width - w * len(p): + x = M + y += len(p) * w + if y > py5.height: + print(f'{i} of {len(polyominoes)}') + break + + py5.save_frame('a.png') + +def long(p): + xs, ys = zip(*p.squares) + return max(max(xs) - min(xs), max(ys) - min(ys)) + +def get_polyominoes(target, up_to=False): + order = 1 + polyominoes = set([Polyomino(((0,0),))]) + all_p = set([]) + while order < target: + order += 1 + next_order_polyominoes = set() + for polyomino in polyominoes: + next_order_polyominoes.update(polyomino.raise_order()) + polyominoes = next_order_polyominoes + all_p.update(next_order_polyominoes) + if up_to: + return all_p + return polyominoes + + +py5.run_sketch() + \ No newline at end of file diff --git a/docs/README.md b/docs/README.md index ded7d337..af0c34b8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -30,6 +30,16 @@ Here are listed some of the tools I have been using more recently: 2024 \| [2023](2023.md) \| [2022](2022.md) \| [2021](2021.md) \| [2020](2020.md) \| [2019](2019.md) \| [2018](2018.md) +--- + +### sketch_2024_10_27 + +![sketch_2024_10_27](https://raw.githubusercontent.com/villares/sketch-a-day/main/2024/sketch_2024_10_27/sketch_2024_10_27.png) + +[sketch_2024_10_27](https://github.com/villares/sketch-a-day/tree/main/2024/sketch_2024_10_27) [[py5](https://py5coding.org/)] + +704 one-sided octominoes, using code inspired by a great talk by Hamish Campbell https://pyvideo.org/kiwi-pycon-2013/polyominoes-an-exploration-in-problem-solving-w.html + --- ### sketch_2024_10_26