screwlisp proposes kittens

NicCLIM Example of making an HTML table for this site

๐Ÿฆ‰
๐Ÿ‹๐ŸŒฝ๐Ÿ•Š๐ŸŒฟ๐Ÿฌ๐ŸŒฑ๐Ÿฅฆ๐Ÿชต
๐Ÿ๐Ÿฆข๐Ÿฆข๐Ÿฆญ๐Ÿ›๐Ÿ›๐Ÿˆ๐Ÿชท๐ŸŒฒ๐Ÿ‘
๐ŸŒท๐Ÿฆ€๐Ÿซ๐Ÿฆƒ๐Ÿฅฅ๐Ÿฆข๐Ÿชฐ๐Ÿก๐Ÿฅ๐Ÿฅœ
๐ŸŒน๐Ÿ๐Ÿชณ๐ŸŒพ๐Ÿฆญ๐Ÿฃ๐ŸŒณ
๐Ÿฆƒ๐Ÿ‹๐Ÿฅฆ๐ŸŒฑ๐Ÿฆ€๐Ÿชฑ๐Ÿ•ธ๐Ÿชณ๐Ÿ™๐Ÿซ๐Ÿ’
๐Ÿš๐Ÿƒ๐ŸŽ„๐Ÿƒ๐Ÿ•Š๐Ÿ•ท๐ŸŒฑ๐ŸŒป๐Ÿ€๐Ÿฅ’
๐Ÿงš๐Ÿ‹๐Ÿ‹๐Ÿฃ๐Ÿ™

Let us begin taking NicCLIM more practically. And make a life-filled ASCII table element for this siteโ€™s banner. This also moves towards a general theory of automata for our NicCLIM spacetime-box tiles.

I guess https://lispy-gopher-show.itch.io/nicclim links us to https://screwlisp.small-web.org/lispgames/trying-nicclim-v2/ for advice on what to do. Iโ€™ll eww into that in emacs. By the way, eww + Eduardoโ€™s eev-mode is great- navigate a site, tap f8 on the ee-bullet lines I wasa looking forโ€ฆ

Setup

On that webpage, I tapped f8 on

โ€ข (setq inferior-lisp-program "ecl")
โ€ข (slime)
โ€ข (setq eepitch-buffer-name "*slime-repl ECL*")

(ensure-directories-exist #p"~/GAME/")

(uiop:chdir "~/GAME/")
(uiop:chdir "~/GAME/")

;; I guess I forgot the critical lines!
(ql:quickload :mcclim)
(compile-file "~/Downloads/nicclim.lisp" :load t)
;; Which we downloaded from my first link, and
(in-package :nicclim)

since I guess this is my conventional working directory, and the lisp imageโ€™s purpose is to be running NicCLIM.

Creating a map inside a spacetime-box

Remembering that we are borrowing spacetime from Olum for our distributed game spacetime volumes and time evolution.

Making one 2D layer

(rect-file "NATURE" 16 8 ())

Put that into a spacetime-box

(defparameter *box* (make-instance 'spacetime-box))

(with-slots
      (dims times.contentses insward-facets)
    *box*
  (setf dims '(16 8 1)
	times.contentses '((0 nature))
	inward-facets
	`((
	   ((0 15) (0 7) (0 0))
	   (0 0 0)
	   ,*box*)
	  ))
  )	

that seems like it calls for a lot of polish, but I have not decided what that polish would be like yet. Hence just directly exposing the spacetime-box instanceโ€™s slots. It seems like a spacetime box could be created solely with a list of layers that would be inside it, or even a formula for creating new layers to put inside it. Not the topic right now though.

Open the nature layer for editing with NicCLIM

(enclose-map "NATURE")

this is a great starting point and all, but let us switch to

Programmatically populating nature with unicode

My own unicode character collection from before

(defvar *some-characters* "๐Ÿชด๐ŸŒณ๐ŸŽ„๐ŸŒฒ๐ŸŒดโธ™๐Ÿƒ๐Ÿฅฌ๐Ÿฅ•๐Ÿฅฆ๐Ÿ๐Ÿ€๐Ÿ‚๐Ÿ‰๐Ÿ๐ŸŽ๐Ÿ๐ŸŒต๐ŸŒฟ๐Ÿฅ—๐Ÿฅ’๐Ÿฅ”๐Ÿˆ๐ŸŒ๐ŸŽ‹๐Ÿ„๐Ÿชต๐Ÿฅ๐Ÿซ๐Ÿซ’๐Ÿ ๐Ÿ“๐Ÿฅฅ๐Ÿ‹๐Ÿ‡๐Ÿฅœ๐Ÿชท๐Ÿ‘๐Ÿ๐ŸŽƒ๐Ÿฅ’๐ŸŒพ๐ŸŒฝ๐ŸŒนโš˜๐Ÿ’ฎ๐Ÿ’๐ŸŽ•๐Ÿฅ€๐Ÿถ๐Ÿต๐ŸŒฑ๐ŸŒป๐ŸŒท๐Ÿซ˜๐Ÿ›๐Ÿชฑ๐Ÿฆ‹๐Ÿชฒ๐Ÿ๐Ÿชฐ๐Ÿž๐Ÿœ๐ŸฆŸ๐Ÿ•ท๐Ÿฆ€๐Ÿฆž๐Ÿชณ๐ŸŒ๐Ÿš๐Ÿฆ‚๐Ÿ•ธ๐Ÿฆ๐Ÿงš๐Ÿฅ๐Ÿฆ๐Ÿฆ…๐Ÿ”๐Ÿ“๐Ÿฆ†๐Ÿฆข๐Ÿค๐Ÿฃ๐Ÿฆƒ๐Ÿ•Š๐Ÿง๐Ÿฆ‰๐Ÿฆซ๐Ÿฆฉ๐Ÿฆš๐Ÿฆค๐Ÿก๐ŸŸโ—‰๐Ÿฅ๐ŸŽฃ๐Ÿ ๐Ÿฆˆ๐Ÿฆซ๐Ÿ‰โฅฟ๐Ÿ™๐Ÿฆ‘๐Ÿš๐Ÿฆญ๐Ÿ‹๐Ÿฌ๐Ÿชธ๐Ÿฆ€")

Start the app in the background

(require :bordeaux-threads)
(bt:make-thread
   (lambda () (enclose-map "NATURE")))

A random walk loop to place clusters of animals.

(loop
  :with n-clusters := (random #o30)
  :with current-n := 0
  :with x := 0
  :with y := 0
  :with (xlim ylim zlim) := (slot-value *box* 'dims)
  :while (< current-n n-clusters) :do
    (loop
      :with d := 5
      :with -d/2 := (-(truncate 5 2))
      :with no-chars := (length *some-characters*)
      :for sym := (make-symbol
		   (let ((idx (random no-chars)))
		     (subseq *some-characters*
			     idx (1+ idx))))
      :for m := 0
      :for dx := (+ -d/2 (random d))
      :for dy := (+ -d/2 (random d))
      :for new-x := (+ x dx)
      :for new-y := (+ y dy)
      :when (and (< 0  new-x xlim)
		 (< 0 new-y ylim))
	:do (multiple-value-setq
		(x y)
	      (values new-x new-y))
	    (incf m)
	    (block insert-symbol
	      (loop
		:for cmd :in `((set-cur1 ,sym)
			       (jump ,new-x ,new-y)
			       (push-cur1))
		:do
		   (execute-frame-command
		    *nic* ; from enclose-map
		    cmd)
		   (sleep 1)))
      :while (< m current-n)
      :finally (incf current-n)))
  

The gif is quite boring, because McCLIM focuses on frequently used, language unicode symbols and doesnโ€™t render almost all of these emojis.

Stopping that interactively!

What I did, when I realised that it was going to be a while before it stopped on its own was C-c C-c in my emacs repl, followed by:

(bt:all-threads)
;; the new application-frame thread was the first thread
(bt:destroy-thread (first *))
ABORT

and then

(execute-frame-command *nic* '(com-writef nature))

to salvage the situation.

State of the layer now

Literally, NATURE is now

NIC> (execute-frame-command *nic* '(log-map))
(#:๐Ÿฆ‰)	NIL	NIL	NIL	NIL	NIL	NIL	NIL	NIL	NIL	NIL	NIL	NIL	NIL	NIL	NIL
NIL	NIL	(#:๐Ÿ‹ #:๐ŸŒฝ #:๐Ÿ•Š #:๐ŸŒฟ)	(#:๐Ÿฌ #:๐ŸŒฑ)	NIL	NIL	NIL	NIL	NIL	NIL	NIL	NIL	(#:๐Ÿฅฆ)	NIL	NIL	(#:๐Ÿชต)
NIL	(#:๐Ÿ)	(#:๐Ÿฆข #:๐Ÿฆข #:๐Ÿฆญ)	(#:๐Ÿ› #:๐Ÿ›)	NIL	NIL	NIL	NIL	NIL	NIL	NIL	NIL	NIL	(#:๐Ÿˆ)	(#:๐Ÿชท
                                                                             #:๐ŸŒฒ)	(#:๐Ÿ‘)
NIL	NIL	(#:๐ŸŒท)	(#:๐Ÿฆ€)	NIL	NIL	NIL	NIL	NIL	NIL	(#:๐Ÿซ)	(#:๐Ÿฆƒ)	(#:๐Ÿฅฅ #:๐Ÿฆข)	(#:๐Ÿชฐ)	(#:๐Ÿก
                                                                         #:๐Ÿฅ)	(#:๐Ÿฅœ)
NIL	(#:๐ŸŒน)	NIL	(#:๐Ÿ)	(#:๐Ÿชณ)	(#:๐ŸŒพ)	(#:๐Ÿฆญ)	NIL	NIL	NIL	NIL	NIL	(#:๐Ÿฃ)	(#:๐ŸŒณ)	NIL	NIL
NIL	NIL	(#:๐Ÿฆƒ)	(#:๐Ÿ‹)	(#:๐Ÿฅฆ #:๐ŸŒฑ #:๐Ÿฆ€ #:๐Ÿชฑ)	NIL	NIL	NIL	(#:๐Ÿ•ธ)	(#:๐Ÿชณ)	(#:๐Ÿ™ #:๐Ÿซ)	NIL	NIL	NIL	(#:๐Ÿ’)	NIL
NIL	NIL	NIL	NIL	NIL	NIL	NIL	NIL	(#:๐Ÿš #:๐Ÿƒ)	(#:๐ŸŽ„)	NIL	NIL	(#:๐Ÿƒ #:๐Ÿ•Š #:๐Ÿ•ท #:๐ŸŒฑ)	(#:๐ŸŒป
                                                                           #:๐Ÿ€)	(#:๐Ÿฅ’)	NIL
NIL	NIL	NIL	(#:๐Ÿงš)	(#:๐Ÿ‹)	NIL	(#:๐Ÿ‹)	NIL	NIL	NIL	NIL	NIL	NIL	(#:๐Ÿฃ #:๐Ÿ™)	NIL	NIL

Which I guess we would like to turn into

an html table.

(slot-value *nic* 'table-list)
(loop
  :initially (princ "<table>")
  :repeat (length *)
  :for row :in * :do
    (fresh-line)
    (loop
      :initially (princ " <tr>") :do
	(loop :for cell :in row :do
	  (princ "<td>")
	  (mapc 'princ cell)
	  (princ "</td>"))
	(loop-finish)
      :finally (princ "</tr>"))
  :finally (terpri) (princ "</table>"))
		    

Soo

๐Ÿฆ‰
๐Ÿ‹๐ŸŒฝ๐Ÿ•Š๐ŸŒฟ๐Ÿฌ๐ŸŒฑ๐Ÿฅฆ๐Ÿชต
๐Ÿ๐Ÿฆข๐Ÿฆข๐Ÿฆญ๐Ÿ›๐Ÿ›๐Ÿˆ๐Ÿชท๐ŸŒฒ๐Ÿ‘
๐ŸŒท๐Ÿฆ€๐Ÿซ๐Ÿฆƒ๐Ÿฅฅ๐Ÿฆข๐Ÿชฐ๐Ÿก๐Ÿฅ๐Ÿฅœ
๐ŸŒน๐Ÿ๐Ÿชณ๐ŸŒพ๐Ÿฆญ๐Ÿฃ๐ŸŒณ
๐Ÿฆƒ๐Ÿ‹๐Ÿฅฆ๐ŸŒฑ๐Ÿฆ€๐Ÿชฑ๐Ÿ•ธ๐Ÿชณ๐Ÿ™๐Ÿซ๐Ÿ’
๐Ÿš๐Ÿƒ๐ŸŽ„๐Ÿƒ๐Ÿ•Š๐Ÿ•ท๐ŸŒฑ๐ŸŒป๐Ÿ€๐Ÿฅ’
๐Ÿงš๐Ÿ‹๐Ÿ‹๐Ÿฃ๐Ÿ™

Conclusions

That was pretty great. I should keep making those latin squares from before as well.

Fin.

See you on the Mastodon thread please.

Share where and how occurs to you and as you like.

screwlisp proposes kittens