From: Benjamin Auder Date: Wed, 4 Mar 2020 15:12:30 +0000 (+0100) Subject: Experimental symmetric randomness + deterministic option X-Git-Url: https://git.auder.net/game/current/%7B%7B%20asset%28%27mixstore/css/user/DESCRIPTION?a=commitdiff_plain;h=7ba4a5bc5b64e19a1e7f26aa232d5c50770d07ad;p=vchess.git Experimental symmetric randomness + deterministic option --- diff --git a/TODO b/TODO index ab06e20a..7e9c4834 100644 --- a/TODO +++ b/TODO @@ -7,14 +7,6 @@ From MyGames page: send "mconnect" to all online players (me included: potential When quit, send mdisconnect (relayed by server if no other MyGames tab). And remove current "notify through newmove" on server in sockets.js -Analyse mode when launched from a position: should keep orientation ---> $route query param, "side=w or b" - -Subcursor (intra move) for multi-move variants for better navigation (in BaseGame) - -Allow symmetric mode in all variants (vertical symmetry for racing kings) -flag in challenge, "Symmetric: true / false", option of GenRandInitFen() - # Misc: Saw once a "double challenge" bug, one anonymous and a second one logged Both were asked a challenge probably, and both challenges added as different ones. diff --git a/client/src/base_rules.js b/client/src/base_rules.js index 5b335b0f..93772b9b 100644 --- a/client/src/base_rules.js +++ b/client/src/base_rules.js @@ -238,11 +238,21 @@ export const ChessRules = class ChessRules { ///////////// // FEN UTILS - // Setup the initial random (assymetric) position - static GenRandInitFen() { + // Setup the initial random (asymmetric) position + static GenRandInitFen(randomness) { + if (!randomness) randomness = 2; + if (randomness == 0) + // Deterministic: + return "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w 0 1111 -"; + let pieces = { w: new Array(8), b: new Array(8) }; - // Shuffle pieces on first and last rank + // Shuffle pieces on first (and last rank if randomness == 2) for (let c of ["w", "b"]) { + if (c == 'b' && randomness == 1) { + pieces['b'] = pieces['w']; + break; + } + let positions = ArrayFun.range(8); // Get random squares for bishops diff --git a/client/src/components/BaseGame.vue b/client/src/components/BaseGame.vue index 2a1a4474..4af4e153 100644 --- a/client/src/components/BaseGame.vue +++ b/client/src/components/BaseGame.vue @@ -227,11 +227,13 @@ export default { this.lastMove = null; }, analyzePosition: function() { - const newUrl = + let newUrl = "/analyse/" + this.game.vname + "/?fen=" + this.vr.getFen().replace(/ /g, "_"); + if (this.game.mycolor) + newUrl += "&side=" + this.game.mycolor; // Open in same tab in live games (against cheating) if (this.game.type == "live") this.$router.push(newUrl); else window.open("#" + newUrl); @@ -337,7 +339,7 @@ export default { } }; const playMove = () => { - const animate = V.ShowMoves == "all" && received; + const animate = V.ShowMoves == "all" && (received || navigate); if (!Array.isArray(move)) move = [move]; let moveIdx = 0; let self = this; diff --git a/client/src/components/ChallengeList.vue b/client/src/components/ChallengeList.vue index a350c705..7572ede1 100644 --- a/client/src/components/ChallengeList.vue +++ b/client/src/components/ChallengeList.vue @@ -6,6 +6,7 @@ div th {{ st.tr["Variant"] }} th {{ st.tr["With"] }} th {{ st.tr["Cadence"] }} + th {{ st.tr["Random?"] }} tbody tr( v-for="c in sortedChallenges" @@ -15,6 +16,7 @@ div td {{ c.vname }} td {{ withWho(c) }} td {{ c.cadence }} + td(:class="getRandomnessClass(c)")