07-26-2023, 02:43 PM
(This post was last modified: 07-26-2023, 05:05 PM by Alain Busser.)
Hello, I programmed this game:
and as I would like to find an AI based on the number of free moves for the winner, I added a score to each player, so that
and it almost works. Sometimes when the loser passes the other one gets one more point on his score. Sometimes... but not always! For examples if each player uses an alpha-beta pruning the game ends like this:
Sometimes there is "Pass" and sometimes there is only a dot. The score is not incremented when there is "Pass". So I guess I need to pass on Pass, but I did not find out how I could do that.
Any idea?
Code:
(game "alquerkonane"
("TwoPlayersNorthSouth")
(equipment
{
(board (rectangle <Rows:num> <Columns:num>))
(piece "Ball"
Each
(if (no Moves Mover)
(addScore Prev 1)
(or
(move Step (directions { BL BR }) (to if:(is Empty (to))))
(move
Hop
(between
if:(is Enemy (who at:(between)))
(apply (remove (between)))
)
(to if:(is Empty (to)))
)
)
)
)
}
)
(rules
(start
{
(set Score Each 0)
(place
"Ball2"
(intersection
(sites Phase 0)
(expand (sites Bottom) steps:1)
)
)
(place
"Ball1"
(intersection
(sites Phase 1)
(expand (sites Top) steps:1)
)
)
}
)
(play (forEach Piece))
(end (if
(and
(no Moves Mover)
(no Moves Next)
)
(result Mover Win))
)
)
)
(option "Rows" <Rows> args:{ <num> }
{
(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.")
}
)
(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.")
}
)
(metadata
(info
{
(description "Take the opponent's pieces or be the last to move a pawn.")
(aliases {"The reunionese checkers"})
(rules "Checkers without promotion. The winner is the last to move. One can move a pawn diagonally or hop orthogonally over an opponent's pawn, taking it.")
(source "https://iremi.univ-reunion.fr/spip.php?article1165")
(version "1.1.1")
(classification "board/war/leaping/diagonal")
(author "anonymous creole")
(credit "Alain Busser 7/21/2023")
(origin "This game is from Reunion Island, on 2016.")
}
)
(graphics (board Style Chess))
)
and as I would like to find an AI based on the number of free moves for the winner, I added a score to each player, so that
- The game is not ended when one player (the loser) has no moves, but when no player has no moves at all.
- Until the game is ended, every time a player cannot move, he increments the other player's score.
Code:
(if (no Moves Mover)
(addScore Prev 1) (or ...))
and it almost works. Sometimes when the loser passes the other one gets one more point on his score. Sometimes... but not always! For examples if each player uses an alpha-beta pruning the game ends like this:
Code:
Turn 24. B4-C5
Turn 25. Pass
Turn 26. C3-B4
Turn 27. .
Turn 28. B4-A5
Turn 29. Pass
Turn 30. C5-B6
Turn 31. .
Turn 32. Pass
Sometimes there is "Pass" and sometimes there is only a dot. The score is not incremented when there is "Pass". So I guess I need to pass on Pass, but I did not find out how I could do that.
Any idea?