[Scummvm-git-logs] scummvm master -> efd19a3fe775a5ee6220a9cd40518110173048d4
Die4Ever
noreply at scummvm.org
Thu Jan 27 21:37:22 UTC 2022
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:
efd19a3fe7 GROOVIE: pente bug fix with negative scores
Commit: efd19a3fe775a5ee6220a9cd40518110173048d4
https://github.com/scummvm/scummvm/commit/efd19a3fe775a5ee6220a9cd40518110173048d4
Author: Die4Ever (die4ever2005 at gmail.com)
Date: 2022-01-27T15:36:36-06:00
Commit Message:
GROOVIE: pente bug fix with negative scores
Changed paths:
engines/groovie/logic/pente.cpp
engines/groovie/logic/pente.h
diff --git a/engines/groovie/logic/pente.cpp b/engines/groovie/logic/pente.cpp
index f0896d443bf..7ebb327689e 100644
--- a/engines/groovie/logic/pente.cpp
+++ b/engines/groovie/logic/pente.cpp
@@ -36,8 +36,8 @@ namespace Groovie {
#undef UINT_MAX
#endif
const uint UINT_MAX = (uint)-1;
-const uint WIN_SCORE = 100000000;
-const uint CAPTURE_SCORE = 1000000;
+const int WIN_SCORE = 100000000;
+const int CAPTURE_SCORE = 1000000;
const uint PLAYER = 79;
const uint STAUF = 88;
@@ -48,8 +48,8 @@ struct pentePlayerTable {
struct penteTable {
pentePlayerTable player;
pentePlayerTable stauf;
- uint playerScore;
- uint staufScore;
+ int playerScore;
+ int staufScore;
byte playerLines;
byte staufLines;
byte width;
@@ -139,16 +139,20 @@ void PenteGame::penteInit(uint width, uint height, uint length) {
memset(_table->numAdjacentPieces, 0, sizeof(_table->numAdjacentPieces));
_table->calcTouchingPieces = 1;
+
+ _nextCapturedSpot = -1;
+ _animateCapturesBitMask = 0;
+ _previousMove = 0;
}
-uint &PenteGame::getPlayerTable(bool staufTurn, pentePlayerTable *&pt) {
+int &PenteGame::getPlayerTable(bool staufTurn, pentePlayerTable *&pt) {
pt = staufTurn ? &_table->stauf : &_table->player;
return staufTurn ? _table->staufScore : _table->playerScore;
}
void PenteGame::scoreLine(uint16 lineIndex, bool isStaufTurn, bool revert) {
pentePlayerTable *playerTable;
- uint &score = getPlayerTable(isStaufTurn, playerTable);
+ int &score = getPlayerTable(isStaufTurn, playerTable);
int lineLength, mult;
if (revert) {
@@ -163,7 +167,7 @@ void PenteGame::scoreLine(uint16 lineIndex, bool isStaufTurn, bool revert) {
score = (int)score + (int)WIN_SCORE * mult;
} else {
pentePlayerTable *opponentTable;
- uint &opponentScore = getPlayerTable(!isStaufTurn, opponentTable);
+ int &opponentScore = getPlayerTable(!isStaufTurn, opponentTable);
int opponentLineLength = opponentTable->lines[lineIndex];
if (lineLength == 0) {
opponentScore += (-(1 << ((byte)opponentLineLength & 0x1f))) * mult;
@@ -289,6 +293,7 @@ byte PenteGame::scoreCaptureSingle(byte x, byte y, int slopeX, int slopeY) {
if (boardState[x1][y1] != captive || boardState[x2][y2] != captive)
return 0;
+ // now we take away the points the captor had for these pieces
revertScore(x1, y1);
revertScore(x2, y2);
return 1;
@@ -320,7 +325,7 @@ uint PenteGame::scoreCapture(byte x, byte y) {
if ((i & 1) == 0)
continue;
pentePlayerTable *playerTable;
- uint &score = getPlayerTable(isStauf, playerTable);
+ int &score = getPlayerTable(isStauf, playerTable);
int lineLength = ++playerTable->lines[_table->linesCounter];
if (_table->lineLength == lineLength) {
@@ -395,7 +400,7 @@ void PenteGame::revertCapture(byte x, byte y, byte bitMask) {
continue;
pentePlayerTable *playerTable;
- uint &score = getPlayerTable(!isPlayer, playerTable);
+ int &score = getPlayerTable(!isPlayer, playerTable);
int linesCounter = --playerTable->lines[_table->linesCounter];
@@ -418,7 +423,7 @@ void PenteGame::revertCapture(byte x, byte y, byte bitMask) {
int PenteGame::scoreMoveAndRevert(byte x, byte y, char depth, int parentScore, bool &gameOver) {
updateScore(x, y, _table->moveCounter % 2);
- uint score = scoreCapture(x, y);
+ uint capturesMask = scoreCapture(x, y);
if (_table->playerScore >= WIN_SCORE || _table->staufScore >= WIN_SCORE)
gameOver = true;
@@ -435,8 +440,8 @@ int PenteGame::scoreMoveAndRevert(byte x, byte y, char depth, int parentScore, b
scoreDiff = _table->staufScore - _table->playerScore;
}
}
- if (score != 0) {
- revertCapture(x, y, score);
+ if (capturesMask != 0) {
+ revertCapture(x, y, capturesMask);
}
revertScore(x, y);
return scoreDiff;
@@ -644,6 +649,7 @@ void PenteGame::opQueryPiece(byte *vars) {
void PenteGame::run(byte *vars) {
byte op = vars[4];
if (_table == nullptr && op != 0) {
+ debugC(kDebugLogic, "pente Init, seed %u", _random.getSeed());
penteInit(20, 15, 5);
}
debugC(kDebugLogic, "penteOp vars[4]: %d", (int)op);
@@ -775,7 +781,7 @@ void PenteGame::test() {
warning("finished PenteGame::test()");
}
-void PenteGame::testGame(uint32 seed, Common::Array<int> moves, bool playerWin) {
+bool PenteGame::testGame(uint32 seed, Common::Array<int> moves, bool playerWin) {
byte vars[1024];
byte &winner = vars[5];
byte &op = vars[4];
@@ -828,6 +834,7 @@ void PenteGame::testGame(uint32 seed, Common::Array<int> moves, bool playerWin)
error("Stauf didn't win, winner: %d", (int)winner);
warning("finished PenteGame::testGame(%u, %u, %d)", seed, moves.size(), (int)playerWin);
+ return true;
}
void PenteGame::testRandomGame(uint32 seed) {
diff --git a/engines/groovie/logic/pente.h b/engines/groovie/logic/pente.h
index be36bfcc526..c33507f4a33 100644
--- a/engines/groovie/logic/pente.h
+++ b/engines/groovie/logic/pente.h
@@ -53,7 +53,7 @@ private:
void buildLookupTable();
void penteDeInit();
void penteInit(uint width, uint height, uint length);
- uint &getPlayerTable(bool staufTurn, pentePlayerTable *&pt);
+ int &getPlayerTable(bool staufTurn, pentePlayerTable *&pt);
void scoreLine(uint16 lineIndex, bool isStaufTurn, bool revert);
void calcTouchingPieces(byte moveX, byte moveY, bool revert);
void updateScore(byte x, byte y, bool whose_turn);
@@ -68,7 +68,7 @@ private:
int aiRecurse(char depth, int parentScore);
uint16 aiGetBestMove(byte depth);
void test();
- void testGame(uint32 seed, Common::Array<int> moves, bool playerWin);
+ bool testGame(uint32 seed, Common::Array<int> moves, bool playerWin);
void testRandomGame(uint32 seed);
Common::RandomSource _random;
More information about the Scummvm-git-logs
mailing list