Game grid KRF actions from lisp code.

Alright, let us do something with these types. Software-individuals have a lot of opinions, so do not take this devlog as implying always and only. I will also mostly belay lengthy philosophical apologies. But let us first make a <sequence <of sequences> <of < nil bird insect plant> s> slowly and deliberately. Then, software-individuals do not want themselves to be a graphical application, so I am imagining them producing basically an input to McCLIM like I just told our friend ACDW they could try.

Slowly building a rectangular grid

I am still eepitching like I started here. Lets see what we can do by hand in the manually-interacting part of my Pawn-75 software-individuals.

Setting session variables (of sequences)

ssv .line1 <nil nil nil nil nil>

Sandewall said that everyone starts by asking to be able to do this and it is just not that useful, but he included it for them anyway. Those are regular nils. Let’s start with a 10x10 grid and see what is happening.

Concatenating sequences

I guess his will work.

ssv .line10 (concat .line1 .line1)
ssv .lines2 <.line10 .line10 .line10 .line10 .line10>
ssv .lines10 (concat .lines2 .lines2)
ses.064) .lines10
  => 
<<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    nil    nil    nil    nil>
    <nil    nil    nil    nil    nil    nil    nil    nil    nil    nil>>

Well, I can’t say this was the most beautiful way to do things, but we certainly have a sequence of ten sequences of ten nils, made using software-individuals’ primitives.

Aside: str.concat and union

The analogous str.concat exists:

ses.074) ssv .z (str.concat "a" "b")

ses.075) .z
  => "ab"

ses.076) (str.concat .z .z)
  => "abab"

ses.077) (str.concat (str.concat .z .z) (string z))
  => "ababz"

ses.078) (str.concat (str.concat .z .z) (string .z))
  => "ababab"

and union for sets.

ses.065) (union {a b c} {c d e})
  => {a b c d e}

Some accessor idioms.

ses.083) (t1 <1 2 3>)
  => <2 3>

ses.084) (e1 <1 2 3>)
  => 1

ses.085) (e2 <1 2 3>)
  => 2

But this is not well suited right now. Let us just

leodef some lisp

put make-grid type lispdef
addmember (get board contents) make-grid
writefil board

Since the def is multiple lines, you invoke whatever editor. At the end we can now find this:

---------------------------------------------------------
-- make-grid

[: type lispdef]
[: latest-rearchived nil]

We can just add our leodef there. I can’t say I am stupendously happy with how I have figured out to do low level work, but I /do/ think the intent is that the nice logical notation was for interactive work, and that you do end up doing Norvigian low level pure lisp new functionalities.

---------------------------------------------------------
-- make-grid

[: type lispdef]
[: latest-rearchived nil]

(leodef tile-grid tile-grid (x y z)
	(setf
	 (get x 'tiles)
	 (let ((empty-row `(seq& ,(loop :repeat z :collect nil :into nils
					:finally (return nils)))))
	   `(seq& ,(loop :repeat y :collect (copy-tree empty-row))))))

Try the new def.

loadk board
tile-grid grid1 2 3

-.

ses.118) tile-grid grid1 2 3
<<nil
    nil>
    <nil
    nil>
    <nil
    nil>>

Well, we can make an empty grid. We should definitely be checking grid1 was or could be something that had tiles though. For now if I can just interoperate between my logic and lisp freely, I am content to begin with.

Actually, this seems like a moment to stop as well. We got to adding infterface commands and internal defuns with lisp to our KRF game.

Dramatic conclusion tomorrow!

See everyone