I have mostly forgotten this code, so I have to read it myself, to
understand it.

Here's an overview, though:

MOVES gives the legal moves (destination positions after moving) for
each position on the board.

I had no use here for indexing by row or indexing by column, so board
positions are an integer rather than a pair of integers.

seq looks like this:

   seq=: (, MOVES ({~ ?@#)@{::~ _2&{)^:(~:/@{.~&_2)^:_

The overall structure of seq is:
   (, MOVES verb2 verb1)^:test^:_

so it's a "repeat until done" concept, where the test part tells us
when we are done, and the left hand part is choosing a move to add to
the list of moves which is the argument.

Note that ^:_ verbs can be inspected using copy and paste.

For example, V^:_ N goes through these steps:

   N
   V N
   V V N
   V V V N
   V V V V N
   ...
and when a result repeats that will be the final result.

Of course, U^:V^:_ N can be inspected using that same approach:
   N
   U^:V N
   U^:V U^:V N
   U^:V U^:V U^:V N
   ...

but the test will be a 0 or 1 result and we are only interested in
when it changes.  So a more informative sequence of tests would be:
   N
   V N
   U N
   V U N
   U U N
   V U U N
   U U U N
   ...

Anyways, the point of all of this is that the verbs are just tools of
manipulation -- the interesting thing is the data.  If you can
understand the data you can understand the point of the manipulations.
 But seeing the data can be a critical step in learning to understand
the data.

I hope this helps,

-- 
Raul

On Tue, May 1, 2012 at 10:02 PM, Linda Alvord <lindaalv...@verizon.net> wrote:
> On 4/5/12 I sent out this challenge, and Raul Miller had an encrypted
> solution the same day!  Here is the translation.
>
>
>
>    full simulation 0
>
> ---------┐
> │B goes  │
> │first , │
> │W wins  │
> +--------+
> │.o.o.o.o│
> │oWo.o.o.│
> │.o.o.o.o│
> │o.o.o.o.│
> │.o.o.o.o│
> │o.o.o.o.│
> │.o.o.oBo│
> │o.o.o.o.│
> +--------+
> │.o.o.o.o│
> │oWo.o.o.│
> │.o.o.o.o│
> │o.o.o.o.│
> │.o.o.o.B│
> │o.o.o.o.│
> │.o.o.o.o│
> │o.o.o.o.│
> +--------+
> │.o.o.o.o│
> │o.o.o.o.│
> │.o.W.o.o│
> │o.o.o.o.│
> │.o.o.o.B│
> │o.o.o.o.│
> │.o.o.o.o│
> │o.o.o.o.│
> +--------+
> │.o.o.o.o│
> │o.o.o.o.│
> │.o.W.o.o│
> │o.o.oBo.│
> │.o.o.o.o│
> │o.o.o.o.│
> │.o.o.o.o│
> │o.o.o.o.│
> +--------+
> │.o.o.o.o│
> │o.o.o.o.│
> │.o.o.o.o│
> │o.o.oWo.│
> │.o.o.o.o│
> │o.o.o.o.│
> │.o.o.o.o│
> │o.o.o.o.│
> L---------
>
>
>
> Here is the code in separate lines with no conventional control structures.
>
>
>
> SQUARES=:,8 8 {.9 9$'.o'
>
> pieces=: # $ {&(32#'WB')@{.~&2
>
> summary=: ({.,' goes first, ',{:,' wins  '"_)@pieces
>
> boards=: (8 8 ,@<@$ ]`[`(SQUARES"_)})"1&(]\~&2) pieces
>
> full=: (]\~&_2)&.;:@summary ; boards
>
> MOVES=:,8 8{.11 11$<@(8#.(#~ */@:<&8"1))"2]11#.inv 120<.(i.121)+/(,-)9 13 21
> 23   NB.  MOVES is a long line
>
> seq=: (, MOVES ({~ ?@#)@{::~ _2&{)^:(~:/@{.~&_2)^:_
>
> simulation=: seq@(|.^:(? bind 2) bind 9 54)
>
>
>
> simulation 0
>
> full simulation 0
>
>
>
> I have been struggling and finally "translated"  MOVES  to  movesla  in
> simple J (almost - only 1 @).
>
>
>
>
>
> K=:11#.inv 120<.(i.121)+/(,-)9 13 21 23
>
> movesla=: 13 :',(x,x){.11 11 $<@((x#.(#~"2(*/"1@:<x"1)))"2)y'
>
>
>
> I can't untangle  seq.
>
>
>
> Raul's solution is impressive and I hope to understand it sometime.
>
> In any case, any help with a way around control structures in the simple J
> version.
>
>
>
> Linda
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to