Ludii Forum
Cells around a vertex - 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: Cells around a vertex (/showthread.php?tid=405)

Pages: 1 2


Cells around a vertex - dale walton - 02-01-2021

I am working on a hex cell based game where it would be convenient if I could select each vertex, then check the cells it is part of for player occupancy, and if all 3 are occupied by the mover, then move each of those pieces one step in the same direction.

What functions are available to use for this.  I see (sites Incident...) but it has almost no documentation, can it be used?  Can I even select vertices at all in a Cell based game?  Can you suggest an appropriate approach?


RE: Cells around a vertex - dale walton - 02-02-2021

OK. I was able to use sites Incident to test for the triplets and select them.  In the documentation it would help to give examples or a definition of incident as you use it.

From an player interface point of view, it would be nice, then, to have dynamic large pieces so that whole group would be highlighted and the script-writer's work for testing the sites for collision could also be reduced.  (select Cohort of:(sites  ) origin:(site))) .....  (move Cohort (from) (to if:(is Cohort Empty(to))

Or just  Group instead of a new term... but the idea is a group with a defined origin, like a Large piece has so that a group can be moved like a large piece would.


RE: Cells around a vertex - dale walton - 02-03-2021

Actually this code is working Except...

(define "DozerLocation"
  (= 3 (count Pieces Mover in:(sites Incident Cell of:Vertex at:#1)))
)

(define "Plow"
  (move Select
  (from (forEach (sites Board Vertex) if:("DozerLocation" (site))))
  (to (sites Distance Vertex Adjacent from:(from) 2))
  (then
    (and
    (forEach
      Site
      (sites Incident Cell of:Vertex at:(last From)) 
      (remove (site))
    )
    (forEach
      Site
      (sites Incident Cell of:Vertex at:(last To)) 
      (add (to (site)))
)))))

The player doesn't auto-detect that the selection dots should show on vertices. If the (move Select... ludeme had a Vertex argument, this could easily be resolved.

The code above is for a game played on the cells of a Hex board.  The selects, as written obviously show up on cells far from where I intend, but the code works in moving a triplet from one place to another. - all that is missing is to have the selection dots show on the vertices.


Checking corresponding cells for occupancy could still be an issue - I am thinking about how to do it.


RE: Cells around a vertex - dale walton - 02-03-2021

So the other essential that I need for this is a function to return a direction of movement based on a from-to pair.

eg (direction [Vertex|Cell|Edge] from:<> to:<>)

that can be used in a move such as (push (from (site)) (direction Vertex from:(last From) to:(last To)))
or (hop ... ) or (slide...) to specify the direction chosen.

Does "SameDirection" do this based on lastFrom and lastTo, or does there need to be an actual move performed or direction specified in advance?

Also SameDirection wouldn't work here anyway as it wouldn't be able to detect that the direction to be used for the cell movements was derived from vertices.


RE: Cells around a vertex - Eric Piette - 02-10-2021

Hi,

In the next release, you will be able to select two different sites which can be different graph element types. 

Example to select the vertex 0 and the cell 0:



Code:
(move Select
    (from Vertex 0)
    (to Cell 0)
)


AND

In the next release, it will be possible to get the direction between two sites with the (directions ....) ludeme.
Example to get the direction between Cell (last From) and Cell (last To) here.


Code:
(directions 
     Cell 
     from:(last From) 
     to:(last To)
)

I attached a small test game for you to test with the next release with these two examples.

Regards,
Eric


RE: Cells around a vertex - Michael - 02-10-2021

This is great news, Eric! I think I'll have to rewrite some games to use this new direction function, then. I have been missing it. Any chance of adding selection of a specific level as well?


RE: Cells around a vertex - Eric Piette - 02-10-2021

Hi,

Yes I can also add the level to them, that will be also in the (from ...) and (to ...) of the select ludeme.

Regards,
Eric


RE: Cells around a vertex - Michael - 02-10-2021

(02-10-2021, 02:40 PM)Eric Piette Wrote: Hi,

Yes I can also add the level to them, that will be also in the (from ...) and (to ...) of the select ludeme.

Regards,
Eric
You're a saint!


RE: Cells around a vertex - dale walton - 02-10-2021

Indeed, thanks very much. It opens up a lot of useful territory to explore.


RE: Cells around a vertex - dale walton - 02-16-2021

I am getting compiler rejections when I try to use this new (directions ...)  Ludeme, can you show an example of how it works?
Is it an array of Integers, or a list of strings? Can it be converted to a single item?

I had assumed you would give a less general (direction ...) function giving a single value, that could be then inserted to specify a direction value wherever such a value is allowed:
(move Step
(move Slide
(move Shoot
(move Hop
(custodial
(directionCapture
...
(sites Around
(sites Direction
(forEach Direction
(remember Value
(set Direction

Perhaps it already can do what I want, but the compiler hasn't been given the "OK" to allow it?
------------------------------------------------

OK, Looked again, and now understand a little better how it works.  The problem was that one still needs "Adjacent" - I had assumed that the new function replaced the <directions>  (which is optional in most the ludemes) but it turns out you need both.

That is a lot of documentation update needed...

---------------------------------------
PS  I waste a lot of time everytime I switch code from (sites Around  to  Sites Distance  to sites Direction because these unnecesarily require the same information in different sequences and formats.  It is a general problem in other parts of the language as well which means having to refer continuously to documentation even when aware of the problem.