Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+1)

Hi! Thanks again for your help! I got it working: https://oofoe.itch.io/puz15
(password "puz15" -- I just don't want it showing up on my profile yet because not finished.)

Another question, if you're willing... I'm trying to use the array language capabilities to figure out if there's an opening to move a tile into by vector adding to get the orthogonal neighbours:

np:2 window (p,p,p,p)+(1,0,0,1,-1,0,0,-1)

Then I get the contents of my tracking map (canvas that I write the actual tile positions into) at those positions to determine if one of the neighbouring spaces is empty (=0):

0=map@np  # Yields something like (0,1,0,0)

I know that a lot of array languages have some kind of operator to filter one array by a boolean other, so I could apply the result of the 0=map@np to np and arrive at just the coordinates of the empty space (or nil, if no empty space in neighbours). Currently, I'm grovelling through with an each loop -- is there a way to one-shot the operation like that?

Thanks!

In K, you'd solve this kind of problem with the "where" (&) operator:

 &0 1 0 0 1
1 4
 *&0 1 0 0 1
1

Lil doesn't have an independent monadic primitive for this operation; it's folded into the query language:

first extract value where 0=map@value from np

This is a little bulky when you're doing something simple.

When you only need a single result, you could consider forming a dictionary:

((0=map@np)dict np)[1]

It's also possible to perform an equivalent "masking" operation just with arithmetic:

m:0,0,0,1,0     # "one-hot" boolean vector
m*keys m        # (0,0,0,3,0)
sum m*keys m    # 3