Embeddable SGF player for the game of Go (aka Weiqi, Baduk)
Free software released under the GNU Affero General Public License. Some bundled assets are copyright by other authors and available under Creative Commons licensing terms. See "Copying and License" section for further details.
BesoGo can be used as a web-based SGF editor, an embeddable SGF viewer, or a board diagram renderer
SGF editor based on the latest code snapshot at http://yewang.github.io/besogo/testing.html
With realistic board rendering http://yewang.github.io/besogo/testing.html?theme=wood&realstones=on
Other experimental themes include:
SGF editor based on the latest release (lagging behind the latest snapshot) at http://yewang.github.io/besogo/stable.html
Download the source distribution and open
Navigation key bindings
page upjump back 10 nodes
page downjump forward 10 nodes
homejump to first node
endjump to last node
deleteremove current branch
Shift-clicking with the auto-move/navigate tool will jump to the move that plays at that point
When entering moves, overwrite, suicide, and basic ko moves are not allowed, but can be enabled by holding down
ctrl while clicking
BesoGo supports the SGF standard for Go game records. BesoGo should always output SGF files that comply with the standard (besides the exceptions listed below). BesoGo permissively imports SGF file input, allowing many common SGF syntax errors, while attempting to fix any issues and converting to valid SGF on output.
Exceptions in SGF standard support
- Some properties are unsupported and ignored:
- Time left
- Move annotations
- Control annotations
- Some general annotations
- Some markup
- Time left
- No special validation is performed on game info properties:
US. All are merely treated as "simple text" (all whitespace converted to spaces), except for
GCwhich is treated as text (allowing new lines and spaces).
- Some root properties (
AP) are ignored on file input and set to fixed values on output.
Web Dev Guide
To embed BesoGo editor/viewer in your website
- Link the style sheet
css/besogo.cssand one of the
css/board-*.csssheets, which select different board themes (
wood, etc.). These sheets provide essential rendering parameters and can be modified to customize the layout and style.
- Add divs with the class
<div class="besogo-editor"></div> <div class="besogo-viewer" sgf="gameRecord.sgf"></div> <div class="besogo-diagram" panels="comment"> (;FFGMSZAB[bb:dd]AW[ee][ff][gg] C[This diagram shows a 9x9 board with 9 black stones and 3 white stones placed on it. Be sure to properly escape HTML special characters such as >, <, etc.])</div>
- Call the auto-initialization function
besogo.autoInit()to create widgets for the above divs.
The contents of the div should either be empty or contain SGF text. If SGF text is detected (by starting with "(;", ignoring whitespace), it will be loaded into BesoGo. BesoGo will remove all children from the div and then insert sub-divs building up the GUI.
Security Warning: If your site inserts user-input SGF text directly into the inner HTML of a div, remember to escape any HTML special characters ("<", ">", "&") to avoid XSS vulnerabilities. BesoGo will properly load the intended characters. This is not a security vulnerability within BesoGo, but rather a reminder to use secure practices in your surrounding code.
Options settable via div attributes
sgfsets the URL (from same domain or server with CORS enabled) of the SGF file to load. If an URL is provided, BesoGo ignores the text within the div.
sizesets the size of the empty board loaded if no SGF text or URL is provided. Square sizes can be specified by a single number (e.g., "19", "13") and rectangular sizes are specified by two numbers separated by a colon (e.g., "9:15"). Sizes from "1:1" to "52:52" are supported.
realstonessets board rendering to use realistic stone images if set to a truthy value. Otherwise, defaults to flat SVG stones.
shadowsselects whether shadows will be added beneath the stones. If omitted or set to
auto, shadows will be added for realistic stones, but not for SVG stones. If set to
off, shadows will not be added. If set to any other truthy value, shadows will always be added.
coordsets the initial coordinate system, which is by default
none, and can be choosen from the following options:
noneno coordinate labels
westernchess-style coordinates using numbers and letters
easterncoordinates using numbers and CJK symbols
numericcoordinates using only numbers
cornercorner-relative system using numbers and letters
eastcorcorner-relative system using numbers and CJK symbols
panelsplus-separated list of which GUI elements are added in the GUI. The following panels are supported:
controlnavigation control buttons
namesplayer names, ranks, and captures
commentcomments and game info
toolediting tool selector buttons
treegame tree visualization
filesave, load, and new board buttons
toolsets the selected tool.
variantssets the variant style, formatted as number 0-3 according to SGF standard.
pathstring to set the initial position in the game tree of the loaded SGF. The letter
nsets to next mode. The letter
bsets to branch mode. One or more digits specifies the number of nodes to move forward always taking the first child (when in next mode), or the child to select (when in branch mode). All other characters are ignored but used to separate numbers. Next is the default mode. Zero in branch mode selects the last child. Examples:
20moves to the 21st node in the mainline of the game tree, which typically contains the 20th move assuming no move in the root and no empty/setup nodes besides the root.
n5b1b1-1z1-1n10does the same as
20, but overly verbose and redundant.
b2,3,0,1navigates following the 2nd child, 3rd child, last child, and first child over four steps.
nokeysturns off navigation key bindings if set to a truthy value. Otherwise, by default, navigation keys are enabled and the
tabindexattribute of the container div is set to
0(to enable keypress focus), if not already set.
nowheelturns off mousewheel navigation if set to a truthy value. Otherwise, by default, mousewheel navigation is enabled.
resizesets the resizing behavior of the widget, defaulting to
autoif not set, with the following options:
autois the default responsive resizing behavior, which depends on the settings of the following companion parameters
orientcan be set to
landscapefixes the orientation of the widget as specified
autois the default behavior, which switches from
portraitif the parent container width is less than
viewis the same as
auto, but also switches from
portraitif the parent container width is less than viewport height
transwidthsets the width to transition from
vieworientation modes, defaulting 600 pixels if not set
maxwidthsets a limit on the maximum width, otherwise the widget will fill the width of the parent container if omitted
portratiosets the height-to-width ratio for
portraitmode, expressed as a percentage. Defaults to 200% if not set. If set to a truthy value that converts to
NaN, then the GUI panels will have a compact automatic height.
landratiosets the width-to-height ratio for
landscapemode, expressed as a percentage. Defaults to 200% if not set.
minpanelswidthsets the smallest width for the GUI panels in
landscapemode, where the board and widget height would be shrunk to ensure that this minimum is met, defaulting to 350 pixels if not set
minpanelsheightsets the smallest height for the GUI panels in
portraitmode (if height is computed using
portratio), defaulting to 400 pixels if not set
fixedrequires the width and height of the container div to be set, as they will be accordingly
noneor any other truthy value that is not
fixeddisables all resizing
Everything is (or at least should be) encapsulated within the name space object
./build.sh automatically generates the combined and minified versions (requires shell, cat, curl, and internet access)
Alternatively, you can manually combine and minify as follows
- Cobmine the js files into a single file (just ensure that
besogo.jsis first), e.g., with
cat js/* > besogo.all.js
- Use the Google Closure Compiler to minify the combined file
besogo.jsestablishes name space, core functions
createcompose the editor and GUI objects
editor.jscore editor logic managing game tree, handling input from GUI panels, and notifying GUI panels of state changes
gameRoot.jsdata structure that internally represents the game tree
boardDisplay.jsessential board display GUI panel
controlPanel.jsGUI panel for navigation control buttons
namesPanel.jsGUI panel for player names, ranks, and captures
commentPanel.jsGUI panel for comments and game info
toolPanel.jsGUI panel for tool selector buttons
treePanel.jsGUI panel for game tree visualization
filePanel.jsGUI panel for save, load, and new board buttons
coord.jsutility functions for coordinate system labels
svgUtil.jsutility functions for SVG composition
parseSgf.jsparses and extracts data structure from SGF text
loadSgf.jsloads SGF data structure into game tree
saveSgf.jscomposes SGF file from game tree data structure
CSS files in
besoso.cssdefines GUI layout and main rendering options
besogo-flat.cssdefault flat board theme
besogo-bold.cssbold board theme
besogo-book.cssbook (black and white) board theme
besogo-dark.cssdark (night mode) board theme
besogo-wood.csswood grain board theme
besogo-eidogo.cssboard theme mimicking EidoGo
besogo-glift.cssboard theme mimicking Glift
besogo-kibitz.cssboard theme mimicking GoKibitz
besogo-sensei.cssboard theme mimicking Sensei's Library
Graphical assets in
These images are used for realistic board and stone rendering
black3.pngblack stone slate textures
white10.pngwhite stone shell textures
shinkaya4.jpgshinkaya board textures
- Redesigned responsive behavior
- Added realistic stone and board rendering
- Added and modified themes
- Added mousewheel navigation
- Converted index.html to demo page, moved old index.html to stable.html
- Added fixedSize.html examples page
- Fixed minor tree panel bug
- Tweaked margin for coordinate labels slightly
- Added build script for generating combined and minified releases
- Reorganized code into folders
- Tweaked widget auto-resize behavior
- Refactored for CSS based board themes
- Removed board hover effects for touch devices (fixes iOS issues)
- History remembered during tree navigation
- Favicon added to repository
- Initial preview release
Copying and License
The following copyright and license terms only apply to the software code, which consists of all of the files excluding the contents of the
Copyright (C) 2015-2016 Ye Wang email@example.com
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program (see the LICENSE files in the source distribution). If not, see http://www.gnu.org/licenses/.
The contents of the
img/ directory are copyright by other authors and available under the license terms specified below
The following images are from the go-assets repository, available under a Creative Commons Attribution-ShareAlike 4.0 International license. Copyright (C) 2016 Andreas Tarnowsky firstname.lastname@example.org
- 4 black stone images
- 11 white stone images
The following images are from (or derived from) the jgoboard repository, available under a Creative Commons Attribution-NonCommercial 4.0 International license. Copyright (C) 2013 Joonas Pihlajamaa email@example.com
img/shinkaya1.jpgand its derivatives