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
|
RE: Cells around a vertex - dale walton - 02-16-2021 Another issue I find is that Ludii doesn't seem to define the OffDiagonal directions for Hexagonal vertices. i.e the short diagonal directions that should be the same direction as the cell to cell directions. If the are not defined, I won't be able to use them for determining the cell to Cell directions they are parallel to... -------------------------------- As a separate issue, With no working direction to them, I can't even select them, even this: isn't working for me: Select (from Vertex (sites Empty Vertex)) (to Vertex (sites Around Vertex ((sites Around Vertex (from) Adjacent)) Adjacent) ) ------------------------------- I think my easiest work-around is to play on the Verticies of a triangular grid, and select the cells for the group moves... Edit: ran into another bug/problem (move Add (to Vertex (sites Empty Vertex) if: (= 0 (count Pieces Next in:(sites Around Vertex (to)))) ) The condition did not work for the triangular grid ontil I specified use:Vertex for the board. The boards are different as well, because without use:Vertex you give a colored board with space for both cells and triangles. That is the board where it did not work. ---------------------- What is the difference between: (sites Cell Vertex (from)) --- this one works on the use:vertex board. (sites Incident Vertex of:Cell at:(from)) --- this one does not work on the use:vertex board. But on the cell board, the second form worked, and the analogous: (sites Incident Cell of:Vertex at:(from)) worked , and doesn't have a corresponding (and confusing - it should be something like "IncidentCell" ) simple form Which is preferred? which will you make to work for all the boards? RE: Cells around a vertex - dale walton - 02-17-2021 Well I have a script that starts to show what I'm trying to do and the problems. I tried to follow your slide examples, because other moves might be different, but I was not successful - Then I tried to use (set Direction ... and SameDirection to handle it.) Maybe you can help to see what is wrong in the attached file .... Here are examples of the errors during my edits. Unexpected syntax '(sites Direction from...' in '(is Empty (sites Direction fr...'. Player 1 to move. Unexpected syntax 'Adjacent' in '(slide (from if:(not (is Empt...'. Player 1 to move. Unexpected syntax 'Vertex' in '(slide (from if:(not (is Empt...'. Player 1 to move. Unexpected syntax 'Vertex' in '(slide (directions Cell from:...'. Player 1 to move. <html><h2>Syntax error: Could not create "game" ludeme from description.</h2><br/><p>//<br/>(define "Place"<br/> (move<br/> Add<br/> (to Vertex (sites Empty Vertex) <br/> if:(or<br/> (= 0 (count Pieces Next in:(sites Around Vertex (to))))<br/> (not (all Sites (sites Incident Cell of:Vertex at:(to)) if:(not ("TriangleLiberty" (site)))))<br/>))))<br/><br/>(define "TriangleLiberty" // argument is vertex location<br/> (= 2 (count Pieces Mover in:(sites Cell Vertex (#1))))<br/>)<br/>(define "DozerLocation" (sites Cell Vertex (#1)))<br/>(define "IsDozerLocation" (= 3 (count Pieces Mover in:("DozerLocation" #1))))<br/><br/>//Check for at least one empty in or ahead of the Rubble in front of the Dozer <br/>(define "CanPlow" // (last From, last To) <br/> (= 0 <br/> (+<br/> (results <br/> from:(difference ("DozerLocation" #2) ("DozerLocation" #1))<br/> (if <br/> (< 0<br/> (count Sites <br/> in:(intersection<br/> (sites Empty Vertex)<br/> (sites Direction <br/> from:(from) <br/>// (directions Cell from:(#1) to:(#2))<br/>SameDirection<br/> included:True<br/> distance:1<br/> Vertex<br/> ))))<br/> 0<br/> 1<br/>)))))<br/><br/>(define "PushRubble" // (last From, last To) - Rubble pieces can belong to either player<br/> (forEach Site<br/> (difference ("DozerLocation" #2) ("DozerLocation" #1))<br/> (slide<br/> (from if:(not (is Empty (from))))<br/>// (directions Cell from:#1 to:#2)<br/>SameDirection<br/>// Adjacent <br/>// Vertex<br/>)))<br/><br/>(define "PushBlade" // (last From, last To)<br/> (forEach Site<br/> (intersection ("DozerLocation" #1) ("DozerLocation" #2))<br/> (slide<br/>// (directions Cell from:#1 to:#2) <br/>SameDirection<br/>// Adjacent <br/>// Vertex<br/>)))<br/><br/>(define "MoveDozerEngine" // (last From, last To)<br/> (forEach Site<br/> (difference ("DozerLocation" #1) ("DozerLocation" #2))<br/> (slide<br/>// (directions Cell from:#1 to:#2)<br/>SameDirection<br/>// Adjacent<br/>// Vertex<br/>)))<br/><br/>(define "Plow"<br/> (move Select<br/> (from Cell (sites Board Cell) if:("IsDozerLocation" (from)))<br/> (to Cell (sites Around Cell (from) OffDiagonal))<br/> (then <br/> (if <br/> ("CanPlow" (last From) (last To))<br/> (and<br/> {<br/> ("PushRubble" (last From) (last To))<br/> ("PushBlade" (last From) (last To))<br/> ("MoveDozerEngine" (last From) (last To))<br/> }<br/>)))))<br/><br/>(define "CanPlow2"<br/> (< 1<br/> (min <br/> (results<br/> from:("DozerLocation" (last From)) <br/> (max 1 (count Sites in:(sites Around (from) distance:2 (directions Cell from:(last From) to:(last To)) Adjacent if:(is Empty (site)))))<br/> )<br/>)))<br/> <br/><br/>(define "BoardUsed" (<BoardShape:gridType> <BoardSize:smallSide>))<br/><br/>(option "Board Size" <BoardSize> args:{<smallSide> } <br/> {<br/> (item "Infuse 2" <2> "Order 2 board")<br/> (item "Infuse 3" <3> "Order 3 board")<br/> (item "Infuse 4" <4> "Order 4 board")<br/> (item "Infuse 5" <5> "Order 5 board")**<br/> (item "Infuse 6" <6> "Order 6 board")<br/> (item "Infuse 7" <7> "Order 7 board")<br/> (item "Infuse 8" <8> "Order 8 board")*<br/> (item "Infuse 9" <9> "Order 9 board")<br/> }<br/>)<br/>(option "Board Grid" <BoardShape> args:{<gridType> } <br/> {<br/> (item "Square Grid" <square> "Square Grid")*<br/> (item "Hex Grid" <tri Hexagon> "Hex Grid")<br/> (item "Hex Limping" <tri Limping> "Hex N / N+1 Grid")**<br/> }<br/>)<br/><br/>//-------------------------------------------------<br/><br/>(<font color=red>game</font> "Oomph"<br/> (players 2)<br/> (equipment<br/> {<br/> (board "BoardUsed" use:Vertex)<br/> (piece "Disc" Each)<br/> }<br/> )<br/> (rules<br/> (start (set Score Each 0))<br/> (play<br/> (if <br/> (was Pass)<br/> (or<br/> (move Pass)<br/> (priority <br/> ("Plow")<br/> ("Place")<br/> )<br/> )<br/> (or<br/> {<br/> ("Place")<br/> ("Plow")<br/> (move Pass)<br/> }<br/> )<br/> )<br/> )<br/> (end <br/> {<br/> (if <br/> (and<br/> (all Passed)<br/> (> (score Mover) (score Next))<br/> )<br/> (result Mover Win)<br/> )<br/> (if <br/> (and<br/> (all Passed)<br/> (le (score Mover) (score Next))<br/> )<br/> (result Next Win)<br/> )<br/> }<br/> )<br/> )<br/>) <br/><br/>//---------------------------------------------<br/><br/>(metadata<br/> (info<br/> {<br/> (description "Played on cells of a hex grid on a large board.<br/>A turn has up to three parts: Placement followed by movement, followed by capture.<br/>Each and all parts are optional.<br/><br/>Placement: a single stone is placed on an empty cell that either is not adjacent to an opponent's piece, or else that shares a vertex with two existing friendly stones.<br/><br/>Movement:<br/>A vertex surrounded by 3 friendly stones is selected as the starting point. If a placement was made on the turn, one of the 3 stones must be the stone that was placed. The 3 stones at that vertex all shift by one cell in one of the six grid directions. They are able to push stones on the two cells in front of them, provided that no other stones will be displaced by the move.<br/><br/>Capture: Any isolated stone, or maximal group of mutually connected stones which can no longer have a stone of its color placed adjacent at some cell around it, is removed in its entirety. If there is more than one such group the player must choose which to remove.<br/><br/>The <font color=red>game</font> ends when both players pass or when one is eliminated.<br/><br/>Scoring is by territory. One's territory is all the cells one occupies plus all the cells that only you can place a piece on.")<br/> (rules "Oomph is a territorial placement <font color=red>game</font> that includes invasive movements by triplets of pieces called 'Dozers' that can displace that can displace upto two more pieces in a plowing action.<br/> <br/>Goal: Most territory when the <font color=red>game</font> ends. <br/>Territory is any cell with your stone and every cell where you may play a stone. (Both player's territories may overlap by this definition, but the result is the same as excluding the overlapping territory from both players territory.) <br/><br/>Start on an empty board. <br/>Each turn has upto three actions: <br/>1) Placement<br/>2) Plowing<br/>3) Capture<br/>These actions are optional, may only be taken once per turn, and are never taken out of order.<br/><br/>Placement:<br/>A single stone is placed on an empty cell. The chosen cell may be adjacent to an enemy stone only if it also shares a vertex with two existing friendly stones, such that the placed stone will form a triangle (Dozer) with them. Otherwise the player must choose a cell for placement that is not adjacent to an enemy stone.<br/><br/>Plowing:<br/>If a placement was made that formed a Dozer, that Dozer move as a unit, one cell distance 'plowing' up to two stones on its leading edge along with it. The plowing move may not be taken if either of the plowed stones would end up on an occupied space. <br/><br/>Plowing is not available as an action after placements that do not form a Dozer.<br/><br/>If no placement was made, then any three player's stones sharing a vertex may be used as a 'Dozer'<br/>The plowed stones. <br/><br/>Capture: Any isolated stone, or maximal group of mutually connected stones which can no longer have a stone of its color placed adjacent at some cell around it, is removed in its entirety. If there is more than one such group the player must choose which to remove.<br/><br/>Ending the <font color=red>game</font>. The <font color=red>game</font> ends after three consecutive passes. Any completed turn that returns the <font color=red>game</font> to a previous board state is considered to be a pass for the sake of this rule.<br/> <br/>The winner is the player with the most territory. Alternatively, players may end the <font color=red>game</font> by agreeing on the ammont of territory that each would have in a future stable <font color=red>game</font> state.<br/>")<br/> (source "BGG")<br/> (version "1.1.14")<br/> (classification "experimental")<br/> (author "Dale W. Walton")<br/> (credit "Dale W. Walton")<br/> (date "19-11-2020")<br/> }<br/> )<br/>)<br/><br/></p></html> Player 1 to move. Unexpected syntax '(directions Cell from...' in '(set Direction (directions Ce...'. RE: Cells around a vertex - Eric Piette - 02-22-2021 Hi, (set Direction ...) is in reality to set the rotation state of a piece. So you can not use a direction in entry of that. FYI: we are going to rename that ludeme to (set Rotation ...) to be clearer. Regards, Eric RE: Cells around a vertex - dale walton - 02-23-2021 Good to know. However it was the last thing I tried. The other errors were from trying to use it in (sites Direction ... (directions ...)), and in (slide ... (directions ...)) since that was in your original example, but those were kicked out by the compiler before as syntax errors. So which ludemes use direction in the sense of rotation, and which use it in the sense of absolute direction. And in the new (directions ...) ludeme what is the data structure and kind of values created, and which ludemes is it compatible with? Other unanswered questions: 1) OffDiagonal directions for Hexagonal vertices. Do you have them, if not when? 2) The following should select the Off-diagonal vertices on a hex grid, (i.e the short diadonals of the hexes or vertexes at 2 steps distance) but does not Why? Select (from Vertex (sites Empty Vertex)) (to Vertex (sites Around Vertex ((sites Around Vertex (from) Adjacent)) Adjacent)) 3) Why doesn't the following work on the Cell-and-vertex board (ie why does (board Tri use:Vertex) need to be specified in order to make it work? (move Add (to Vertex (sites Empty Vertex) if: (= 0 (count Pieces Next in:(sites Around Vertex (to))))) 4.What is the difference between the following, and why do they require different board geometries?: (sites Cell Vertex (from)) --- this one works on the use:vertex board. (sites Incident Vertex of:Cell at:(from)) --- this one does not work on the use:vertex board. RE: Cells around a vertex - Eric Piette - 02-24-2021 Hi, The rotation state has nothing related to the direction functions. The rotation state is to modify the facing direction of a piece dynamically, you can see its use in Ploy.lud The (directions ...) function is not new, this is like that since more than half a year. AbsoluteDirection, RelativeDirection are all DirectionFunctions and some others directions functions exist (see the LGLG to see all). All the ludemes with Direction in entry can use them. However, it is possible that some ludemes are still using AbsoluteDirection alone, so in that case the directionFunction will not work for them, like that was the case for Push before the last release. For some that can be normal, but in general Direction should be in entry. For the data, that ludeme is converting any ludeme in entry to a set of absoluteDirection, then the eval method of each ludeme use them to use the steps/radials etc... 1) OffDiagonalDirection has a strict definition (see LGLG: "All directions between two cells sharing a vertex but not an edge."), this is computed for all the tilings. If you think they are not there, that's because this is probably not OffDiagonalDirection. Apparently you speak about vertices, as you can see in that definition, this is not OffDiagonal. 2) Can not answer with just that. I need a concrete example, but if this is not the right result, I guess the description is incorrect. 3) Same here. 4) The first one is returning the indices of the cells of the vertex from, the second one is returning the list of vertices of the cell from which is not the same. To expect a good and quicker answer, please use a different thread for each question with when possible an example .lud showing the issue, when you put too much questions in the same message, that becomes to hard to follow for us and often not possible to help you. Regards, Eric RE: Cells around a vertex - dale walton - 02-24-2021 Thanks for covering all the points of the 2nd post. Re #1 OffDiagonal, I can see that, but this means that this relationship exists for a given tiling, but not for it's dual. So one would expect an equivalent function: perhaps called ShortDiagonal for the directions parallel to the short diagonals of the cells. that connect alternate vertices. \ Since the "ShortDiagonal" vertex to Vertex direction is not known to the program, even though it is parallel to the known cell-to-cell direction, does using the (directions) function to obtain it work? RE: Cells around a vertex - Eric Piette - 02-25-2021 Hi, No (directions ...) can return only existing directions. Regards, Eric RE: Cells around a vertex - dale walton - 02-25-2021 OK, that is a good reason then that it would be good for this "ShortDiagonal" direction to "exist". |