About the HexWorld Interactive Hex Board

Link

https://hexworld.org/board

Usage

Board:

Buttons and menus:

Keyboard shortcuts

Sharing

Importing games from other sites

Board Game Arena

The user comonoid contributed a bookmarklet for importing a game record from Board Game Arena directly into HexWorld. To use it, copy the following text and paste it into the "URL" portion of a bookmark:

javascript:void function(){const a="https://hexworld.org/board/#";const e=window.location.href;const r=e.match(/\/table\?table=(\d+)/);const n=e.match(/\/gamereview\?table=(\d+)/);const t=e.match(/\/replay\/.*?\/\?table=\d+/);function o(e){return e.match(/\/(\d+\/hex)\?table=(\d+)/)}const i=o(e);let s="";if(typeof bgaConfig==="undefined")console.error('No "bgaConfig" variable found, cannot get the request token');else s=bgaConfig.requestToken;function c(e){let a;let i;return e.reduce((e,r)=>[...e,...r.data],[]).map(({type:e,args:r,log:n})=>{if(e==="message"&&r.size){if(r.red&&!a)a=String(r.red);else console.warn('No "args.red"');const t=r.size.match(/(\d+)x\d+/);if(t)return t[1]+"c1,"}if(e==="playToken"){if(!a)a=r.player_id;const o=i==r.player_id?":p"+r.coord:r.coord;i=r.player_id;return o}if(e==="swapPieces"){i=r.player_id;return":s"}if(e==="pass"){i=r.player_id;return":p"}if(e==="resign"||e==="playerConcedeGame"){return r.player_id==a?":rb":":rw"}}).join("")}function l(e){return fetch(window.location.origin+e,{cache:"no-cache",headers:{"X-Request-Token":s}})}function f(e){console.info(`Requesting table archives for #${e}`);return l(`/gamereview/gamereview/requestTableArchive.html?table=${e}`).then(e=>e.json()).then(e=>{if(e.status===1)return;if(e.error)throw new Error(`Error while requesting the table archive: ${e.error}`);console.warn("result.status !== 1",e)})}function d(n,e,r){const t=n?`/archive/archive/logs.html?table=${e}`:`/${r}/hex/notificationHistory.html?table=${e}&from=1&privateinc=1&history=1`;return l(t).then(e=>e.json()).then(e=>{if(String(e.status)==="0"&&e.error){throw new Error(`Error while fetching the move history: ${e.error}`)}const r=n?e.data.logs:e.data.data;console.info("Events:",r);return c(r)})}function h(r,n,t){const o=window.open("about:blank");o.document.write("<p>Loading...</p>");d(r,n,t).catch(e=>{if(e instanceof Error&&e.message.includes("Cannot find gamenotifs log file of an archived table"))return f(n).then(()=>d(r,n,t));throw e}).then(e=>{console.info(`HexWorld hash: ${e}`);o.location.href=a+e}).catch(e=>{o.close();console.error(e);window.alert(String(e))})}if(i){const u=i[1];const g=i[2];h(false,g,u);return}if(r){const g=r[1];const w=document.querySelector("#access_game_panel");if(w&&w.style.display!=="none"){const m=document.querySelector("#view_end_btn");if(!m||!m.href)return window.alert("Error: Cannot find #view_end_btn");const b=o(m.href);if(!b)return window.alert(`Cannot parse the url: ${m.href}`);h(false,b[2],b[1]);return}if(!w)console.warn("Cannot detect if the game is finished.");h(true,g);return}if(n){h(true,n[1]);return}if(t){const p=g_gamelogs;if(!p)return window.alert('Error. No "g_gamelogs" variable found.');const v=c(p);window.open(a+v);return}window.alert("No table found. Use this bookmark while viewing a Hex game on Board Game Arena.")}();

You can then use this bookmark from any Hex game on Board Game Arena. It works both for completed games and games in progress, and can be used on /hex, /table, /gamereview, or /archive/replay pages. Watch this short video to see how to set up and use the bookmarklet: Firefox, Chrome, Edge, Android.

Update 2022/05/17. The bookmarklet was updated due to a change on Board Game Arena.

Update 2023/04/28. The bookmarklet was updated due to a change on Board Game Arena. To fix an existing bookmarklet, right-click it and choose "Edit Bookmark". Then replace the contents of the URL field with the above updated code.

Little Golem

In the menu, select "Import from Little Golem" and enter the game number.

Information for developers

The URL hash field (the part after "#") contains a complete representation of the board and game state. Not all types of moves are accessible in the user interface. The syntax is:

⟨hash⟩   ::= ⟨size⟩⟨config⟩*,⟨move⟩*,⟨move⟩*  (trailing commas can be omitted)

⟨size⟩   ::= ⟨n⟩                              (board size: 1–31)
           | ⟨n⟩x⟨n⟩                          (board size: 1–31)
⟨config⟩ ::= r⟨n⟩                             (rotation: 1–12, clock direction for cell a1)
           | n                                (turn on move numbers)
           | c1                               (red-blue mode)

⟨move⟩   ::= ⟨cell⟩                           (normal move)
           | :s                               (swap pieces)
           | :S                               (swap sides)
           | :p                               (pass)
           | :rb                              (Black resigns)
           | :rw                              (White resigns)
           | :fb                              (Black forfeits)
           | :fw                              (White forfeits)

⟨n⟩ is an integer, such as 11.
⟨cell⟩ is a cell name, such as a1.

The comma in the move list indicates the current move.

The direct URL for importing a Little Golem game is https://hexworld.org/lg/?game=NNNNN, where NNNNN is the game number.

Changes

Author

© 2021–2024 Peter Selinger, selinger@mathstat.dal.ca.

With contributions from comonoid.