[Scummvm-git-logs] scummvm master -> 5d239aa5c8108318931c876bd485d3145a109e14

Die4Ever 30947252+Die4Ever at users.noreply.github.com
Sun Oct 24 22:19:14 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
5d239aa5c8 GROOVIE: T11H added tests for cake and triangle


Commit: 5d239aa5c8108318931c876bd485d3145a109e14
    https://github.com/scummvm/scummvm/commit/5d239aa5c8108318931c876bd485d3145a109e14
Author: Die4Ever (die4ever2005 at gmail.com)
Date: 2021-10-24T17:18:59-05:00

Commit Message:
GROOVIE: T11H added tests for cake and triangle

Changed paths:
    engines/groovie/detection.cpp
    engines/groovie/groovie.h
    engines/groovie/logic/beehive.cpp
    engines/groovie/logic/cake.cpp
    engines/groovie/logic/cake.h
    engines/groovie/logic/tlcgame.cpp
    engines/groovie/logic/triangle.cpp
    engines/groovie/logic/triangle.h


diff --git a/engines/groovie/detection.cpp b/engines/groovie/detection.cpp
index e162bb9e04..e37fad4466 100644
--- a/engines/groovie/detection.cpp
+++ b/engines/groovie/detection.cpp
@@ -41,9 +41,8 @@ static const DebugChannelDef debugFlagList[] = {
 	{Groovie::kDebugCursor, "Cursor", "Debug cursor decompression / switching"},
 	{Groovie::kDebugMIDI, "MIDI", "Debug MIDI / XMIDI files"},
 	{Groovie::kDebugScriptvars, "Scriptvars", "Print out any change to script variables"},
-	{Groovie::kDebugCell, "Cell", "Debug the cell game (in the microscope)"},
+	{Groovie::kDebugLogic, "Logic", "Debug the AI puzzles in the logic folder and TLC questionnaires"},
 	{Groovie::kDebugFast, "Fast", "Play videos quickly, with no sound (unstable)"},
-	{Groovie::kDebugTlcGame, "TLCGame", "Debug the questionnaires in TLC"},
 	DEBUG_CHANNEL_END
 };
 
diff --git a/engines/groovie/groovie.h b/engines/groovie/groovie.h
index 1171abcf5d..d6451855fb 100644
--- a/engines/groovie/groovie.h
+++ b/engines/groovie/groovie.h
@@ -67,9 +67,9 @@ enum DebugLevels {
 	kDebugCursor = 1 << 5,
 	kDebugMIDI = 1 << 6,
 	kDebugScriptvars = 1 << 7,
-	kDebugCell = 1 << 8,
+	kDebugLogic = 1 << 8,
 	kDebugFast = 1 << 9,
-	kDebugTlcGame = 1 << 10
+	//kDebugTlcGame = 1 << 10
 	// the current limitation is 32 debug levels (1 << 31 is the last one)
 	// but some are used by system, so avoid high values.
 };
diff --git a/engines/groovie/logic/beehive.cpp b/engines/groovie/logic/beehive.cpp
index d097bb795b..6638ed2bfb 100644
--- a/engines/groovie/logic/beehive.cpp
+++ b/engines/groovie/logic/beehive.cpp
@@ -46,7 +46,7 @@ void BeehiveGame::run(byte *scriptVariables) {
 		kBeehiveColorRed = 1
 	};
 
-	debugC(1, kDebugScript, "Beehive subop %d", op);
+	debugC(1, kDebugLogic, "Beehive subop %d", op);
 
 	int8 v21, v22, v24;
 	int8 tempState[64];
diff --git a/engines/groovie/logic/cake.cpp b/engines/groovie/logic/cake.cpp
index ebc4eaa4e7..144849d3c1 100644
--- a/engines/groovie/logic/cake.cpp
+++ b/engines/groovie/logic/cake.cpp
@@ -81,6 +81,8 @@ CakeGame::CakeGame() : _random("CakeGame") {
 			numLines++;
 		}
 	}
+
+	testCake();
 }
 
 void CakeGame::run(byte *scriptVariables) {
@@ -315,4 +317,99 @@ byte CakeGame::aiGetBestMove(int search_depth) {
 	return best_move;
 }
 
+void CakeGame::testCake() {
+	warning("starting CakeGame::testCake()");
+	// test the draw condition, grouped by column
+	runCakeTestNoAi(/*move 1*/ "7777777" /*8*/ "6666666" /*15*/ "5555555" /*22*/ "34444444" /*30*/ "333333" /*36*/ "2222222" /*43*/ "01111111" /*51*/ "000000", false, true);
+
+	runCakeTest(9, "24223233041", true);
+	runCakeTest(1, "232232432445", false);
+	runCakeTest(123, "4453766355133466", false);
+
+	warning("finished CakeGame::testCake()");
+}
+
+void CakeGame::runCakeTestNoAi(const char *moves, bool playerWin, bool draw = false) {
+	warning("starting runCakeTestNoAi(%s, %d)", moves, (int)playerWin);
+
+	restart();
+
+	for (int i = 0; moves[i]; i++) {
+		byte win = getWinner();
+		if (win) {
+			error("early win at %d, winner: %d", i, (int)win);
+		}
+		if (gameEnded()) {
+			error("early draw at %d", i);
+		}
+		byte move = moves[i] - '0';
+		placeBonBon(move);
+	}
+
+	byte winner = getWinner();
+	if (draw) {
+		if (winner != 0 || !gameEnded())
+			error("wasn't a draw! winner: %d, gameover: %d", (int)winner, (int)gameEnded());
+	} else if (playerWin && winner != PLAYER) {
+		error("player didn't win! winner: %d", (int)winner);
+	} else if (playerWin == false && winner != STAUF) {
+		error("Stauf didn't win! winner: %d", (int)winner);
+	}
+
+	warning("finished runCakeTestNoAi(%s, %d), winner: %d", moves, (int)playerWin, (int)winner);
+}
+
+void CakeGame::runCakeTest(uint seed, const char *moves, bool playerWin) {
+	warning("starting runCakeTest(%u, %s, %d)", seed, moves, (int)playerWin);
+
+	// first fill the board with the expected moves and test the win-detection function by itself without AI
+	runCakeTestNoAi(moves, playerWin);
+
+	restart();
+
+	byte vars[1024];
+	memset(vars, 0, sizeof(vars));
+	byte &lastMove = vars[1];
+	byte &winner = vars[3];
+	winner = 0;
+	lastMove = 8;
+	run(vars);
+
+	uint old_seed = _random.getSeed();
+	_random.setSeed(seed);
+
+	for (int i = 0; moves[i]; i += 2) {
+		if (winner != 0) {
+			error("early win at %d, winner: %d", i, (int)winner);
+		}
+		lastMove = moves[i] - '0';
+		byte stauf_move = moves[i + 1] - '0';
+
+		run(vars);
+
+		if (stauf_move < 8) {
+			if (winner == 2) {
+				error("early player win at %d", i);
+			}
+
+			if (stauf_move != lastMove) {
+				error("incorrect Stauf move, expected: %d, got: %d", (int)stauf_move, (int)lastMove);
+			}
+		} else if (winner != 2) {
+			error("missing Stauf move, last_move: %d", (int)lastMove);
+		} else
+			break;
+	}
+
+	if (playerWin && winner != 2) {
+		error("player didn't win! winner: %d", (int)winner);
+	} else if (playerWin == false && winner != 1) {
+		error("Stauf didn't win! winner: %d", (int)winner);
+	}
+
+	_random.setSeed(old_seed);
+
+	warning("finished runCakeTest(%u, %s, %d)", seed, moves, (int)playerWin);
+}
+
 } // End of Groovie namespace
diff --git a/engines/groovie/logic/cake.h b/engines/groovie/logic/cake.h
index a60839d519..b3767c6585 100644
--- a/engines/groovie/logic/cake.h
+++ b/engines/groovie/logic/cake.h
@@ -83,6 +83,9 @@ private:
 	int aiRecurse(int search_depth, int parent_score);
 	uint rng();
 	byte aiGetBestMove(int search_depth);
+	void testCake();
+	void runCakeTest(uint seed, const char *moves, bool player_win);
+	void runCakeTestNoAi(const char *moves, bool player_win, bool draw);
 };
 
 } // End of Groovie namespace
diff --git a/engines/groovie/logic/tlcgame.cpp b/engines/groovie/logic/tlcgame.cpp
index 55b3a8751b..f5ca482b66 100644
--- a/engines/groovie/logic/tlcgame.cpp
+++ b/engines/groovie/logic/tlcgame.cpp
@@ -98,13 +98,13 @@ void TlcGame::handleOp(uint8 op) {
 // This function is mainly for debugging purpose
 void inline TlcGame::setScriptVar(uint16 var, byte value) {
 	_scriptVariables[var] = value;
-	debugC(5, kDebugTlcGame, "script variable[0x%03X] = %d (0x%04X)", var, value, value);
+	debugC(5, kDebugLogic, "script variable[0x%03X] = %d (0x%04X)", var, value, value);
 }
 
 void inline TlcGame::setScriptVar16(uint16 var, uint16 value) {
 	_scriptVariables[var] = value & 0xFF;
 	_scriptVariables[var + 1] = (value >> 8) & 0xFF;
-	debugC(5, kDebugTlcGame, "script variable[0x%03X, 0x%03X] = %d (0x%02X, 0x%02X)", var, var+1, value, _scriptVariables[var], _scriptVariables[var+1]);
+	debugC(5, kDebugLogic, "script variable[0x%03X, 0x%03X] = %d (0x%02X, 0x%02X)", var, var+1, value, _scriptVariables[var], _scriptVariables[var+1]);
 }
 
 uint16 inline TlcGame::getScriptVar16(uint16 var) {
@@ -141,7 +141,7 @@ void TlcGame::regionsInit() {
 
 	// Check if header was already loaded.
 	if (_regionHeader != NULL) {
-		debugC(1, kDebugTlcGame, "TLC:RegionsInit: Regions already loaded.");
+		debugC(1, kDebugLogic, "TLC:RegionsInit: Regions already loaded.");
 		return;
 	}
 
@@ -171,7 +171,7 @@ void TlcGame::regionsInit() {
 
 	delete regionsfile;
 
-	debugC(1, kDebugTlcGame, "TLC:RegionsInit: Loaded %d region headers", _numRegionHeaders);
+	debugC(1, kDebugLogic, "TLC:RegionsInit: Loaded %d region headers", _numRegionHeaders);
 }
 
 
@@ -220,7 +220,7 @@ void TlcGame::regionsLoad() {
 
 			delete regionsfile;
 
-			debugC(1, kDebugTlcGame, "TLC:RegionsLoad: Loaded %d regions for question %s", _curQuestNumAnswers, questName);
+			debugC(1, kDebugLogic, "TLC:RegionsLoad: Loaded %d regions for question %s", _curQuestNumAnswers, questName);
 			return;
 		}
 	}
@@ -279,7 +279,7 @@ void TlcGame::opExitPoll() {
 		_epScoreBin[4] = _scriptVariables[1];
 		_epScoreBin[5] = _scriptVariables[2];
 		setScriptVar(0, 0x09);
-		debugC(1, kDebugTlcGame, "TLC:EpInitBins: Init bins: bin[4]=%d, bin[5]=%d", _epScoreBin[4], _epScoreBin[5]);
+		debugC(1, kDebugLogic, "TLC:EpInitBins: Init bins: bin[4]=%d, bin[5]=%d", _epScoreBin[4], _epScoreBin[5]);
 
 		break;
 	default:
@@ -358,7 +358,7 @@ void TlcGame::epInit() {
 	// Return code
 	setScriptVar(0, 0x09);
 
-	debugC(1, kDebugTlcGame, "TLC:EpInit: For episode %d loaded %d question scores. Will play %d questions", _epEpisodeIdx+1, _epQuestionsInEpisode, kTlcEpQuestToPlay[_epEpisodeIdx]);
+	debugC(1, kDebugLogic, "TLC:EpInit: For episode %d loaded %d question scores. Will play %d questions", _epEpisodeIdx+1, _epQuestionsInEpisode, kTlcEpQuestToPlay[_epEpisodeIdx]);
 }
 
 
@@ -472,10 +472,10 @@ void TlcGame::epSelectNextQuestion() {
 			_epQuestionNumOfPool = _random.getRandomNumber(32767) / 2000;
 		} while (_epQuestionNumOfPool < 1 || _epQuestionNumOfPool > _epQuestionsInEpisode);
 
-		debugC(1, kDebugTlcGame, "TLC:EpSelNextQuest: Question %d: Selected question %d/%d by random.", _epQuestionIdx, _epQuestionNumOfPool, _epQuestionsInEpisode);
+		debugC(1, kDebugLogic, "TLC:EpSelNextQuest: Question %d: Selected question %d/%d by random.", _epQuestionIdx, _epQuestionNumOfPool, _epQuestionsInEpisode);
 
 	} else {
-		debugC(1, kDebugTlcGame, "TLC:EpSelNextQuest: Question %d: Selected question %d/%d by predefined data.", _epQuestionIdx, _epQuestionNumOfPool, _epQuestionsInEpisode);
+		debugC(1, kDebugLogic, "TLC:EpSelNextQuest: Question %d: Selected question %d/%d by predefined data.", _epQuestionIdx, _epQuestionNumOfPool, _epQuestionsInEpisode);
 	}
 
 	// Choose next question, if question was already played
@@ -486,7 +486,7 @@ void TlcGame::epSelectNextQuestion() {
 		}
 	}
 	_epQuestionsData[_epQuestionNumOfPool - 1].questionUsed = true;
-	debugC(1, kDebugTlcGame, "TLC:EpSelNextQuest: Question %d: Forward to question %d/%d. (used-flag)", _epQuestionIdx, _epQuestionNumOfPool, _epQuestionsInEpisode);
+	debugC(1, kDebugLogic, "TLC:EpSelNextQuest: Question %d: Forward to question %d/%d. (used-flag)", _epQuestionIdx, _epQuestionNumOfPool, _epQuestionsInEpisode);
 
 	// write selected episode and question to script variables
 	setScriptVar(4, (_epEpisodeIdx + 1) / 10);
@@ -500,7 +500,7 @@ void TlcGame::epSelectNextQuestion() {
 	// Debug output
 	{
 		uint32 dbgQScore = _epQuestionsData[_epQuestionNumOfPool - 1].questionScore;
-		debugC(1, kDebugTlcGame, "TLC:EpSelNextQuest: Bins for Answers: %d %d %d %d %d %d %d %d",
+		debugC(1, kDebugLogic, "TLC:EpSelNextQuest: Bins for Answers: %d %d %d %d %d %d %d %d",
 			(dbgQScore >> 28) & 0xf, (dbgQScore >> 24) & 0xf, (dbgQScore >> 20) & 0xf, (dbgQScore >> 16) & 0xf,
 			(dbgQScore >> 12) & 0xf, (dbgQScore >> 8) & 0xf, (dbgQScore >> 4) & 0xf, (dbgQScore) & 0xf);
 	}
@@ -617,7 +617,7 @@ void TlcGame::epResultQuestion() {
 	// Add value of register 3 (answer register) to spezial register
 	if (specialReg >= 0) {
 		setScriptVar(specialReg, _scriptVariables[specialReg] + _scriptVariables[3]);
-		debugC(1, kDebugTlcGame, "TLC:EpResultQuest: Question: %d vars[0x%02x] += %d. New Value: %d", _epQuestionIdx, specialReg, _scriptVariables[3], _scriptVariables[specialReg]);
+		debugC(1, kDebugLogic, "TLC:EpResultQuest: Question: %d vars[0x%02x] += %d. New Value: %d", _epQuestionIdx, specialReg, _scriptVariables[3], _scriptVariables[specialReg]);
 	}
 
 
@@ -632,7 +632,7 @@ void TlcGame::epResultQuestion() {
 
 	_epScoreBin[scoreBinId] = _epScoreBin[scoreBinId] + 1;
 
-	debugC(1, kDebugTlcGame, "TLC:EpResultQuest: Answer: %d -> Inc bin[%d] -> bin[0..5] = %d, %d, %d, %d, %d, %d", 
+	debugC(1, kDebugLogic, "TLC:EpResultQuest: Answer: %d -> Inc bin[%d] -> bin[0..5] = %d, %d, %d, %d, %d, %d", 
 		answerIdx+1, scoreBinId, _epScoreBin[0], _epScoreBin[1], _epScoreBin[2], _epScoreBin[3], _epScoreBin[4], _epScoreBin[5]);
 }
 /*
@@ -647,7 +647,7 @@ void TlcGame::epResultEpisode() {
 	int    i;
 
 	/* keep only the maxium scores of bin[1], bin[2], bin[3]. -> Set all other to 0 */
-	debugCN(1, kDebugTlcGame, "TLC:EpResultEpisode: bins[1..3] = %d, %d, %d ", _epScoreBin[1], _epScoreBin[2], _epScoreBin[3]);
+	debugCN(1, kDebugLogic, "TLC:EpResultEpisode: bins[1..3] = %d, %d, %d ", _epScoreBin[1], _epScoreBin[2], _epScoreBin[3]);
 	maxBinValue = _epScoreBin[1];
 	for (i = 2; i < 4; i++) {
 		if (maxBinValue < _epScoreBin[i]) {
@@ -659,7 +659,7 @@ void TlcGame::epResultEpisode() {
 			_epScoreBin[i] = 0;
 		}
 	}
-	debugC(1, kDebugTlcGame, "-> bins[1..3] = %d, %d, %d ", _epScoreBin[1], _epScoreBin[2], _epScoreBin[3]);
+	debugC(1, kDebugLogic, "-> bins[1..3] = %d, %d, %d ", _epScoreBin[1], _epScoreBin[2], _epScoreBin[3]);
 
 	/* Select next stream according to which bin(s) are still >0. */
 	if (_epScoreBin[1] != 0 && _epScoreBin[2] == 0 && _epScoreBin[3] == 0) {
@@ -680,7 +680,7 @@ void TlcGame::epResultEpisode() {
 		error("Tlc:EpResultEpisode: Stream selection failed. bins[0..5] = %d, %d, %d, %d, %d, %d",
 			  _epScoreBin[0], _epScoreBin[1], _epScoreBin[2], _epScoreBin[3], _epScoreBin[4], _epScoreBin[5]);
 	}
-	debugC(1, kDebugTlcGame, "Selected stream [1..3] = %d ", _scriptVariables[3]);
+	debugC(1, kDebugLogic, "Selected stream [1..3] = %d ", _scriptVariables[3]);
 
 	/* save bin values of bin[4..5] to script variables */
 	setScriptVar(1, _epScoreBin[4]);
@@ -704,7 +704,7 @@ void TlcGame::opFlags() {
 				_tatFlags[x][y] = 0;
 			}
 		}
-		debugC(1, kDebugTlcGame, "Tlc:TatFlags: Initialized fields (%d, %d)", x, y);
+		debugC(1, kDebugLogic, "Tlc:TatFlags: Initialized fields (%d, %d)", x, y);
 		break;
 
 	// Get and set flags
@@ -727,7 +727,7 @@ void TlcGame::opFlags() {
 			setScriptVar(0x01, 0);
 			_tatFlags[x][y] = 1;
 
-			debugC(1, kDebugTlcGame, "Tlc:TatFlags: Set x=%d, y=%d to 1", x, y);
+			debugC(1, kDebugLogic, "Tlc:TatFlags: Set x=%d, y=%d to 1", x, y);
 
 			debugTatFlags(0, 1);
 			debugTatFlags(2, 3);
@@ -749,7 +749,7 @@ void TlcGame::debugTatFlags(int y1, int y2) {
 		s2 += int(_tatFlags[x][y2]);
 	}
 
-	debugC(5, kDebugTlcGame, "Tlc:TatFlags: %s  %s", s1.c_str(), s2.c_str());
+	debugC(5, kDebugLogic, "Tlc:TatFlags: %s  %s", s1.c_str(), s2.c_str());
 }
 
 
diff --git a/engines/groovie/logic/triangle.cpp b/engines/groovie/logic/triangle.cpp
index 049d1a8b98..e4ff554c16 100644
--- a/engines/groovie/logic/triangle.cpp
+++ b/engines/groovie/logic/triangle.cpp
@@ -34,11 +34,14 @@ extern const int8 triangleLogicTable[924];
 
 TriangleGame::TriangleGame() : _random("TriangleGame") {
 	init();
+#if 0
+	test();
+#endif
 }
 
 void TriangleGame::run(byte *scriptVariables) {
 	byte op = scriptVariables[3];
-	int8 move;
+	uint8 move;
 
 	switch (op) {
 	case 3:
@@ -47,20 +50,25 @@ void TriangleGame::run(byte *scriptVariables) {
 		return;
 
 	case 4:
+		// Samantha AI
 		move = sub03(2);
 		break;
 
 	case 5:
+		// Stauf AI (only called after Samantha)
 		move = sub03(1);
 		break;
 
 	default:
+		// Player and then Stauf
+		debugC(kDebugLogic, "player chose spot %d", (int)(scriptVariables[1]) + (10 * (int)scriptVariables[0]));
 		setCell(scriptVariables[1] + 10 * scriptVariables[0], 2);
 		scriptVariables[3] = sub02();
 
 		if (scriptVariables[3] == 0) {
 			move = sub03(1);
 		} else {
+			debugC(kDebugLogic, "winner: %d", (int)scriptVariables[3]);
 			return;
 		}
 	}
@@ -68,9 +76,11 @@ void TriangleGame::run(byte *scriptVariables) {
 	scriptVariables[0] = move / 10;
 	scriptVariables[1] = move % 10;
 	scriptVariables[3] = sub02();
+	debugC(kDebugLogic, "stauf chose spot %d, winner: %d", (int)move, (int)scriptVariables[3]);
 }
 
 void TriangleGame::init() {
+	debugC(kDebugLogic, "TriangleGame::init(), seed: %u", _random.getSeed());
 	_triangleCellCount = 0;
 	memset(_triangleCells, 0, 66);
 }
@@ -738,6 +748,98 @@ void TriangleGame::collapseLoops(int8 *route, int8 *singleRow) {
 		route[len] = 66;
 }
 
+void TriangleGame::testGame(uint32 seed, Common::Array<uint8> moves, bool playerWin) {
+	byte vars[1024];
+	byte &op = vars[3];
+	byte &move10s = vars[0];
+	byte &move1s = vars[1];
+	byte &winner = vars[3];
+
+	memset(vars, 0, sizeof(vars));
+
+	op = 3;
+	run(vars);
+
+	warning("starting TriangleGame::testGame(%u, %u, %d)", seed, moves.size(), (int)playerWin);
+	_random.setSeed(seed);
+
+	for (uint i = 0; i < moves.size(); i++) {
+		if (i % 2) {
+			// check Stauf's move
+			uint8 move = ((uint)move10s * 10) + (uint)move1s;
+			if (move != moves[i])
+				error("%u: bad Stauf move: %d", (int)i, (int)move);
+			continue;
+		}
+
+		// else, input player's move
+		if (winner != 0)
+			error("%u: early winner: %d", (int)i, (int)winner);
+
+		uint8 move = moves[i];
+		move10s = move / 10;
+		move1s = move % 10;
+		op = 0;
+		run(vars);
+	}
+
+	if (playerWin && winner != 2)
+		error("player didn't win, winner: %d", (int)winner);
+	if (playerWin == false && winner != 1)
+		error("Stauf didn't win, winner: %d", (int)winner);
+
+	warning("finished TriangleGame::testGame(%u, %u, %d)", seed, moves.size(), (int)playerWin);
+}
+
+void TriangleGame::ensureSamanthaWin(uint32 seed) {
+	byte vars[1024];
+	byte &op = vars[3];
+	byte &winner = vars[3];
+
+	op = 3;
+	run(vars);
+
+	warning("starting TriangleGame::ensureSamanthaWin(%u)", seed);
+	_random.setSeed(seed);
+
+	for (int i = 0; i < 100; i++) {
+		// Samantha
+		op = 4;
+		run(vars);
+		if (winner)
+			break;
+
+		// Stauf
+		op = 5;
+		run(vars);
+		if (winner)
+			break;
+	}
+
+	if (winner != 2)
+		error("Samantha didn't win, winner: %d", (int)winner);
+
+	warning("finished TriangleGame::ensureSamanthaWin(%u)", seed);
+}
+
+void TriangleGame::test() {
+	warning("starting TriangleGame::test");
+
+	// Samantha appears to not always win, but she usually does, and she wins these seeds
+	// haven't verified if she always wins in the original game
+	for (int i = 100; i < 105; i++)
+		ensureSamanthaWin(i);
+
+	testGame(1, {24, 32, 30, 42, 37, 53, 45, 39, 19, 47, 20, 56, 55, 59, 36, 49, 29, 46, 23, 38, 18}, true);
+	testGame(1, {24, 32, 30, 42, 37, 53, 19, 39, 45, 47, 46, 59, 56, 49, 38, 48, 31, 40, 25, 50, 20}, true);
+	testGame(2, {24, 31, 33, 38, 43, 46, 16, 41, 54, 52, 64, 61, 53, 37, 42, 51, 32, 40, 23, 60, 15}, true);
+	testGame(2, {24, 31, 33, 38, 43, 46, 16, 41, 53, 52, 64, 61, 54, 37, 34, 50, 25, 36, 17, 0, 10}, true);
+	testGame(3, {24, 32, 17, 42, 23, 53, 16, 39, 11, 29, 10, 44, 6, 33, 7, 63, 12, 28, 18, 31, 13, 204, 8, 204, 4, 38, 3, 43}, false);
+	testGame(3, {6, 32, 10, 42, 11, 53, 7, 23, 3, 15, 12, 22, 18, 43, 13, 33, 8, 35, 4, 31, 1, 204, 17, 204, 16, 204, 19, 63 }, false);
+
+	warning("finished TriangleGame::test");
+}
+
 namespace {
 
 const int8 triangleLookup1[12] = {
diff --git a/engines/groovie/logic/triangle.h b/engines/groovie/logic/triangle.h
index 91191c8850..67fb3f07c5 100644
--- a/engines/groovie/logic/triangle.h
+++ b/engines/groovie/logic/triangle.h
@@ -49,6 +49,10 @@ private:
 	int copyLookup(const int8 *lookup, int8 *start, int8 *dest);
 	void collapseLoops(int8 *route, int8 *singleRow);
 
+	void testGame(uint32 seed, Common::Array<uint8> moves, bool player_win);
+	void ensureSamanthaWin(uint32 seed);
+	void test();
+
 private:
 	int _triangleCellCount;
 	int8 _triangleCells[66];




More information about the Scummvm-git-logs mailing list