|
Post by tenochtitlanuk on Apr 19, 2022 14:28:44 GMT -5
Piet is an 'esoteric programming language'. Similar to a very basic FORTH, it is coded as a string of colour blocks called codels, and the intention is that the code should look like a work of art in the style of Piet Mondrian. I was looking for a fun coding project, so have got part way in. I'll add more as and when I have time. At present I have a colour chooser for 1D Piet code production. To interpret it I'll use the LIFO stack already on my site.
More dettails on my Piet website.
|
|
|
Post by Carl Gundel on Apr 19, 2022 18:43:36 GMT -5
Piet is an 'esoteric programming language'. Similar to a very basic FORTH, it is coded as a string of colour blocks called codels, and the intention is that the code should look like a work of art in the style of Piet Mondrian. What fun! Makes me think of porting it to my VIC-20. When I was a teenager I started work on a programmable calculator program in BASIC for the VIC-20 but I didn't make it work, so this inspires me.
|
|
|
Post by tenochtitlanuk on Apr 22, 2022 16:19:33 GMT -5
Got two programs running. One to write the colour sequence which is Piet code, and one to execute the sequence. Intention is to merge their functions. It's worth pointing out that for any one Piet codel colour sequence there will be 18 variations- all that has to be the same is the hue/darkness CHANGES. Not all commands are yet implemented, and I stick for now to 1D rather than 2D, so don't have to implement turning. For now, an animation of a Piet program to ask operator for a number and print its square!!
EDIT- sorry, when annotating the fourth screengrab stage I wrote 'dup' and meant 'multiply'...
|
|
|
Post by tenochtitlanuk on May 8, 2022 14:20:57 GMT -5
For my Piet machine I'm held up at present on counting the size of codels, ie colour blocks with connection to left or right or up or down. ( diagonal neighbours are NOT within the codel block) In the fragment below I've added manually the neighbour-count for each cell to show what is needed. I can read the colour of each square with getPixel, or from an array. Basically I want a routine that you can point at x, y and it will tell you the codel count, In the fragment shown most would return 1; two would return 2 for either square; and on would return 3 from any of its members. The blocks all in one colour can extend irregularly to the edge of the graphic box but no further. Should be straightforward surely to write an iterative/recursive search out from the x,y cell selected, but I've tied myself in a knot. Any offers??
|
|
|
Post by Brandon Parker on May 8, 2022 20:41:39 GMT -5
Have a look at my old FloodFill example for Rosetta Code. That might strike something in the gray matter with respect to the recursive action required.
{:0)
Brandon Parker
|
|
|
Post by tenochtitlanuk on May 9, 2022 2:27:27 GMT -5
I happily use both native LB recursive flood filling and MS's internal FloodFill- see lots of my entries on this forum and on my website. It was just the 'counting-as-I-find-them' that was blind-siding me. I work in Linux/Wine and pointed out a long time ago that the Rosetta Code LB solution failed for me. Still does. Me (14 Feb 2020 at 19:46) and Rod (15 Nov 2019 at 10:15) The flood fill rosetta code had a number of quirks for me. It also did not run on my PC The main culprit was setting the brush using backcolor instead of color. But it was also passing globals to subs and whats with floating point numbers describing screen width?
Doesn't seem to have been corrected..
Ho hum. Today's a chance for a fresh look!
|
|
|
Post by Rod on May 9, 2022 2:35:44 GMT -5
Optimisation will be important. No point in comparing n^n^n cells. You say four directions but I would say two. Run length encoding both vertical snd horizontal. So run across row one leaving behind the neighbour count. Then row two and eventually repeat for the columns. Build a duplicate array or a two dimension array holding colour and neighbour count.
Now what happens on cross over matching? A plus (+) cross over is 5? That needs caught for the cross over point, presumably we can just sum the found neighbour count with the crossing count? Hmmm….. what if there are more than one crossing lines, how does that sum out?
|
|
|
Post by tenochtitlanuk on May 9, 2022 3:52:47 GMT -5
That's almost exactly my thinking. I'm nearly there- after 10 minutes this morning with my mind clearer! It's rather fun- I love the ability to send a Piet-user a picture that actually runs as a program. And the same program can be represented in Piet in so many different ways! Mind you, the language written entirely in tabs, spaces and line-feeds beats it- you don't even realise you've received a message!
|
|
|
Post by tenochtitlanuk on May 11, 2022 7:06:42 GMT -5
Pogress report- the detection and sizing of 'codels' is working happily. Just the direction/turning controls to implement now. Web page up soon...
|
|
|
Post by tenochtitlanuk on May 26, 2022 6:42:54 GMT -5
I'm spending too much time on this, but it is addictive! I'm not helped that there are VERY few published programs, and several are actually incorrect- or interpret Piet slightly differently. Anyway, this screen shot shows a brute force way to print 'Hello World' in Piet. - I think nearly everything is near working correctly- entering Piet code and interpreting it. All looks pretty but is even closer than Forth to 'write impenetrable. read almost impossible.'
|
|
|
Post by tenochtitlanuk on May 29, 2022 14:59:51 GMT -5
So here is a Piet interpreter written in LB producing the output 'Hello World"! The ASCII values of the letters are inputted as blocks of colour.... Will update the webpage version soon.
|
|