yewang / besogo

Embeddable SGF editor/viewer for the game of Go (aka Weiqi, Baduk)
http://yewang.github.io/besogo/
MIT License
101 stars 29 forks source link

Besogo ignores PL #29

Open tkrajina opened 2 years ago

tkrajina commented 2 years ago

I'm testing with this simple SGF:

(;GM[1]FF[4]CA[UTF-8]AP[Sabaki:0.52.0]KM[6.5]SZ[19]DT[2022-07-20]PL[W])

There are no stones and no moves yet, but PL[W] tells that the next to make a move is white.

Besogo ignores the PL and behaves like it's black's turn:

Screenshot 2022-07-20 at 18 13 13

Here's a complete example:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>BesoGo</title>

<link rel="icon" type="image/png" href="icon32.png" sizes="32x32">
<link rel="icon" type="image/png" href="icon152.png" sizes="152x152">
<link rel="icon" type="image/png" href="icon192.png" sizes="192x192">
<link rel="icon" type="image/png" href="icon512.png" sizes="512x512">
<link rel="apple-touch-icon-precomposed" href="icon152.png" sizes="152x152">
<link rel="apple-touch-icon-precomposed" href="icon192.png" sizes="192x192">
<link rel="icon" href="icon.svg" sizes="any" type="image/svg+xml">
<link rel="manifest" href="manifest.json" />
<meta name="description" content="BesoGo: a web-based SGF Editor">
<meta property="og:url" content="https://yewang.github.io/besogo/testing.html">
<meta property="og:type" content="website">
<meta property="og:title" content="BesoGo">
<meta property="og:description" content="BesoGo: a web-based SGF Editor">
<meta property="og:image" content="https://yewang.github.io/besogo/icon512.png">

<link rel="stylesheet" type="text/css" href="css/besogo.css">
<link rel="stylesheet" type="text/css" href="css/besogo-fill.css">
<link rel="stylesheet" type="text/css" href="css/board-flat.css">

<script src="js/besogo.js"></script>
<script src="js/editor.js"></script>
<script src="js/gameRoot.js"></script>
<script src="js/svgUtil.js"></script>
<script src="js/parseSgf.js"></script>
<script src="js/loadSgf.js"></script>
<script src="js/saveSgf.js"></script>
<script src="js/boardDisplay.js"></script>
<script src="js/coord.js"></script>
<script src="js/toolPanel.js"></script>
<script src="js/filePanel.js"></script>
<script src="js/controlPanel.js"></script>
<script src="js/namesPanel.js"></script>
<script src="js/commentPanel.js"></script>
<script src="js/treePanel.js"></script>

</head>
<body>
<div id="target"></div>

<script type="text/javascript">
(function() {
    const options = { resize: "fill" },
        div = document.getElementById('target'),
        params = new URLSearchParams(window.location.search);

    options.sgf = `
(;GM[1]FF[4]CA[UTF-8]AP[Sabaki:0.52.0]KM[6.5]SZ[19]DT[2022-07-20]PL[W])
`

    besogo.create(div, options);

    function addStyleLink(cssURL) {
        var element = document.createElement('link');
        element.href = cssURL;
        element.type = 'text/css';
        element.rel = 'stylesheet';
        document.head.appendChild(element);
    }
})();
</script>

</body>

</html>
yewang commented 2 years ago

Sorry, currently, the PL property is simply ignored by BesoGo (as noted in the unsupported properties in the README file). It is not even loaded into the game tree, when parsing the SGF.

It would be a nice enhancement to eventually support this property. However, I think a user interface for setting this property would also need to be considered.

Currently, the next to move in the root node is set based on how stones many of each color are set up.

As a work around, when authoring SGF files, or interacting with tsumego, one can manually play either color by using the "Set Black" or "Set White" tools and ctrl+clicking to play a stone (rather than set the stone).