From: Benjamin Auder <benjamin.auder@somewhere>
Date: Thu, 27 Dec 2018 00:22:52 +0000 (+0100)
Subject: Add traces to understand what happens in MarseilleChess about turn/subturn
X-Git-Url: https://git.auder.net/doc/html/css/scripts/%7B%7B%20asset%28%27mixstore/DESCRIPTION?a=commitdiff_plain;h=3fa426b632d92a65843038a161677069de5db27e;p=vchess.git

Add traces to understand what happens in MarseilleChess about turn/subturn
---

diff --git a/public/javascripts/components/game.js b/public/javascripts/components/game.js
index 4c369e4c..3f3b5556 100644
--- a/public/javascripts/components/game.js
+++ b/public/javascripts/components/game.js
@@ -1312,7 +1312,7 @@ Vue.component('my-game', {
 			this.endGame(this.mycolor=="w"?"0-1":"1-0");
 		},
 		newGame: function(mode, fenInit, color, oppId) {
-			const fen = fenInit || VariantRules.GenRandInitFen();
+			const fen = "nrqkbrnb/pppppppp/8/8/8/8/PPPPPPPP/RKQBNRBN w 1111 -";//fenInit || VariantRules.GenRandInitFen();
 			console.log(fen); //DEBUG
 			if (mode=="human" && !oppId)
 			{
@@ -1391,7 +1391,7 @@ Vue.component('my-game', {
 			else if (mode == "computer")
 			{
 				this.compWorker.postMessage(["init",this.vr.getFen()]);
-				this.mycolor = (Math.random() < 0.5 ? 'w' : 'b');
+				this.mycolor = "w";//(Math.random() < 0.5 ? 'w' : 'b');
 				if (this.mycolor != this.vr.turn)
 					this.playComputerMove();
 			}
@@ -1622,7 +1622,10 @@ Vue.component('my-game', {
 			if (["human","computer","friend"].includes(this.mode))
 				this.updateStorage(); //after our moves and opponent moves
 			if (this.mode == "computer" && this.vr.turn != this.mycolor && this.score == "*")
+			{
+				console.log(this.vr.moves.length + " " + this.vr.turn + " " + this.mycolor);
 				this.playComputerMove();
+			}
 		},
 		undo: function() {
 			// Navigate after game is over
diff --git a/public/javascripts/playCompMove.js b/public/javascripts/playCompMove.js
index fc69ce24..f4aeaacb 100644
--- a/public/javascripts/playCompMove.js
+++ b/public/javascripts/playCompMove.js
@@ -19,6 +19,9 @@ onmessage = function(e)
 			self.vr.play(e.data[1]);
 			break;
 		case "askmove":
+
+console.log("IN playCompMove " + self.vr.moves.length + " " + self.vr.turn);
+
 			const compMove = self.vr.getComputerMove();
 			postMessage(compMove);
 			break;
diff --git a/public/javascripts/variants/Marseille.js b/public/javascripts/variants/Marseille.js
index 618e8330..0d228b0c 100644
--- a/public/javascripts/variants/Marseille.js
+++ b/public/javascripts/variants/Marseille.js
@@ -233,7 +233,9 @@ class MarseilleRules extends ChessRules
 		const maxeval = V.INFINITY;
 		const color = this.turn;
 		const oppCol = this.getOppCol(this.turn);
-
+//if (this.moves.length == 25)
+//	debugger;
+console.log("turn before " + this.turn + " " + this.subTurn);
 		// Search best (half) move for opponent turn
 		const getBestMoveEval = () => {
 			let moves = this.getAllValidMoves();
@@ -271,11 +273,16 @@ class MarseilleRules extends ChessRules
 		};
 
 		let moves11 = this.getAllValidMoves();
+console.log("turn after " + this.turn + " " + this.subTurn);
+
+if (this.moves.length == 25)
+	debugger;
+
+
 		let doubleMoves = [];
 		// Rank moves using a min-max at depth 2
 		for (let i=0; i<moves11.length; i++)
 		{
-			moves11[i].eval = (color=="w" ? -1 : 1) * maxeval;
 			this.play(moves11[i]);
 			if (this.turn != color)
 			{
@@ -292,10 +299,66 @@ class MarseilleRules extends ChessRules
 						moves:[moves11[i],moves12[j]],
 						eval:getBestMoveEval()});
 					this.undo(moves12[j]);
+			console.log("------ after undo of " + this.getNotation(moves12[j]) + " " + this.turn + " " + this.subTurn);
 				}
 			}
 			this.undo(moves11[i]);
+
+			console.log("after undo of " + this.getNotation(moves11[i]) + " " + this.turn + " " + this.subTurn);
+
+		}
+console.log("turn interm " + this.turn + " " + this.subTurn);
+
+		for (let i=0; i<doubleMoves.length; i++)
+		{
+			if (doubleMoves[i].moves.length == 2)
+			{
+				if (this.moves.length == 1
+					&& this.getNotation(doubleMoves[i].moves[0])=="a5"
+					&& this.getNotation(doubleMoves[i].moves[1])=="h6")
+				{
+					return doubleMoves[i].moves;
+				}
+				if (this.moves.length == 5
+					&& this.getNotation(doubleMoves[i].moves[0])=="c6"
+					&& this.getNotation(doubleMoves[i].moves[1])=="Kc7")
+				{
+					return doubleMoves[i].moves;
+				}
+				if (this.moves.length == 9
+					&& this.getNotation(doubleMoves[i].moves[0])=="d6"
+					&& this.getNotation(doubleMoves[i].moves[1])=="dxe5")
+				{
+					return doubleMoves[i].moves;
+				}
+				if (this.moves.length == 13
+					&& this.getNotation(doubleMoves[i].moves[0])=="fxe6"
+					&& this.getNotation(doubleMoves[i].moves[1])=="Rxf1")
+				{
+					return doubleMoves[i].moves;
+				}
+				if (this.moves.length == 17
+					&& this.getNotation(doubleMoves[i].moves[0])=="Nb6"
+					&& this.getNotation(doubleMoves[i].moves[1])=="Bg6")
+				{
+					return doubleMoves[i].moves;
+				}
+				if (this.moves.length == 21
+					&& this.getNotation(doubleMoves[i].moves[0])=="Bxe4"
+					&& this.getNotation(doubleMoves[i].moves[1])=="Nxd3") //Bxd3
+				{
+					return doubleMoves[i].moves;
+				}
+				if (this.moves.length == 25
+					&& this.getNotation(doubleMoves[i].moves[0])=="Na4"
+					&& this.getNotation(doubleMoves[i].moves[1])=="xb6") //Nxb6
+				{
+					debugger;
+					return doubleMoves[i].moves;
+				}
+			}
 		}
+console.log("turn intermBIS " + this.turn + " " + this.subTurn);
 
 		doubleMoves.sort( (a,b) => {
 			return (color=="w" ? 1 : -1) * (b.eval - a.eval); });
@@ -306,6 +369,7 @@ class MarseilleRules extends ChessRules
 		{
 			candidates.push(i);
 		}
+console.log("turn END " + this.turn + " " + this.subTurn);
 
 		const selected = doubleMoves[_.sample(candidates, 1)].moves;
 		if (selected.length == 1)