Besogo
Embeddable SGF editor/viewer for the game of Go (aka Weiqi, Baduk)
Install / Use
/learn @yewang/BesogoREADME
BesoGo
Embeddable SGF player for the game of Go (aka Weiqi, Baduk)
Written in JavaScript, CSS, and HTML5, with no dependencies on other libraries
Free software released under the MIT License. Some bundled assets are copyright by other authors and available under Creative Commons licensing terms. See "Copying and License" section for further details.
User Notes
BesoGo can be used as a web-based SGF editor, an embeddable SGF viewer, or a board diagram renderer
Online usage
SGF editor based on the latest code snapshot at https://yewang.github.io/besogo/testing.html
With realistic board rendering https://yewang.github.io/besogo/testing.html?theme=wood&realstones=on
Other experimental themes include:
- https://yewang.github.io/besogo/testing.html?theme=bold
- https://yewang.github.io/besogo/testing.html?theme=book
- https://yewang.github.io/besogo/testing.html?theme=dark
SGF editor based on the latest release (lagging behind the latest snapshot) at https://yewang.github.io/besogo/stable.html
Offline usage
Download the source distribution and open testing.html
Navigation key bindings
leftprevious noderightnext nodeshift+leftprevious branching nodepage upjump back 10 nodespage downjump forward 10 nodeshomejump to first nodeendjump to last nodedeleteremove 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
OB,OW,BL,WL - Move annotations
BM,DO,IT,TE - Control annotations
KO,MN,PL - Some general annotations
DM,GB,GW,HO,N,UC,V - Some markup
AR,LN,TB,TW,DD,FG,PM,VW
- Time left
- No special validation is performed on game info properties:
PB,BR,BT,PW,WR,WT,HA,KM,RU,TM,OT,DT,EV,GN,PC,RO,ON,RE,AN,CP,SO,US. All are merely treated as "simple text" (all whitespace converted to spaces), except forGCwhich is treated as text (allowing new lines and spaces). - Some root properties (
FF,GM,CA,AP) are ignored on file input and set to fixed values on output.
Web Dev Guide
See https://yewang.github.io/besogo/ and https://yewang.github.io/besogo/fixedSize.html for some examples of how to embed BesoGo. See https://yewang.github.io/besogo/testing.html for an example full window interface for the editor.
To embed BesoGo editor/viewer in your website
- Link the style sheet
css/besogo.cssand one of thecss/board-*.csssheets, which select different board themes (simple,flat,book,dark,wood, etc.). These sheets provide essential rendering parameters and can be modified to customize the layout and style. - Include the combined and minified javascript file
besogo-all-min.js. - Add divs with the class
besogo-editor,besogo-viewer, orbesogo-diagram, e.g.,<div class="besogo-editor"></div> <div class="besogo-viewer" sgf="gameRecord.sgf"></div> <div class="besogo-diagram" panels="comment"> (;FF[4]GM[1]SZ[9]AB[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 toauto, shadows will be added for realistic stones, but not for SVG stones. If set tooff, 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 defaultnone, and can be choosen from the following options:noneno coordinate labelswesternchess-style coordinates using numbers and letterseasterncoordinates using numbers and CJK symbolsnumericcoordinates using only numberscornercorner-relative system using numbers and letterseastcorcorner-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 buttonsnamesplayer names, ranks, and capturescommentcomments and game infotoolediting tool selector buttonstreegame tree visualizationfilesave, 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 letterNornsets to next mode. The letterBorbsets 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 as20, 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 thetabindexattribute of the container div is set to0(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 toautoif not set, with the following options:autois the default responsive resizing behavior, which depends on the settings of the following companion parametersorientcan be set tolandscape,portrait,autoorviewportraitorlandscapefixes the orientation of the widget as specifiedautois the default behavior, which switches fromlandscapetoportraitif the parent container width is less thantranswidthviewis the same asauto, but also switches fromlandscapetoportraitif the parent container width is less than viewport height
transwidthsets the width to transition fromlandscapetoportraitforautoandvieworientation modes, defaulting 600 pixels if not setmaxwidthsets a limit on the maximum width, otherwise the widget will fill the width of the parent container if omittedportratiosets the height-to-width ratio forportraitmode, expressed as a percentage. Defaults to 200% if not set. If set to a truthy value that converts toNaN, then the GUI panels will have a compact automatic height.landratiosets the width-to-height ratio forlandscapemode, expressed as a percentage. Defaults to 200% if not set.minpanelswidthsets the smallest width for the GUI panels inlandscapemode, where the board and widget height would be shrunk to ensure that this minimum is met, defaulting to 350 pixels if not setminpanelsheightsets the smallest height for the GUI panels inportraitmode (if height is computed usingportratio), defaulting to 400 pixels if not set
fillis another responsive resizing behavior designed for filling and only using the entire window. It toggles between portrait and landscape modes automatically depending on the aspect ratio. It also makes use of theminpanelswidthandminpanelsheightto ensure that the panels are visible if needed and the aspect ratio is too squarish.fixedrequires the width and height of the container div to be set, as they will be accordinglynoneor any other truthy value that is notautoorfixeddisables all resizing
Code Doc
Everything is (or at
Related Skills
node-connect
337.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
337.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.2kCommit, push, and open a PR
