Twixtbot-gui: How does one make the swap move? TWIXT PP

2 replies. Last post: 2022-12-06

Reply to this topic Return to forum

Twixtbot-gui: How does one make the swap move?
  • David J Bush ★ at 2022-12-06

    I see the “allow swap” check box in the settings window. But I do not see any way to make the swap move as the second player during a game.

    I am grateful that games are saved as text files. Apparently, each move gets its own line and is not numbered. This makes the import of other games, for the purpose of analysis, a bit tedious. Is there an easier way?

    Thanks for any clue.

  • agtoever at 2022-12-06

    Hi David,

    The swapping: if the second player clicks on the peg that the first player placed, the peg is swapped.

    The export file formats: the only file format that is currently supported for saving files, is the T1J format, that doesn't have move numbers in it. If you feel confident, and you want a quick fix, it just takes two edits to add move numbers. Open file.py in the src directory.

    Go to line 39, just above the line that reads: # Handle swap and resign.
    Add the following two lines above that line (make sure you indent it identical to the lines above and below it:

    if '#' in move:
        move = move.split('#')[0]
    

    Next, navigate to around line 282 (or 284 after adding the lines above). There should be a line:

    content += [str(m).upper() for m in moves]
    

    Change this to:

    content += [str(m).upper() + '  # move ' + str(nr + 1) for nr, m in enumerate(moves)]
    

    This is not tested. Make a backup copy of file.py and test saving and loading a file before you start using this extensively.

    Hope this helps.

Return to forum

Reply to this topic