開始研究Ludii

分享讨论IT相关的内容
回复
头像
ejsoon
圈圈精英
圈圈精英
帖子: 2230
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 98 次
被赞次数: 98 次
联系:

開始研究Ludii

帖子 ejsoon »

來自:https://ludii.games/

Ludii是一個弈棋研發平臺,你只需要把弈棋規則寫成ludeme,就可以直接跑起來,不用再去找甚麼元素和運行平臺,非常方便。

前提是,你願意去學習它的規則語法。

比如,以下是一個遊戲的ludeme:

代码: 全选

(game "Pentomino" 
    (players <Players:numPlayers>) 
    (equipment { 
        (board (rectangle <Rows:num> <Columns:num>)) 
        (tile "Z" Shared {F R F F L F})
        (tile "Y" Shared {F R F R R F R F F})
        (tile "X" Shared {F L F L L F F L L F R F})
        (tile "W" Shared {F L F R F L F})
        (tile "V" Shared {F F R F F})
        (tile "U" Shared {F L F F L F})
        (tile "T" Shared {F F R F R R F F})
        (tile "P" Shared {F F R F R F})
        (tile "N" Shared {F R F L F F})
        (tile "L" Shared {F R F F F})
        (tile "I" Shared {F F F F})
        (tile "F" Shared {F L F L L F L F R F})
        (hand Shared size:12)
        
    }) 
    (rules 
        (start {
            (place "F" (handSite Shared 0))
            (place "I" (handSite Shared 1))
            (place "L" (handSite Shared 2))
            (place "N" (handSite Shared 3))
            (place "P" (handSite Shared 4))
            (place "T" (handSite Shared 5))
            (place "U" (handSite Shared 6))
            (place "V" (handSite Shared 7))
            (place "W" (handSite Shared 8))
            (place "X" (handSite Shared 9))
            (place "Y" (handSite Shared 10))
            (place "Z" (handSite Shared 11))
        })
        (play (move (from (sites Hand Shared)) (to (sites Empty))))
        (end ("NoMoves" <End:result>))
    )
)

//------------------------------------------------------------------------------
(option "Players" <Players> args:{ <numPlayers> }
    {
    (item "2" <2> "The game is played by 2 players")*
    (item "3" <3> "The game is played by 3 players")
    }
)
(option "Rows" <Rows> args:{ <num> }
    {
    (item "1" <1> "The board has 1 row.") 
    (item "2" <2> "The board has 2 rows.") 
    (item "3" <3> "The board has 3 rows.") 
    (item "4" <4> "The board has 4 rows.") 
    (item "5" <5> "The board has 5 rows.") 
    (item "6" <6> "The board has 6 rows.")* 
    (item "7" <7> "The board has 7 rows.") 
    (item "8" <8> "The board has 8 rows.") 
    (item "9" <9> "The board has 9 rows.") 
    (item "10" <10> "The board has 10 rows.") 
    (item "11" <11> "The board has 11 rows.") 
    (item "12" <12> "The board has 12 rows.") 
    (item "13" <13> "The board has 13 rows.") 
    (item "14" <14> "The board has 14 rows.") 
    (item "15" <15> "The board has 15 rows.") 
    (item "16" <16> "The board has 16 rows.") 
    (item "17" <17> "The board has 17 rows.") 
    (item "18" <18> "The board has 18 rows.") 
    (item "19" <19> "The board has 19 rows.") 
    }
)
(option "Columns" <Columns> args:{ <num> }
    {
    (item "2" <2> "The board has 2 columns.") 
    (item "3" <3> "The board has 3 columns.") 
    (item "4" <4> "The board has 4 columns.") 
    (item "5" <5> "The board has 5 columns.") 
    (item "6" <6> "The board has 6 columns.")
    (item "7" <7> "The board has 7 columns.") 
    (item "8" <8> "The board has 8 columns.") 
    (item "9" <9> "The board has 9 columns.") 
    (item "10" <10> "The board has 10 columns.")*
    (item "11" <11> "The board has 11 columns.") 
    (item "12" <11> "The board has 12 columns.") 
    (item "13" <11> "The board has 13 columns.") 
    (item "14" <14> "The board has 14 columns.") 
    (item "15" <14> "The board has 15 columns.") 
    (item "16" <14> "The board has 16 columns.") 
    (item "17" <14> "The board has 17 columns.") 
    (item "18" <14> "The board has 18 columns.") 
    (item "19" <19> "The board has 19 columns.") 
    }
)
(option "End" <End> args:{ <result> }
    {
    (item "Normal" <Loss> "The Last player to play wins.")*
    (item "Misere" <Win> "The Last player to play loses.")
    }
)

//------------------------------------------------------------------------------

(metadata 
    
(info
{
(description "Pentomino tiling puzzles and games are popular in recreational mathematics.")
(aliases {"Golomb's Game"})
(rules "Two players have a collection of dominoes which they place on the grid in turn, covering up squares. One player places tiles vertically, while the other places them horizontally. The first player who cannot move loses.")
(id "1664")
(source "<a href=\"https://en.wikipedia.org/wiki/Pentomino\" target=\"_blank\" class=\"style1\" style=\"color: #0000EE\" />Wikipedia</a>")
(version "1.3.10")
(classification "board/space/blocking")
(credit "Fabio Barbero")
}
)
    
    (graphics {
        (piece Colour "F" fillColour:(colour 221 187 153))
        (piece Colour "I" fillColour:(colour 238 170 170))
        (piece Colour "L" fillColour:(colour 204 204 136))
        (piece Colour "N" fillColour:(colour 170 238 170))
        (piece Colour "P" fillColour:(colour 187 221 153))
        (piece Colour "T" fillColour:(colour 153 221 187))
        (piece Colour "U" fillColour:(colour 136 204 204))
        (piece Colour "V" fillColour:(colour 153 187 221))
        (piece Colour "W" fillColour:(colour 170 170 238))
        (piece Colour "X" fillColour:(colour 187 153 221))
        (piece Colour "Y" fillColour:(colour 204 136 204))
        (piece Colour "Z" fillColour:(colour 221 153 187))
    }) 
    (ai
        "Pentomino_ai"
    )
)

https://ejsoon.win/
天蒼人頡:發掘好玩事物
头像
ejsoon
圈圈精英
圈圈精英
帖子: 2230
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 98 次
被赞次数: 98 次
联系:

Fanorona Telo

帖子 ejsoon »

代码: 全选

(game "Fanorona Telo"
    (players 2) 
    (equipment {
        ("AlquerqueBoard" 3 3)
        (hand Each)
        (piece "Marker" Each "StepToEmpty")
    }) 
    (rules 
        (start (place "Marker" "Hand" count:3))
        
        phases:{
        (phase "Placement"
            (play (move (from (handSite Mover)) (to (sites Empty))))
            (nextPhase ("HandEmpty" P2) "Movement")
        )
        
        ("PhaseMovePiece" "Movement")
        }
        (end ("Line3Win"))
    )
)

//------------------------------------------------------------------------------

(metadata 
    
(info
{
(description "Fanorona Telo is a simple game of alignment played by children of the Merina people of Madagascar.")
(rules "3x3 intersecting lines with diagonals. Play occurs on the intersections of the lines. Each player has three pieces. Play begins with each player placing pieces on empty points. If they make three in a row along the lines, they win. Once all pieces are placed, players take turns moving pieces one spot to an adjacent point along the lines trying to make three in a row.
")
(source "Murray 1951: 42.")
(id "951")
(version "1.3.10")
(classification "board/space/line")
(credit "Eric Piette")
(origin "This game was played in Madagascar, around 1951.")
}
)
    
    (ai
        "Fanorona Telo_ai"
    )
)
https://ejsoon.win/
天蒼人頡:發掘好玩事物
头像
ejsoon
圈圈精英
圈圈精英
帖子: 2230
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 98 次
被赞次数: 98 次
联系:

Fanorona

帖子 ejsoon »

代码: 全选

(define "CaptureAgainIn"
    (move Select
        (from #1) 
        (to 
            (sites Around #1) 
            if:(and { 
                (not (is Visited (to))) 
                (is Empty (to)) 
                ("IsEnemyAt" (ahead #2 #3))
            })
        )
    )
)

(define "EmptyButNotVisitedWithEnemyIn"
    (and { 
        (not (is Visited (to))) 
        (is Empty (to)) 
        ("IsEnemyAt" (ahead #1 #2))
    })
)

(define "EmptyWithEnemyIn"
    (and 
        (is Empty (to)) 
        ("IsEnemyAt" (ahead #1 #2))
    )
)

(define "RemoveEnemyPiece"
    (to 
        if:("IsEnemyAt" (to)) 
        (apply (remove (to)))
    )
)

(define "MoveThePiece"
    (fromTo 
        (from (last From)) 
        (to (last To))
    ) 
)

(define "MoveAgainIn"
    (move Select
        (from #1) 
        (to 
            (sites Around #1) 
            if:("EmptyButNotVisitedWithEnemyIn" #2 #3)
        ) 
        (then 
            (and {
                "MoveThePiece" 
                (directional 
                    (from #4) 
                    #5
                    "RemoveEnemyPiece"
                ) 
                (if 
                    (can Move
                        (or 
                            ("CaptureAgainIn" #1 (to) SameDirection)
                            ("CaptureAgainIn" #1 (from) OppositeDirection)
                        )
                    )
                    (moveAgain)
                )
            })
        )
    )
)

(define "CaptureFromLast" 		
    (or 
        ("MoveAgainIn" #1 (to) SameDirection (last To) ("LastDirection" Vertex))
        ("MoveAgainIn" #1 (from) OppositeDirection (last From) (directions Vertex from:(last To) to:(last From)))
    )
)

(define "MoveIn"
    (forEach Piece 
        (move Select
            (from) 
            (to 
                (sites Around (from)) 
                if:("EmptyWithEnemyIn" #1 #2)
            ) 
            (then 
                (and 
                    "MoveThePiece" 
                    (directional
                        (from #3) 
                        #4
                        "RemoveEnemyPiece"
                    )
                ) 
            )
        ) 
        (then 
            (if 
                (can Move ("CaptureFromLast" (last To))) 
                (moveAgain)
            )
        ) 
    )
)

//------------------------------------------------------------------------------

(game "Fanorona" 
    (players 2) 
    (equipment { 
        ("AlquerqueBoard" <Board:size>)
        (piece "Marker" Each)
    }) 
    
    (rules 
        (start { 
            (place "Marker1" (union { <Board:startP1>}))
            (place "Marker2" (union { <Board:startP2>}))
        })
        
        (play
            (if "SameTurn"
                (or 
                    (if (is Occupied (last To)) 
                        ("CaptureFromLast" (last To)) 
                        ("CaptureFromLast" (last From))
                    )
                    (move Pass)
                )
                (priority {
                    (or 
                        ("MoveIn" (to) SameDirection (last To) ("LastDirection" Vertex))
                        ("MoveIn" (from) OppositeDirection (last From) (directions Vertex from:(last To) to:(last From)))
                    )
                    (forEach Piece "StepToEmpty")
                })
            )
        )
        
        (end (if (no Pieces Mover) (result Next Win)))
    )
)

//------------------------------------------------------------------------------

(option "Version" <Board> args:{ <size> <startP1> <startP2> }
    {
    (item "Telo" <3 3> <(union (sites Bottom) (sites {"C2"}))> <(union (sites {"A2"}) (sites Top))>              "The game is played on a 3x3 board") 
    (item "Dimy" <5 5> <(union (expand (sites Bottom)) (sites {"A3" "D3"}))> <(union (sites {"B3" "E3"}) (expand (sites Top)))>      "The game is played on a 5x5 board") 
    (item "Tsivy" <5 9> <(union (expand (sites Bottom)) (sites {"B3" "D3" "G3" "I3"}))> <(union (sites {"A3" "C3" "F3" "H3"}) (expand (sites Top)))> "The game is played on a 5x9 board")** 
})

//------------------------------------------------------------------------------

(metadata 
    
(info
{
(description "Fanorona is perhaps the most popular game in Madagascar. It has been documented there since the nineteenth century, but it plays a part in many Malagasy stories about their past so it likely has a much longer history there. It is often played outside, and most households in Madagascar have a Fanorona board in them.")
(rules "Fanorona-Tsivy is played on a board of 9x5 intersecting lines with diagonals. Each player has 22 pieces, starting on the intersections of the lines except in the centre position, placed on opposite rows of the board, but alternating in the central row.. Pieces move to an adjacent intersection along the lines. Players must capture pieces when possible. Capturing is accomplished by moving to an adjacent intersection to an opposing piece in the continuing direction of the capturing stones movement, or by moving away from an adjacent opposing pieces in such a direction. When an opponent's piece is captured, all other of the opponent's pieces in that line are also captured. Multiple captures can be made, but cannot be done by moving twice in the same direction. Multiple captures are optional. A player wins by capturing all of the other player's pieces.")
(source "Montgomery 1896: 151–155.")
(id "50")
(version "1.3.10")
(classification "board/war/direction/linear")
(credit "Eric Piette")
(origin "This game was played in Madagascar, around 1896.")
}
)
    
    (ai
        "Fanorona_ai"
    )
)
https://ejsoon.win/
天蒼人頡:發掘好玩事物
头像
ejsoon
圈圈精英
圈圈精英
帖子: 2230
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 98 次
被赞次数: 98 次
联系:

Ludii語法真是太難了,一個高手幫忙做了一個

帖子 ejsoon »

代码: 全选

(game "HowToPlaceNeutralPiece"
    (players 2)

    (equipment
        {
        (board (square 8))

        (regions "Central4x4" Neutral
            (difference (difference (difference (difference (sites Inner) (sites Column 1)) (sites Column 6)) (sites Row 1)) (sites Row 6))   
        )
       
        (regions "TopLeftCorner" Neutral (sites {48 56 57}))
        (regions "TopRightCorner" Neutral (sites {62 63 55}))
        (regions "BottomRightCorner" Neutral (sites {15 7 6}))
        (regions "BottomLeftCorner" Neutral (sites {1 0 8}))

        (regions "Corners" Neutral (union {(sites "TopLeftCorner") (sites "TopRightCorner") (sites "BottomRightCorner") (sites "BottomLeftCorner")}))

        (regions "PerimeterMinusCorners" Neutral (difference (sites Perimeter) (sites "Corners")))


        (piece "Dot" Neutral)

        (piece "Rook" Each)

        (piece "Pawn" Each)
        }
    )

    (rules
        phases:
            {
            (phase "FirstTwoNeutralPieces"
                (play
                    (move Add
                        (piece "Dot0")

                        (to
                            (forEach (sites "Central4x4")
                                if:
                                    (and
                                        {
                                        // can't be placed on an already occupied site
                                        (is Empty (site))
                               
                                        // cannot be collinear
                                        (= 0
                                            (count Pieces All in:(sites LineOfSight at:(site) Orthogonal))
                                        )

                                        // cannot be connect diagonally
                                        (= 0
                                            (count Pieces All in:(sites Around (site) Diagonal))
                                        )
                                        }
                                    )
                            )
                        )
                    )
                )

                (nextPhase (= (count Moves) 2) "LastFourNeutralPieces")
            )

            (phase "LastFourNeutralPieces"
                (play
                    (move Add
                        (piece "Dot0")

                        (to
                            (forEach (sites "PerimeterMinusCorners")
                                if:
                                    (and
                                        {
                                        // can't be placed on an already occupied site
                                        (is Empty (site))
                               
                                        // cannot be collinear
                                        (= 0
                                            (count Pieces All in:(sites LineOfSight at:(site) Orthogonal))
                                        )
                                        }
                                    )
                            )
                        )
                    )
                )

                (nextPhase (= (count Moves) 6) "RookPhase")
            )

            (phase "RookPhase"
                (play
                    (if
                        (= 1 (mover))

                        (move Add (piece "Rook1") (to (sites "Corners")))

                        (move Add
                            (piece "Rook2")

                            (to
                                // series of if that checks which corner is occupied by the first rook, and returns the opposite corner
                                (if
                                    (= 1 (count Pieces P1 in:(sites "TopLeftCorner")))

                                    (sites "BottomRightCorner")

                                    (if 
                                        (= 1 (count Pieces P1 in:(sites "TopRightCorner")))
                       
                                        (sites "BottomLeftCorner")

                                        (if
                                            (= 1 (count Pieces P1 in:(sites "BottomRightCorner")))
                       
                                            (sites "TopLeftCorner")
               
                                            (sites "TopRightCorner")
                                        )
                                    )
                                )
                            )
                        )
                    )
                )

                (nextPhase (= (count Moves) 8) "PawnPhase")
            )

            (phase "PawnPhase"
                (play
                    (if
                        (= 1 (mover))

                        (move Add (piece "Pawn1") (to (sites Empty)))

                        (move Add (piece "Pawn2") (to (sites Empty)))
                    )
                )
               
               (end (if (no Moves Next) (result All Draw)))
            )
            }
    )
)
https://ejsoon.win/
天蒼人頡:發掘好玩事物
头像
ejsoon
圈圈精英
圈圈精英
帖子: 2230
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 98 次
被赞次数: 98 次
联系:

chess

帖子 ejsoon »

代码: 全选

//**** Defines used to model the castling Moves. ****
(define "HasNeverMoved"
    (= (state at:(mapEntry #1 (mover))) 1) 
)

(define "PieceHasMoved"
    (set State at:#1 0) 
)

(define "RememberPieceHasMoved"
    (then 
        (if 
            (= (state at:(last To)) 1) 
            ("PieceHasMoved" (last To))
        ) 
    ) 
)

(define "KingNotCheckedAndToEmpty"
    (and 
        (is Empty (to)) 
        (not ("IsInCheck" "King" Mover at:(to)))
    ) 
)

(define "DecideToCastle"
    (move Slide 
        (from (mapEntry #1 (mover))) 
        #2 
        (between 
            (exact #3) 
            if:#4
        ) 
        (to 
            if:True
            (apply ("PieceHasMoved" (from)))
        )
        #5
    )
)

(define "CastleRook"
    (slide 
        (from (mapEntry #1 (mover))) 
        #2 
        (between 
            (exact #3) 
            if:#4
        ) 
        (to 
            if:True
            (apply ("PieceHasMoved" (from)))
        )
    )
)

(define "SmallCastling"
    ("DecideToCastle" "King" E 2 "KingNotCheckedAndToEmpty" (then ("CastleRook" "RookRight" W 2 True)))
)

(define "BigCastling"
    ("DecideToCastle" "King" W 2 "KingNotCheckedAndToEmpty" (then ("CastleRook" "RookLeft" E 3 True)))
)

(define "Castling"
    (if (and 
            ("HasNeverMoved" "King")
            (not ("IsInCheck" "King" Mover)) 
        )
        (or
            (if (and 
                    ("HasNeverMoved" "RookLeft")
                    (can Move ("CastleRook" "RookLeft" E 3 (is Empty (to))))
                )
                "BigCastling"
            )
            (if (and 
                    ("HasNeverMoved" "RookRight")
                    (can Move ("CastleRook" "RookRight" W 2 (is Empty (to))))
                )
                "SmallCastling"
            )
        )
    )
)

//**** Defines used to model the extra Pawn moves. ****
(define "SetEnPassantLocation"
    (then 
        (set Pending (ahead (last To) Backward))
    )
)

(define "InLocationEnPassant"
    (and 
        (is Pending) 
        (= (to) (value Pending)) 
    )
)

(define "EnPassant"
    (move Step 
        (directions {FR FL}) 
        (to if:"InLocationEnPassant") 
        (then 
            (remove 
                (ahead (last To) Backward)
            )
        )
    )
)

(define "InitialPawnMove"
    (if (is In (from) (sites Start (piece (what at:(from)))))
        ("DoubleStepForwardToEmpty" "SetEnPassantLocation")
    )
)

//------------------------------------------------------------------------------

(game "Chess" 
    ("TwoPlayersNorthSouth") 
    (equipment { 
        (board (square 8)) 
        
        ("ChessPawn" "Pawn"
            (or 
                "InitialPawnMove"
                "EnPassant"
            )
            (then 
                (and
                    ("ReplayInMovingOn" (sites Mover "Promotion"))
                    (set Counter)
                )
            )
        )
        ("ChessRook" "Rook" (then (set Counter)) ("RememberPieceHasMoved"))
        ("ChessKing" "King" (then (set Counter)) ("RememberPieceHasMoved"))
        ("ChessBishop" "Bishop" (then (set Counter)))
        ("ChessKnight" "Knight" (then (set Counter)))
        ("ChessQueen" "Queen" (then (set Counter)))
        
        (map "King" {(pair 1 "E1") (pair 2 "E8")})
        (map "RookLeft" {(pair 1 "A1") (pair 2 "A8")})
        (map "RookRight" {(pair 1 "H1") (pair 2 "H8")})
        (regions "Promotion" P1 (sites Top))
        (regions "Promotion" P2 (sites Bottom))
    }) 
    (rules 
        (start { 
            (place "Pawn1" (sites Row 1))
            (place "Pawn2" (sites Row 6))
            (place "Rook1" {"A1" "H1"} state:1) (place "Knight1" {"B1" "G1"}) (place "Bishop1" {"C1" "F1"}) (place "Queen1" coord:"D1") (place "King1" coord:"E1" state:1) 
            (place "Rook2" {"A8" "H8"} state:1) (place "Knight2" {"B8" "G8"}) (place "Bishop2" {"C8" "F8"}) (place "Queen2" coord:"D8") (place "King2" coord:"E8" state:1) 
        })
        
        (play 
            (if "SameTurn"
                (move Promote (last To) (piece {"Queen" "Knight" "Bishop" "Rook"}) Mover)
                (do 
                    (or 
                        (forEach Piece)
                        ("Castling")
                    )
                    ifAfterwards:(not ("IsInCheck" "King" Mover))
                )
            )
        )
        
        (end {
            ("Checkmate" "King")
            (if (or (no Moves Mover) (= (counter) 99)) (result Mover Draw)) 
        })
    )
)

//------------------------------------------------------------------------------

(metadata 
    
(info
{
(description "Ultimately originates from Indian Chaturanga, arrived in Western Europe during the Middle Ages as Shatranj. Over several centuries, after seeming experimentation with movement, the adoption of the modern movement of the queen and bishop made chess what it is today. Modern Chess appeared sometimes during the fourteenth or fifteenth Century, when the vizier piece was replaced by the queen. It since has become perhaps the most popular game in the world, with massive international competitions.")
(aliases {"Mad Queen's Chess" "Queen's Chess" "Échecs" "Schach" "Ajedrez" "Xadrez" "Scacchi"})
(rules "Played on an 8x8 board with pieces with specialized moves: Pawns (8): can move one space forward; Rooks (2): can move any number of spaces orthogonally; Bishops (2): can move any number of spaces diagonally; Knight (2): moves in any direction, one space orthogonally with one space forward diagonally; Queens (1): can move any number of spaces orthogonally or diagonally; Kings (1): can move one space orthogonally or diagonally. Players capture pieces by moving onto a space occupied by an opponent's piece. Player wins when they checkmate the other player's king.")
(source "<a href=\"https://en.wikipedia.org/wiki/Rules_of_chess\" target=\"_blank\" class=\"style1\" style=\"color: #0000EE\" />Wikipedia</a>")
(id "44")
(version "1.3.10")
(classification "board/war/replacement/checkmate/chess")
(credit "Eric Piette")
(origin "This game was played in Europe, from around 1475 to 2022.")
}
)
    
    (graphics {
        (show Check "King")
        (piece Scale "Pawn" 0.825)
        (piece Families {"Defined" "Microsoft" "Pragmata" "Symbola"})
        (board Style Chess)
    })
    
    (ai 
        "Chess_ai"
    )
    
)
https://ejsoon.win/
天蒼人頡:發掘好玩事物
头像
ejsoon
圈圈精英
圈圈精英
帖子: 2230
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 98 次
被赞次数: 98 次
联系:

bagh bandi

帖子 ejsoon »

代码: 全选

(define "CaptureAgain"
    (then 
        (if (can Move 
                ("HopCapture"
                    (from (last To)) 
                    (difference Orthogonal OppositeDirection)
                )
            )
            (moveAgain)
        )
    )	
)

//------------------------------------------------------------------------------

(game "Bagh Bandi" 
    (players 2) 
    (equipment { 
        ("AlquerqueBoardWithBottomAndTopTriangles")
        (piece "Goat" P2 "StepToEmpty")
        (piece "Tiger" P1 
            (or
                ("StepToEmpty")
                ("HopCapture"
                    ~
                    ~
                    ("CaptureAgain")
                )
            )
        )
        (regions "CentralSites" (sites {6 8 16 18}))
        (hand P1)
    }) 
    (rules 
        (start {
            (place Stack "Tiger1" (handSite P1) count:2)
            (place Stack "Goat2" 6 count:8)
            (place Stack "Goat2" 8 count:8)
            (place Stack "Goat2" 16 count:8)
            (place Stack "Goat2" 18 count:8)
        })
        phases:{
        (phase "Placement" P1 
            (play 
                (move 
                    (from (handSite P1)) 
                    (to (sites Empty)) 
                    (then (if ("HandOccupied" Mover) (moveAgain)))
                )
            ) 
            (nextPhase Mover ("HandEmpty" Mover) "Movement")
        )
        (phase "Movement" 
            (play 
                (if ("SameTurn")
                    (or 
                        ("HopCapture" 
                            (from (last To)) 
                            (difference Orthogonal OppositeDirection)
                            ("CaptureAgain")
                        )
                        (move Pass)
                    )
                    (forEach Piece top:True)
                )
            )
        )
        }
        
        (end ("NoMovesP1NoPiecesP2"))
    )
)

//------------------------------------------------------------------------------

(metadata 
    
(info
{
(description "Bagh Bandi is a hunt game played in the Lower Bengal region of South Asia. In it, two tigers attempt to capture 32 goats, and the goats attempt to trap the tigers.")
(rules "5x5 intersecting lines, with diagonals drawn in the four quadrants of the board. Two triangles, their apices intersecting the main board at opposite midpoints. The bast of the triangle is bisected by a line drawn from the apex, and this line is bisected and intersects with the other two sides of the triangle. One player plays as two tigers, which can be placed anywhere on the board, and the other player plays as 32 goats, which begin on the four central points of the quadrants of the square board, eight per stack. Players alternate turns moving a piece to an empty adjacent spot along the lines. The goats move one at a time from their stacks, and cannot be restacked once they have been moved. The tiger may capture a goat by hopping over it to an empty spot immediately on the opposite side of an adjacent goat. Multiple captures in one turn are allowed, but a tiger cannot hop over a stack of goats and hop over it again in the opposite direction. When tigers hop over a stack of goats, only one goat is captured. The goats win by blocking the tigers from being able to move; the tigers win by capturing all the goats.")
(source "Datta 1933: 407-408.")
(id "898")
(version "1.3.10")
(classification "board/hunt")
(credit "Eric Piette")
(origin "This game was played in South Asia, around 1935.")
}
)
    
    (graphics {
        (stackType 0 Count)
        (stackType 1 Count)
        (piece Families {"Abstract" "Themed"})
        (show Edges Diagonal Hidden)
        (show Symbol "disc" "CentralSites" Vertex edgeColour:(colour Black) scale:0.5)
    })
    
)
https://ejsoon.win/
天蒼人頡:發掘好玩事物
头像
ejsoon
圈圈精英
圈圈精英
帖子: 2230
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 98 次
被赞次数: 98 次
联系:

十一牛吃四狗一人棋

帖子 ejsoon »

代码: 全选

(define "ToCenter"
    (and
        (not (is In (to) (sites Top)))
        (not (is In (to) (sites Bottom)))
    )
)

//-------------------------------------------------------------------------

(game "Bison"
    (players 2)
    (equipment {
        (board (rectangle 7 11))
        (piece "Bull" P1 ("StepForwardToEmpty"))
        (piece "Colonel" P2
            (move Step Adjacent
                (to if:
                    (and
                        "ToCenter"
                        (not ("IsFriendAt" (to)))
                    )
                    (apply
                        (if ("IsEnemyAt" (to))
                            (remove (to))
                        )
                    )
                )
            )
        )
        (piece "Dog" P2
            (move Slide
                (between if:(and
                        "ToCenter"
                        (is Empty (to))
                    )
                )
            )
        )
    })
    (rules
        (start {
            (place "Bull1" (sites Bottom))
            (place "Colonel2" {"F6"})
            (place "Dog2" {"D6" "E6" "G6" "H6"})
        })
        (play (forEach Piece))
        (end {
            ("ReachWin" (sites Top) P1)
            ("BlockWin")
        })
    )
)

//-------------------------------------------------------------------------

(metadata
(info
{
(description "In Buffalo Chess, a.k.a. Bison, one player represents a villager and their dogs, who are trying to keep the village from being overrun by buffalos, controlled by the other player.")
(aliases {"Buffalo Chess" "Trespass"})
(rules "Buffalos move one step forward to a free space. Dogs move like a chess queen but cannot capture. The villager moves like a chess king, and can capture buffalos. Dogs and the villager cannot enter the top or bottom rows of the board. Buffalos start, and win by reaching the top row. They lose if they cannot move anymore.")
(id "1106")
(source "<a href=\"https://boardgamegeek.com/boardgame/32/buffalo-chess\" target=\"_blank\" class=\"style1\" style=\"color: #0000EE\" />BGG</a>")
(version "1.3.10")
(classification "board/race/reach")
(author "Alex Randolph")
(publisher "Piatnik")
(credit "Noé Falzon")
(date "1975")
}
)
    (graphics {
        (board Colour Phase0 (colour 223 178 110))
        (board Colour InnerEdges (colour Black))
        (board Colour OuterEdges (colour Black))
        (region Colour (sites Top) (colour DarkGreen))
        (region Colour (sites Bottom) (colour DarkGreen))
        (player Colour P1 (colour Brown))
        (player Colour P2 (colour LightGrey))
    })
    (ai
        "Bison_ai"
    )
)
https://ejsoon.win/
天蒼人頡:發掘好玩事物
头像
ejsoon
圈圈精英
圈圈精英
帖子: 2230
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 98 次
被赞次数: 98 次
联系:

發現一個很無聊的棋,五子長移棋,不過有我想要的移動方式

帖子 ejsoon »

代码: 全选

(define "Move" (move (from) (to (sites LineOfSight Farthest at:(from)))))

//-------------------------------------------------------------------------

(game "King's Valley"
    (players 2)
    (equipment {
        (board (square 5))
        (piece "Disc" Each "Move")
        (piece "King" Each "Move")
    })
    (rules 
        (start {
            (place "King1" (intersection (sites Bottom) (sites Column 2)))
            (place "King2" (intersection (sites Top) (sites Column 2)))
            (place "Disc1" (difference (sites Bottom) (sites Column 2)))
            (place "Disc2" (difference (sites Top) (sites Column 2)))
        })
        (play (forEach Piece))
        (end (if (is In (where "King" Mover) (sites Centre)) (result Mover Win)))
    )
)

//-------------------------------------------------------------------------

(metadata 
    
(info
{
(description "The game is played on a 5x5 board with the center square representing the King's Valley. Players start with 5 pieces on opposites sites of the board, with the center pieces being the kings.")
(rules "King's Valley is a very simple and easy game to play. This is because all the pieces move the same. Any piece can move straight horizontal, vertical or diagonal, but always as far as possible. Pieces always stop their movement either at the sides of the board or before another piece in the same row, column, or diagonal.
The winner is the first player that manages to move his king piece to the central square of the board, which represents the King's Valley.")
(id "1160")
(source "<a href=\"https://boardgamegeek.com/boardgame/86169/kings-valley\" target=\"_blank\" class=\"style1\" style=\"color: #0000EE\" />BGG</a>")
(version "1.3.10")
(classification "board/race/reach")
(author "Mitsuo Yamamoto")
(publisher "<a href=\"http://www.logygames.com/english/index.html\" target=\"_blank\" class=\"style1\" style=\"color: #0000EE\" />Logy Games</a> (used with permission)")
(credit "Eric Piette")
(date "2006")
}
)
    
    (graphics {
        (board Style Chess)
        (board Colour Phase0 (colour White))
        (board Colour Phase1 (colour VeryLightBlue))
        (board Colour OuterEdges (colour Yellow))
        (show Symbol "sun" (sites Centre) fillColour:(colour Yellow)) 
    })
    
    (ai
        "King's Valley_ai"
    )
)
https://ejsoon.win/
天蒼人頡:發掘好玩事物
头像
ejsoon
圈圈精英
圈圈精英
帖子: 2230
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 98 次
被赞次数: 98 次
联系:

Re: 開始研究Ludii

帖子 ejsoon »

ludii太難了,要不我還是放棄吧……
https://ejsoon.win/
天蒼人頡:發掘好玩事物
头像
ejsoon
圈圈精英
圈圈精英
帖子: 2230
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 98 次
被赞次数: 98 次
联系:

Blue Nile:第一個無法落子的人輸

帖子 ejsoon »

代码: 全选

(define "AdjacentNotEmptySites"
    (sites Around 
        (to) 
        if:(not (is In (to) (sites Empty)))
    )
)

//------------------------------------------------------------------------------

(game "Blue Nile" 
    (players 2) 
    (equipment { 
        (board (hex 5)) 
        (piece "Marker" Neutral) 
    }) 
    
    (rules 
        
        phases:{
        (phase "start" P1 
            (play (move Add (piece (id "Marker0")) (to (sites Empty)))) 
            (nextPhase "play")
        )
        
        (phase "play"  
            (play 
                (move Add 
                    (piece "Marker0") 
                    (to 
                        (sites Around 
                            (last To) 
                            if:(and 
                                (is Empty (to)) 
                                // not adjacent to any other piece except the last one placed.
                                ("NoSites" (difference ("AdjacentNotEmptySites") (last To)))
                            ) 
                        )
                    )
                )
            )
        )
        }
        
        (end ("NoMoves" Loss)) 
    )
)

//------------------------------------------------------------------------------

(metadata 
(info
{
(description "Invented by William Daniel Troyka in 2002, Blue Nile is a modern game played on a hexagonal board.")
(rules "Played on a hexagonal board with five spaces per side. Players take turns placing stones on an empty space. The stone must be adjacent to the last stone played but cannot be adjacent to any other. The last player to be able to make a legal move wins.")
(source "<a href=\"https://boardgamegeek.com/boardgame/33046/blue-nile\" target=\"_blank\" class=\"style1\" style=\"color: #0000EE\" />BGG</a>")
(id "381")
(version "1.3.10")
(classification "board/space/blocking")
(author "Dan Troyka")
(credit "Eric Piette")
(date "2002")
}
)
    
    (ai 
        "Blue Nile_ai"
    )
    
)
https://ejsoon.win/
天蒼人頡:發掘好玩事物
回复

在线用户

正浏览此版面之用户: 没有注册用户 和 0 访客