Ludii Forum
Slide as far as possible - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Suggestions (https://ludii.games/forums/forumdisplay.php?fid=10)
+--- Forum: Ludii Features / Services (https://ludii.games/forums/forumdisplay.php?fid=11)
+--- Thread: Slide as far as possible (/showthread.php?tid=103)



Slide as far as possible - dale walton - 08-01-2020

I assume (move Slide) means move any distance in a straight line over empty spaces,

How does one code for move as far as possible in a straight line over empty spaces?

Something like this??

(move Step
        (then
                (do
                       (step (last To) Forward
                       ifAfterwards: (can (step (last To) Forward))
                       (then
                                (if
                                      (can (step (last To) Forward)
                                      (step (last To) Forward)
                                )
                        )
                 )
         )
)


RE: Slide as far as possible - cambolbro - 08-01-2020

Hi,

The (shoot ...) ludeme does that, as used in Amazons.lud.

Regards,
Cameron


RE: Slide as far as possible - Eric Piette - 08-10-2020

Hi,

The (shoot ...) ludeme is not to move as far as possible but to place a piece as far as possible in straight lines from a site.

But to move as far as possible to empty sites in straight lines you can use the line of sight ludeme like that for example:


Code:
(....
    (equipment {
        (board ...)
        (piece "Disc" Each (move (from) (to (sites LineOfSight Empty at:(from)))))
    })
    (rules
        (play (forEach Piece))
        (end (if ....) )
    )
)


Regards,
Eric Piette


RE: Slide as far as possible - AlekErickson - 08-10-2020

I think you can use the LineOfSight Farthest command.


RE: Slide as far as possible - dale walton - 08-10-2020

Thanks but not compiling for me.

I am not sure how it works, as not in 1.0.1 documentation yet. why Empty at :(from) ?

Are you saying that shoot could work, but I would need to remove the piece at (from)?

BTW for another game, I need to move/jump (potentially over either player's pieces) to the first empty site in any direction, but can't get this to work either.


RE: Slide as far as possible - ccxvii - 08-10-2020

A related question: what if I want to Hop over more than one piece in a line? I'm tyring my hand to implement Yinsh, where you have rings and discs and the rings can move in a straight line over any number of empty spaces (0-N), then over any number of discs (1-N), and stop at the first empty site after the discs.

I've tried doing this with the following rules, and it works for hopping over a single disc. When trying to extend it by adding a (range) clause to the (between) it results in no moves at all:

        (move Hop
                (between
                        before:10
                        //(range 1 10) // if this is enabled, no hops are generated!
                        after:0
                        if:(or
                                (= (what at:(between)) (id "Disc1"))
                                (= (what at:(between)) (id "Disc2"))
                        )
                        (apply ("Flip"))
                )
                (to if:(is Empty at:(to)))
        )

PS. Could you please add some notes to the reference manual about which ludemes set which context values, and what scope the context values have? I ran into some trouble using the (forEach Site ...) rule expecting the context for the current site looped over to be (site) when it's actually using the (to) context. Took me a bit of banging my head into the wall until I figured that one out!


RE: Slide as far as possible - Eric Piette - 08-11-2020

@Dale:

That should compile, can you post here the full description you have?

The (from) is the site from where is the piece currently. And the Empty means you want to move to the empty site in the light of sight of the piece.

For the shoot one, yes that will work if you should the piece in the from location and then remove the piece in the from location. But that's not necessary to do that, just moving the piece is better.

For the last question, I answered to you in another thread to be sure of what you ask, then I will help you with that.



@ccxvii

For a such kind of move you can look the code of International draughts for the double counters, that's really similar to what you ask I guess

here an extract using a ludemeplex:
("HopDiagonalSequenceCapture" before:(count Rows) after:(count Rows))

If you do not succeed with that I can write a full description if you want with a simple case doing a such hop move.


RE: Slide as far as possible - ccxvii - 08-11-2020

I don't want multiple hop sequences over single enemies, I want one hop over an unbroken line of enemies.

Here's an example: @ is the piece to move, e is empty, O is occupied.

@ e1 e2 O3 O4 O5 e6 e7 e8 O9

In this situation I want to allow either slide to e1 or e2, or a hop to e6. I naively tried to accomplish the latter with this formulation (since "between" takes a range between the before and after arguments, I assumed it would work).

 (move Hop
    (between
        before:(count Rows)
        (range 1 (count Rows))
        after:0
        if:(is Occupied (between))
        (apply ...)
    )
 )


RE: Slide as far as possible - Eric Piette - 08-12-2020

Hi,

The description of what you asked is

Code:
(or
  (move Slide)
   (move Hop
       (between
           before:(count Rows)
           (range 1 (count Rows))
           if:(is Occupied (between))
       )
       (to if:(is Empty (to)))
   )
)

I just tested it to be sure, and it works in our dev version. But yesterday I fixed a bug in the hop move concerning the jump of many pieces of different sizes, consequently unfortunately with the version 1.0.2 that will not work correctly.

In the next release, that will be fixed and you will be able to use that description to do what you need.

Regards,
Eric