Ludii Forum
(move (to (sites LineOfSight Empty)) Next )? - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Problems (https://ludii.games/forums/forumdisplay.php?fid=5)
+--- Forum: Grammar Problems (https://ludii.games/forums/forumdisplay.php?fid=24)
+--- Thread: (move (to (sites LineOfSight Empty)) Next )? (/showthread.php?tid=134)

Pages: 1 2


(move (to (sites LineOfSight Empty)) Next )? - dale walton - 08-16-2020

2nd Edit: Actually not solved - It is only checking from the last placed opponent's piece - I need to exclude LOS from ALL opponent's pieces.

Edit: #1) I Solved: - should have been:     (sites To (move (from (sites Occupied by:Next)) (to (sites LineOfSight Empty))))
Sorry for the inconvenience.
====================
1) Please tell me what is wrong with this code:

(play
     (move
         Add
          (to
              (difference
                 (sites Empty)
                 (sites To (forEach Piece (move (to (sites LineOfSight Empty)) Next  )))
              )
           )
       )
 )


I get:
Unexpected syntax '(to (sites LineOfSigh...' in '(move (to (sites LineOfSight ...'.

I am trying to disallow movement to sites where an opponent has a line of sight.

Despite what the error says, the "Next" triggers it.

-----------------------------------------------------------------
2) I have some games where players place both colors but score their own, and (move <from> <to> <player>) seems to be the only form that handles this, so I need to know its limitations.

3) I also separately want to know what happens under LOS if there are tiles on the board?


RE: (move (to (sites LineOfSight Empty)) Next )? - dale walton - 08-16-2020

I also tried this way, but it doesn't allow any moves at all:

(define "Try1"
  (move
    Add
    (to
      (sites LineOfSight Empty)
      if:(not
          (can
            Move
            (move Slide
              (from (last To))
              (to if:(is Enemy (who at:(to)))) 
            )
          )
        )
      )
    )
  )
)


RE: (move (to (sites LineOfSight Empty)) Next )? - Eric Piette - 08-16-2020

Hi,

the (move ...) ludeme excepts a from and a to to be used.
so

Code:
(move (to (sites LineOfSight Empty)) Next  )


is incorrect.

and should be


Code:
(move (from) (to (sites LineOfSight Empty)) Next  )


but anyway, if I understand what you try to do a better description would be

Code:
(play
     (move
         Add
         (to
             (difference
                (sites Empty)
                (sites To (forEach Piece (slide) Next  ))
             )
         )
      )
)

Regards,
Eric Piette


RE: (move (to (sites LineOfSight Empty)) Next )? - Eric Piette - 08-16-2020

And if you really want to use the line of sight ludeme the description would be


Code:
(play
   (move
      Add
      (to
         (difference
             (sites Empty)
             (sites To (forEach Piece (move (from) (to (sites LineOfSight Empty at:(from)))) Next ))
         )
      )
   )
)

Regards,
Eric Piette


RE: (move (to (sites LineOfSight Empty)) Next )? - dale walton - 08-16-2020

Thanks for the explanation.  Every bit helps. LOS and Slide are confusing because the (to) values (ie sites that may be chosen) include more that the (to) that is the target of the move. It takes hours to try to figure out what the intent of the documentation is by trial and error.

Unfortunately, neither of those solutions works to remove any sites from the empty sites.  Mine at least was removing sites related to one enemy piece.
I suspect that the "(sites To"  cannot combine the results from the "(forEach" Piece and is only returning one successful case.

That is why I looked at limiting it with (can,  but ran into the same problem.


Why the  Empty at:(from)  - doesn't (from) contain the opponent's piece? or is the "Empty" excluding a possible piece at (to) and the  "at:(from)" doing something else?

As implemented, I have been trying to figure out when using (to (sites LineOfSight Piece)) how to add the condition to check who the piece belongs to.
Also as implemented I am not sure how to separate the cases of inclusion of middle, inclusion of end(s), exclusion of the Empty in the outcomes of the ludeme.

I wish there was more documentation about how and were forEach can be used.

Update: I mistakenly send an totally wrong version.
The updated version only clears the sites LOS from the last placed piece, but I desire from all pieces. Adding forEach makes it not work at all on the first placement, and thereafter seems to be the same as without it.  Perhaps it is a bug?


RE: (move (to (sites LineOfSight Empty)) Next )? - Eric Piette - 08-16-2020

Hi, 

Ok we effectively have a bug in (forEach Piece ...) if we have some specific moves defined directly in the (forEach Piece ...) and not in the generator of the moves in the pieces and if the player of the (forEach Piece ....) is not the mover.

I just fixed it in our dev version and will be published with the next release.

But with your current version you can make it to work if you do not use the <Moves> parameter in the (forEach Piece ...) ludeme and define the move you currently define in that ludeme directly in the pieces like (e.g. (piece "Ball" Each (move Slide)))

(play
   (move
      Add
      (to
         (difference
             (sites Empty)
             (sites To (forEach Piece Next ))
         )
      )
   )
)



Sorry for the inconvenience.

Regards,
Eric Piette


RE: (move (to (sites LineOfSight Empty)) Next )? - dale walton - 08-16-2020

The game also will have movement and capture in addition to this, so I would need to define only the slide part of the moves moves in the piece, and add conditions and other moves in the play, as you illustrate. I'll give it a try.

Thanks for looking into it.


RE: (move (to (sites LineOfSight Empty)) Next )? - dale walton - 08-17-2020

Off topic, but could you also help with the correct way to do this:

(define "SetStates"
  (forEach
    Site
    (sites To (forEach Piece Next ))
    (set
      State
      at:(site)
      (count
        Pieces Next
        in:(sites Around (site))
      )
    )
  )
)

in the documentation (site) is only used for "bySite",  so how does one iterate sites using (forEach Site ?


RE: (move (to (sites LineOfSight Empty)) Next )? - Eric Piette - 08-17-2020

(bySite) is the previous name of the ludeme (forEach Site ....). We just did not update the documentation for (site) but the ludeme (site) can be used to iterate the sites got by (forEach Site ...)

I have now updated the documentation, that will be published with the next release.

So the description you posted here is correct and works (I just test it).

Regards,
Eric


RE: (move (to (sites LineOfSight Empty)) Next )? - dale walton - 08-17-2020

Also having problems with nested (do ... or do within an (or..  list of moves.

I am about 3 bugs away from a viable game. - Options to come later - see attached.

(08-17-2020, 07:47 AM)Eric Piette Wrote: (bySite) is the previous name of the ludeme (forEach Site ....). We just did not update the documentation for (site) but the ludeme (site) can be used to iterate the sites got by (forEach Site ...)

I have now updated the documentation, that will be published with the next release.

So the description you posted here is correct and works (I just test it).

Regards,
Eric
Not sure why it didn't work for me, so I changed the algorithm to do it on the fly without states.
Then I thought I might be having a problem with modifying the (to) part of the implied move, so tried  using do to apply it using an ifAfterwards  move filter..  I don't know which way works fastest or best, but my 1.0.3 is not yet compiling it and I don't see the reasons. - and also am not sure  if the ifAfterwards should take to, from or last To, last From.