NB: Mostly here we start NicCLIM, make a map, add some symbols, change those symbols to render images, and we get a glimpse of a lambda.
…And a note about McCarthy’s LISP. I have said that McCarthy considered LISP might be programmed in pictures. DM let me know he had not heard such a thing. mdhughes had a good Brian Harvey reference viz lisp, scheme, logo and pictures, but what I was talking about was the last section of Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I in which McCarthy points out that while one would prefer to write lisp atoms (being the IBM-704’s 47 characters formed into English-ish words) basically in preference to other contenders that present themselves, such as conventional logic notation or Church notation, a lisp program by its nature defines a set of machine state transitions that would be universally written as a many-branching and recursive flowchart, with one initial entry port and one final exit port. But McCarthy also presented a simple scheme by which universal flowcharts could in turn be themselves understood as lisp programs. I understand this basically RTL programming as being like programming with a flowchart of pictures in contrast to lists of English-like normalized string atoms.
I am declaring my NicCLIM in alpha. I added everything to it I think is needed and goes together to create a complete Map Editor system. I will follow this up with a documentation article later, but here I just want to make a game of life. I came to a decision to use hextille instead of a rectilinear (i.e. square) grid. Hextille was Conway’s term for a regular hexagonal grid, which is one of the regular 2D grids. It has the special property that all six near neighbors are the same distance, unlike a rectangular grid where diagonals are slightly further away than orthogonals. According to Wikipedia there is a straightforward Hextille game of life I will use here.
Note that I am writing this while I am writing this, nothing (except NicCLIM) was prepared earlier.
• (setq inferior-lisp-program "ecl")
• (setq eepitch-buffer-name "*slime-repl ECL*")
• (slime)
(ql:quickload :mcclim)
(string '~/game)
(ensure-directories-exist *)
(uiop:chdir **)
(uiop:chdir ***) ; I have to do this twice for some reason.
(compile-file "~/Downloads/nicclim.lisp" :load t)
;; :load t is an ECL extension. You do you.
(in-package :nicclim)
'(empty)
'gol
(rect-file * 10 8 **)
'gol
(enclose-map *)
Admittedly, I’m using a regular matrix to display my hex in a bumpy looking way, but I think each cell’s 6 neighbors can be readily identified.
./IMGS/EMPTY.PNG
(setf (get 'empty :bitmap) 'imgs/empty.png)
note I just used my [Open that](Open that.) again.
I will place one tile with the CLIM interactor, then one programmatically, then a third one using keyboard shortcuts in a GIF.
Okay, on exceedingly slow computers, McCLIM gets tired of waiting and signals a simple-error like that. You probably will not experience it. ABORT
(return to command loop) is fine. We can use a handler-case
to automatically handle it- it is signalling a real problem, that it can not believe how slow my machine is. But not right now.
(list '(com-kl) '(com-kl)
'(com-set-cur1 life) '(com-push-cur1))
kl
is ne
as we will see. k
is nw
.
We have to start the frame in order to do this:
(bt:make-thread
(lambda ()
(enclose-map 'gol)))
and
(dolist (l *) (execute-frame-command *nic* l) (sleep 1))
In the foreground:
LIFE
(setf (get 'life :bitmap) 'imgs/life.png)
(empty-pattern-cache)
I had to empty the pattern cache when I changed the LIFE to be more noticeable.
Alright, this was fun but I am getting tired.
Lambdas work relatively well in NicCLIM.
(lambda (x)
(loop :for dir :in '(nw ne w e sw se)
:for cell := (adjacent-peek dir)
:when (member 'life cell) :sum '1))
We just put the lambda somewhere like anything else.
Alright, I am calling it here as I became tired.
We saw that McCarthy originally noted that universal recursive flowcharts could be read as lisp programs, and I am loosely equating my NicCLIM alpha with a flowchart.
The trivial feature of symbols having a :bitmap
property rendering as ordered images with transparency was seen, and we briefly saw a lambda
in a NicCLIM cell, though we did not investigate using it yet.
See you on the Mastodon as always. Also tonight I am mainly going to read McCarthy’s original list of things LISP was constructed to be good at, all those decades ago.
screwlisp proposes kittens