How to update the score? - Printable Version +- Ludii Forum (https://ludii.games/forums) +-- Forum: Problems (https://ludii.games/forums/forumdisplay.php?fid=5) +--- Forum: Game Problems (https://ludii.games/forums/forumdisplay.php?fid=17) +--- Thread: How to update the score? (/showthread.php?tid=1624) |
How to update the score? - Alain Busser - 07-26-2023 Hello, I programmed this game: Code: (game "alquerkonane" 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
Code: (if (no Moves Mover) 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 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? RE: How to update the score? - Michael - 07-26-2023 I'm not one of the developers, and I don't know why this happens, but here is something else to try while waiting for an answer: Use (not (can Move …)) instead. RE: How to update the score? - dale walton - 07-27-2023 Might have to do with who is "Prev" if the last move was a pass? You could try (addScore (player (- 3 (mover))) 1) The system supplied passes may skip all execution given that no move is possible, so you may need to allow an explicit pass move. Since this is meant as a forced situation, use (priority) instead of (or) to offer it Possibly like this: - (move Pass (then ....)) might also work. (priority (... the normal move ... )) (do (addscore Next 1) next:(move Pass) )) Since passing becomes a move in this scenario the end condition cannot be (no Moves ...) You would need to use (all Passed) There may be other ways to accomplish this. However, if you haven't set score as a weighted heuristic I don't think the AI will pay attention anyway, as the score is not part of the winning condition. If you do set score as a heuristic in the AI definition, you may need to have some other heuristic to balance it, for cases where a player gets blocked and later unblocked for example. RE: How to update the score? - fuerchter - 07-27-2023 Hi, here's an updated .lud using dale's suggestions. And here is a comparison of the changes made. Notes: 1. I changed ("TwoPlayersNorthSouth") so players could move forwards instead of backwards. I assume you wrote it like this because of a confusion between where players are facing versus where their starting position is? If this is not the case, feel free to change it back. 2. I added a condition "(if (= (score Mover) 0) ..." to (addScore) because otherwise the winner's final pass would always give their opponent score 1. EDIT: Having thought about this again, I think it'd make more sense if you replace this with "(if (not (all Passed)) (addScore Next 1))" 3. I changed the ending because in combination with dale's (priority) suggestion the old ending would lead to draws. As dale said, the AI likely won't play to optimize that score though. |