Fork Games Bug/ API Post

I am helping Devin create tools for the Baduk.Club and with the help of a few people in the community such as Trevoke and Devin himself we found a bug when creating forked games on the site. I assumed it is well-known but it doesn’t carry captures over to the new game made.

Another note is when creating a game through an API Post I’ve found that the forked games captures only the stones on the board in a string and uses that string to create a new game. If you use an API though you get games with illegal positions where stones are not captured.

Example 1: Test
Example 2: Test

In the examples I extracted the string of moves black and white posted then the examples happened.
After figuring out the relationship between the create a game tool and fork game tool I eventually removed captured stones manually. However there is one thing that does happened even with the correct string of moves.

Example 3: Black 17
Example 4: Black Box

Ultimately it seems that whatever interacts with the json either deletes something or misinterprets : “black”: “string of moves”,
“white”: “”
Devin was able to make a temporary fix by adding a space, and so far it hasn’t broken. It’s entirely possible it might break again but I think this last part might be on me. (I haven’t tried replicating it in reverse IE black " " white " string of moves")

My question here is how does the post/workflow interact with the string of moves when posting games? I think I can safely assume it doesn’t read or play out the moves but instead just places the stones on the board. Is there any way to fix the captures by adding a prisoners property to games? Would adding this property break forking a game?

1 Like

I’m having trouble understanding what Examples 3 and 4 are demonstrating. For example, in Ex. 4 I see on the entire border, and a single white stone in the center. What is the expected behavior?

1 Like

The expected result is the white player should place their own stone. with no white string and initial_player"white" there should be no move for white. Instead without a space the scripted places a stone automatically for white and its blacks turn. If you look at the game tree, you can see white did not start the game and black has the initial_player.

TLDR; white move string is null, script plays move for white, black plays first. check the game trees.

Ah, I think what is happening is that "null" is getting interpreted as a move string:

"nu" - invalid move, no stone is placed
"ll" - valid move corresponding to M8

I’m not sure where the "null" is coming from though. This should be an empty string.

2 Likes

Ahh, nice catch. This is probably what’s causing it. Honestly the null issue isn’t important.

More interesting to us is

  1. Forking a game doesn’t maintain captures
  2. How does OGS generate the initial board state when forking a game?

The goal here is to allow players to resume play as white and black from a historic game. This ideally we’d be able to show captures and we’d be able to just load an sgf (or we’d have access to whatever tool is parsing the sgf and turning it into a static board state)

3 Likes

Yeah unfortunately, I don’t think it works like that. I think “fork game” literally just takes the board state (as in the stones that are on the board) from the previous game and places the stones on the board as “initial state”.

Is an accurate score the main reason you want to record captures? If so, one could adjust komi when forking the game to reflect the captures? I totally realize that’s not optimal, just a thought

2 Likes

Right, I suppose the question would be what’s a good way to get the current board state from an sgf?

Good solution! I’d also come up with the same one, but as you said not optimal, but totally workable!

I suppose three low priority things to add to the massive OGS to-do list (not even needed by us but I Think Jae just wanted to make you aware)

  • OGS not interpreting null value correctly (maybe us not properly sending the api call)
  • method to fork a game from an sgf, not just a list of stones on the board
  • ability to fork a game with captures

Thanks as always for your thoughtful and helpful replies @benjito
We of the OGS community are really lucky to have you <3

2 Likes

You are too sweet @Devin_Fraze :slight_smile: The OGS (and Go community) is lucky to have you as well!

The code for how OGS does it is open source, but this code is hairy to be honest :grimacing:

I’d take a look at GoEngine.tsx. If you’re working in JS, you might be able to do something like:

import { GoEngine } from "goban";

const MY_SGF = "(;FF[4]CA[UTF-8]GM[1] ... B[pd](W[dg] ...)))"

const engine = new GoEngine({original_sgf: MY_SGF})
const board_state = engine.computeInitialStateForForkedGame();

I’d say the first one is WAI (after all, “null” is a valid move string on a 25x25 board)

The second two, I agree those should be a thing!