Sierpiński triangle

2015-07-18, post № 47

mathematics, programming, Pygame, Python, #3, #3-gon, #around the center, #black, #black and white, #fractal, #generates, #generating, #generator, #three, #triangle, #white

Having recently heard something about chaos theory, I was interested in the Sierpiński triangle. Specifically in the random generation. To prove that it can really be generated using a die, I wrote this program.

How it works

• You start with any point inside the triangle (I chose the center).
• A triangle has three points, let us call them 𝐴, 𝐵 and 𝐶.
• You choose randomly between one of those three points, go half the distance and set a pixel right there.
• Repeating this process over and over again (always starting at your last point), you eventually [1] get the Sierpiński triangle.

Controls

• ‘Space’ toggles if the triangle is generated,
• ‘m’ toggles if the current position is shown (indicated by a blue circle).
Source code: sierpinski-triangle.py

Jic-Jac-Joe

2015-07-12, post № 46

games, programming, Pygame, Python, #AI, #algorithm, #blue, #com, #computer, #pixel, #pixel graphics, #tac, #tic, #tic-tac-toe, #tictactoe, #toe, #TTT

As the name suggests, this is a computer version of the well-known game Tic-Tac-Toe. This version supports a computer player, but it is not the smartest algorithm and can lose. In this setup, the computer plays ‘O’ and starts, the player plays ‘X’.
Win detection is fully implemented.

Controls

• The 𝟥 ⨉ 𝟥-field is projected on the numpad, so `7` sets your piece in the upper left corner and `3` puts it in the lower right corner.
• Escape resets the game.
Source code: jic-jac-joe.py

JClock III

2015-07-11, post № 45

programming, Pygame, Python, #7, #7-segment, #7 segments, #black, #clock, #current time, #green, #green and black, #numerals, #pixel, #pixels, #seven, #time

Inspired by a 7-segment clock I previously made a 7-segment font (used in Jong). I thought of an idea to make this simple way of displaying our ten numerals more interesting. I came up with this clock.
It uses a number of pixels, which get every second a new destination to the position that would form needed numeral. Because they always try to move to their destination — needing time to get there —, a reordering-effect occurs.

Source code: jclock-iii.py
Jonathan Frech's blog; built 2021/04/16 20:21:20 CEST