srowe wrote: ↑Thu Jul 08, 2021 1:10 am
Having to manipulate parameters on the stack forces you to modularize. ...You become accustom to designing words (functions)
I came accross this book called: Functional Programming in Javascript by Luis Atencio
The book is really about functional orientation perhaps more even than Javascript.
It really impressed me because the 'functional orientation' methodology is I believe the future of code in this here universe.
This is such a bold statement that I have to leave it there.... hanging.... pregnant.
srowe wrote: ↑Thu Jul 08, 2021 1:10 am
Perhaps you can suggest some optimizations?
I think the master blasters in this field are Michael and chysn.
Michael had one particular optimization that he suggested: "... the 'fine' counting algorithm is only thrown at bitmap bytes that might contain cells in the next generation, and not the whole bitmap."
My own version is currently a brute force slow coach.
I have one particularly nasty optimization that occurred to me that maaaay make your code fast I think.
You're may not like it. Turn your Forth machine (stack machine) into a LISP machine (pointer machine).
In other words, don't calculate anything. Do a pointer lookup with lookup tables.
Every cell is a 3 x 3 grid with the cell under investigation in the middle.
Combinatronics says the amount of combinations that exist is given by the number of variants to the power of the number of cells = k^n = 2 ^ 9 = 512 combinations, therefore with 512 results.
You can actually split it into two tables. Is the cell under investigation on or off to start with? Then just do a single byte lookup on one of the two tables (256 bytes each).
Table 1: Cell under investigation off
256 entries with each 8 bits representing the state of the remaining cells
Table 2: Cell under investigation on
256 entries with each 8 bits representing the state of the remaining cells
Each output lookup is a single byte which has one bit of information which says: For this particular combination on this (input cell on or off) table, the cell under investigation is on or off as a result.
Well that's all I got.
Greetings
p.s I've edited this post about six times. I'm leaving it alone now.