Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Steel Wool
#1
I came across an old 2D burning forest simulation. Figured, due to the change in the environmental outlook over the years, that I would change it to Steel Wool... it reminded me of a time when I shoved a 9 volt battery into a ball of steel wool (brillo pad)... A completely useless piece of code... Spent mere minutes converting it... lol

   


.n7   steelwool.n7 (Size: 1.32 KB / Downloads: 8)
Logic is the beginning of wisdom.
Reply
#2
Good code and great effect.
Reply
#3
Thank you. I had a little spare time and an even rarer moment of creativity... lol

The original listing used a 150x150 pixel display... Not much bigger than a postage stamp... Don't know about you, but 'my' eyesight almost struggles, when its that small... lol
Logic is the beginning of wisdom.
Reply
#4
(12-05-2024, 09:31 AM)johnno56 Wrote: I came across an old 2D burning forest simulation. Figured, due to the change in the environmental outlook over the years, that I would change it to Steel Wool... it reminded me of a time when I shoved a 9 volt battery into a ball of steel wool (brillo pad)... A completely useless piece of code... Spent mere minutes converting it... lol

In 1970s, Conway was known as a British mathematician who described cellular automation.
Did you use similar algorithm of "Conway's Game of Life" for the steel wool ?
Reply
#5
No sir. Conway uses "Cellular Automation". The "life" of two or three "cells" is based on 4 basic rules. Those rules will determine the life or death of the cells. Steel Wool uses a simple random method. If the cell is grey, burn it (yellow/orange) then make it black. If black make it grey... and round and round it goes. With Conway, there was always a concept of "total" death of all cells...

Conway's rules: 1. Any live cell with fewer than two live neighbours dies, as if by under population. 2. Any live cell with two or three live neighbours lives on to the next generation. 3. Any live cell with more than three live neighbours dies, as if by overpopulation. 4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
Logic is the beginning of wisdom.
Reply
#6
(12-06-2024, 03:31 AM)johnno56 Wrote: No sir. Conway uses "Cellular Automation". The "life" of two or three "cells" is based on 4 basic rules. Those rules will determine the life or death of the cells. Steel Wool uses a simple random method. If the cell is grey, burn it (yellow/orange) then make it black. If black make it grey... and round and round it goes. With Conway, there was always a concept of "total" death of all cells...
Conway's rules: 1. Any live cell with fewer than two live neighbours dies, as if by under population. 2. Any live cell with two or three live neighbours lives on to the next generation. 3. Any live cell with more than three live neighbours dies, as if by overpopulation. 4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

My first contact with the game of life and cellular automation was in Bernardo Kastrup's book Dreamed up Reality (philosophy) some years ago. Funny that I never bumped into it earlier.
Reply
#7
Add  interactivity
     UP/DOWN to zoom in/out  
     F to set fire
     Try to hold F longer or shorter
     Watch how black turn to grey when F is not pressed

Code:
'=========================================
' Control Keys
' - UP / DOWN : zoom in/out
' - F         : try to press long enough
' - ESC       : quit
'
' Logs :
' -2D burning forest simulation
' -Steel Wool in N7 by Johnno
' -Some modification in N7 by Micha
'==========================================


'----------------
' INITIALIZATION
'----------------
#win32
set window "Steel Wool", 500, 300, false,2
set redraw off
randomize clock()

'color definition
white = [255,255,255]
black = [0,0,0]
grey  = [64,64,64]

'cells of array
f1 = dim(width()/3, height()/3)
f2 = dim(width()/3, height()/3)

'variables
s = 1            'scale
pressF = "false" 'keypress F


'-----------
' MAIN LOOP
'-----------
do
    'color
    fire = [255, 128 + rnd(128), 0]

    'clear screen
    set color black;cls
   
    'interactivity
    if keydown(KEY_UP,true) then s = min(s + 1,20)
    if keydown(KEY_DOWN,true) then s = max(s - 1,1)
   
    'color changing      
    for x = 0 to width()/3-2
        for y = 0 to height()/3-2
       
            'less than 3% black turn to grey
            if not f1[x][y] and rnd(1000)/1000 < 0.03 then
                f2[x][y] = 1
            endif
           
            'fire turn to black
            if f1[x][y] = 2 then
                f2[x][y] = 0
            endif
           
            'selected grey turn to fire
            if f1[x][y] = 1 and keydown(KEY_F) then
                pressF = "true"
                if (f1[x - 1][y - 1] = 2 or f1[x][y - 1] = 2 or f1[x + 1][y - 1] = 2) or  
                   (f1[x - 1][y] = 2 or f1[x + 1][y] = 2 or f2[x][y]=2  or rnd(10000)/10000 < 0.00003) or     
                   (f1[x - 1][y + 1] = 2 or f1[x][y + 1] = 2 or f1[x + 1][y + 1] = 2) then  
                        f2[x][y] = 2
                endif
            else
                pressF = "false"
            endif

            'set the fire now !!!
            if f2[x][y] = 0     set color black
            if f2[x][y] = 1     set color grey
            if f2[x][y] = 2     set color fire
            draw rect (x-1)*s , (y-1)*s , s, s, false
   
        next
    next
   
    for x = 1 to width()/3-2
        for y = 1 to height()/3-2
            f1[x][y] = f2[x][y]
        next
    next

    'info box
    set color white
    set caret 10,10
    wln "Scale :"+s
    wln "F     :"+pressF
    set caret 10,height()-80
    wln "UP/DOWN to zoom in/out" 
    wln "F to set fire"
    wln "Try to hold F longer or shorter"
    wln "watch how black turn to grey when F is not pressed"
      
    redraw
    fwait 15
until keydown(KEY_ESCAPE, true)
Reply
#8
Cool... Nice variation! Wink
Logic is the beginning of wisdom.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)