Along the lines of this discussion, my daughter is looking at a
"four-dimensional" version of tic-tac-toe where each entry of the 3x3 table
is another 3x3 tic-tac-toe grid and there's a rule that the grid upon which
a player can play is influenced by the previous player's move: if player 0
puts an "X" in the upper-right corner of the middle grid, then player 1 is
constrained to put an "O" only on the upper-right grid; if there is no move
available on the putative grid, player 1 can make a move on any grid,
constraining player 0's next move similarly.

This is interesting from the standpoint that it should be possible to
enumerate all possible games and, from this, determine if there's a forced
win for one of the players.

On Thu, Feb 18, 2016 at 5:55 PM, Pascal Jasmin <[email protected]>
wrote:

> My program isn't a complete othelo move finder, as it assumes that there
> are no holes in the board, but with that assumption,
>
> looking at bidirectional approaches by row column and both diagonal
> directions does find legal moves more efficiently than looking at each
> cell.  There is only one solution per directional analysis.  If you took a
> per cell approach, you would still have to look at sets formed in 8
> directions from that cell to see if it could be a valid move.  Much more
> complex to create those sets, and examining more permutations in total.
>
>
>
>
> ----- Original Message -----
> From: Raul Miller <[email protected]>
> To: Programming forum <[email protected]>
> Sent: Thursday, February 18, 2016 12:17 AM
> Subject: Re: [Jprogramming] an inverse to oblique
>
> That pattern - selecting some kind of legal moves on a board - is, I
> think, better solved with a table of indices (one row per board
> position, one column per direction, use _ for illegal moves). And, for
> something like othello, you would probably add another dimension so
> you get each of the relevant pieces. That way, you pre-compute the
> move table for the board and then have a relatively simple (and
> relatively fast) per-move mechanism.
>
> Or, at least, that is how I approached that problem when I last
> implemented something vaguely similar...
>
> Thanks,
>
> --
> Raul
>
>
> On Wed, Feb 17, 2016 at 6:24 PM, Pascal Jasmin <[email protected]>
> wrote:
> > The reason I asked, was to make this seemingly useful adverb that lends
> well to J patterns.  The pattern is applying a verb 8 distinct directions
> across a table (rows cols 2 diagonals front and back)
> >
> > unoblique =: 4 : ' (;y)  (;</.{i.&.> x)} (x $ 0)'
> > eightdirs =: 1 : '[: |:@:(|."1) $ unoblique  [: u&.|. 
> > each@:(</.)@:(|."1)@:|:
> [: |:@:(|."1) $ unoblique  [: u each@:(</.)@:(|."1)@:|: $ unoblique  [:
> u&.|. each@:(</.) $ unoblique [: u each@:(</.) [: u"1&.|."1 [:
> u"1&.|."1&.|: [: u"1  u"1&.|:'
> >
> >
> > An example use is solving legal moves for othello,
> >
> > a  =. '-OX' i. > cutLF 0 : 0
> > --------
> > --------
> > ---OX---
> > --XXXO--
> > --XOO---
> > ---O----
> > --------
> > --------)
> >
> > legal x moves,
> >
> > '-OX_*' {~  2&(4 : ' (({:y) , 2  {.`4:@.( (0 , 2 1 {~ 2=x)&-:)\
> ])^:(x&e.) y') eightdirs a
> > --------
> > --***---
> > --*OX---
> > --XXXO*-
> > --XOO**-
> > --*O**--
> > ---**---
> > --------
> >
> >
> >
> > legal o moves,
> >
> > '-OX_*' {~  1&(4 : ' (({:y) , 2  {.`4:@.( (0 , 2 1 {~ 2=x)&-:)\
> ])^:(x&e.) y') eightdirs a
> > --------
> > ---**---
> > -**OX*--
> > -*XXXO--
> > -*XOO*--
> > ---O----
> > --------
> > --------
> >
> > 2dirs and 4dirs adverbs are just shorter versions of this that many of
> us have likely used without naming the pattern.  More complex 3d versions,
> if you need them, shouldn't be insanely hard, and useful if you have a verb
> to use the pattern.
> >
> >
> > ----- Original Message -----
> > From: Roger Hui <[email protected]>
> > To: Programming forum <[email protected]>
> > Sent: Wednesday, February 17, 2016 2:48 PM
> > Subject: Re: [Jprogramming] an inverse to oblique
> >
> > Instead of portrait and landscape matrices, I myself use tall and wide
> > matrices, terminology I first heard used by Eugene McDonnell.
> >
> > On Wed, Feb 17, 2016 at 11:18 AM, Mike Day <[email protected]>
> > wrote:
> >
> >> I started with the rectangular case,  so have this rather more
> complicated
> >> monad:
> >>
> >> deo =: 13 : 's$i{;y[ i =. /:;</.i.s =. (((+/(],%)>./)@:(#every)))y'
> >>
> >> I was a bit surprised that the result is tacit.
> >>    deo
> >> (+/ (% , ]) >./)@:(#&>) $ ; {~ [: /: [: ; [: </. [: i. (+/ (] , %)
> >> >./)@:(#&>)
> >>
> >> As Marshall observes,  it's not possible to deduce the orientation of
> >> the rectangle.  The verb here assumes a landscape shape.
> >>
> >> Unfortunately,  the result is wrong if the original was portrait...
> >>
> >> eg
> >>    [land  =: </.(a.{~97+i.25){~i.3 8
> >> +-+--+---+---+---+---+---+---+--+-+
> >> |a|bi|cjq|dkr|els|fmt|gnu|hov|pw|x|
> >> +-+--+---+---+---+---+---+---+--+-+
> >>
> >>     [port =: </.(a.{~97+i.25){~i.8 3
> >> +-+--+---+---+---+---+---+---+--+-+
> >> |a|bd|ceg|fhj|ikm|lnp|oqs|rtv|uw|x|
> >> +-+--+---+---+---+---+---+---+--+-+
> >>
> >>    deo land   NB. ok
> >> abcdefgh
> >> ijklmnop
> >> qrstuvwx
> >>
> >>    deo port    NB. !!!
> >> abcfilor
> >> dehknqtu
> >> gjmpsvwx
> >>
> >> This dyad allows us to specify landscape or portrait with the
> >> optional left argument;  explicit odd x forces portrait; the default
> >> is landscape.
> >>
> >> deod =: 3 : 0
> >> 0 deod y
> >> :
> >> s =. (((+/(] (x |.,) %)>./)@:(#every)))y
> >> i =. /:;</.i.s
> >> s$i{;y
> >> )
> >>
> >>    deod land
> >> abcdefgh
> >> ijklmnop
> >> qrstuvwx
> >>
> >>    1 deod port
> >> abc
> >> def
> >> ghi
> >> jkl
> >> mno
> >> pqr
> >> stu
> >> vwx
> >>
> >> I've assumed that the input is properly derived from oblique
> >> boxing of a rectangular array.
> >>
> >> Mike
> >>
> >>
> >>
> >> On 17/02/2016 17:42, Marshall Lochbaum wrote:
> >>
> >>> deoblique =: ($:~ [: ((1+i.,i:)>./) #@>) : ([ $ (/:&; </.@:i.)~)
> >>>
> >>
> >>
> >> ---
> >> This email has been checked for viruses by Avast antivirus software.
> >> https://www.avast.com/antivirus
> >>
> >>
> >> ----------------------------------------------------------------------
> >> For information about J forums see http://www.jsoftware.com/forums.htm
>
> >
> >>
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>



-- 

Devon McCormick, CFA

Quantitative Consultant
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to