Ludii Forum
Dodgem - Printable Version

+- Ludii Forum (
+-- Forum: Suggestions (
+--- Forum: Submit Your Games (
+--- Thread: Dodgem (/showthread.php?tid=412)

Dodgem - fbarbe - 02-03-2021


Third day in a row! I'll see if I can keep this streak and write a new Ludii game every day.
Anyway, here is my implementation of the game Dodgem, from the Ludii Portal Wishlist.
I have followed the coding advice that was given to me in a previous thread, and also used the "option" ludeme for the first time. The only thing I am not entirely sure if it could be written better is the end condition, right now it performs 2 checks and I wonder if it can be written in 1.


RE: Dodgem - cambolbro - 02-03-2021


Nice work.

You don't need the second win test do you? If a player has no pieces then that should be caught by the "no moves" test. So this might suffice:

(end { (if (no Moves Next) (result Next Win)) })

Note that you could have hidden some code in the redundant "no pieces" test by using one of our known defines:

(if ("NoPiece" Mover) (result Mover Win))


RE: Dodgem - fbarbe - 02-03-2021

The issue with the only having the (no Moves Next) condition is that it only declares the winner one round after it got all the pieces out of the board, after the opponent has played. The rules state instead that a player wins as soon as they don't have any pieces or are stuck (so at the end of their turn, not the opponent's).

Is it recommended to use the defines? I sometimes find them a bit hard to read.


RE: Dodgem - Eric Piette - 02-04-2021


I just looked your .lud file.
Having only

   (if (= (count Pieces Mover) 0) (result Mover Win))

is enough.
Because having no legal moves is equivalent to having no car on the board.

For the define, that's not "recommended", that's up to the game designer. 
But in general that makes the description clearer. That can be your own define described in the files or the ones already available with the release which are in the LLR.

I am adding that game to our dev version and it will be available with the next release.
I have added some graphics metadata for it to be like in the pics I saw online, I attached the file here.