Ludii Forum
String move conversion ? - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Questions (https://ludii.games/forums/forumdisplay.php?fid=13)
+--- Forum: About Ludii (https://ludii.games/forums/forumdisplay.php?fid=14)
+--- Thread: String move conversion ? (/showthread.php?tid=168)

Pages: 1 2


RE: String move conversion ? - Quentin Cohen-Solal - 11-06-2020

Hello,

To complete my interface, I am missing two methods. The first returns a boolean if an action is a swap and the second converts a move to a string, so as to be the inverse function of getMovesFromCoordinates().

Thank you for your help.
Quentin


RE: String move conversion ? - Eric Piette - 11-09-2020

Hi Quentin,

For the first question, in the classes which are actions, you have a method isSwap() doing what you want.

For the second one, we are currently provided 3 formats for the moves. What you ask is really close to the Turn format (method toTurnFormat(Context context) in Move.java. You should try to use that and if necessary to modify the output like you need it.

Regards,
Eric


RE: String move conversion ? - Quentin Cohen-Solal - 11-13-2020

Hello,

I have a problem with swap. I have a feeling that the createSwapMove() method is not sufficient for what I want to do (play Hex automatically). I guess what's wrong is that the swap action has to be stacked with a change of active player. It would then be necessary either that createSwapMove() additionally changes the active player (with an option in parameter, for example) or that I have a way to have the action which changes the current player and a method to concatenate a move to this change of player. I'm assuming the last procedure is already implemented. If my guess is right, how can I solve my problem?

Thank you so much.
Regards.


RE: String move conversion ? - Eric Piette - 11-16-2020

Hi Quentin,

Yes that method is not used by our code, but in the code the next player has to be set to the mover and was not, I fixed it.


However, you can create yourself the method you need in your code. Here is the code:

Code:
/**
* @param moverĀ  The player who is expected to make this move.
* @param player1 The player 1 to swap.
* @param player2 The player 2 to swap.
* @return A new swap move.
*/
public static Move createSwapMove(final int mover, final int player1, final int player2)
{
    final ActionSwap actionSwap = new ActionSwap(player1, player2);
    actionSwap.setDecision(true);
    final Move swapMove = new Move(actionSwap);
    swapMove.actions().add(new ActionSetNextPlayer(mover));
    swapMove.setMover(mover);
    return swapMove;
}

Regards,
Eric