Hello community, here is the log from the commit of package kjumpingcube for openSUSE:Factory checked in at 2014-03-18 16:23:55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/kjumpingcube (Old) and /work/SRC/openSUSE:Factory/.kjumpingcube.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "kjumpingcube" Changes: -------- --- /work/SRC/openSUSE:Factory/kjumpingcube/kjumpingcube.changes 2014-02-20 07:57:52.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.kjumpingcube.new/kjumpingcube.changes 2014-03-18 16:23:56.000000000 +0100 @@ -1,0 +2,14 @@ +Thu Mar 13 20:43:18 UTC 2014 - [email protected] + +- Update to 4.12.90 + * KDE 4.13 Beta 2 release + * See http://www.kde.org/announcements/announce-4.13-beta2.php + +------------------------------------------------------------------- +Fri Mar 7 11:25:44 UTC 2014 - [email protected] + +- Update to 4.12.80 + * KDE 4.13 Beta 1 release + * See http://www.kde.org/announcements/announce-4.13-beta1.php + +------------------------------------------------------------------- Old: ---- kjumpingcube-4.12.2.tar.xz New: ---- kjumpingcube-4.12.90.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ kjumpingcube.spec ++++++ --- /var/tmp/diff_new_pack.UrVfeO/_old 2014-03-18 16:23:57.000000000 +0100 +++ /var/tmp/diff_new_pack.UrVfeO/_new 2014-03-18 16:23:57.000000000 +0100 @@ -23,7 +23,7 @@ License: GPL-2.0+ Group: Amusements/Games/Board/Puzzle Url: http://www.kde.org -Version: 4.12.2 +Version: 4.12.90 Release: 0 Source0: kjumpingcube-%{version}.tar.xz BuildRoot: %{_tmppath}/%{name}-%{version}-build ++++++ kjumpingcube-4.12.2.tar.xz -> kjumpingcube-4.12.90.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kjumpingcube-4.12.2/ai_box.cpp new/kjumpingcube-4.12.90/ai_box.cpp --- old/kjumpingcube-4.12.2/ai_box.cpp 2013-08-17 08:41:22.000000000 +0200 +++ new/kjumpingcube-4.12.90/ai_box.cpp 2014-02-07 09:41:59.000000000 +0100 @@ -71,15 +71,44 @@ createBox (side); } -bool AI_Box::doMove (Player player, int index, QList<int> * steps) + +// ---------------------------------------------------------------- +// Moves + + +bool AI_Box::doMove (Player player, int index, MoveUndodata * undodata, QList<int> * steps) { + // Check for move legality. Player oldOwner = m_owners[index]; if ((oldOwner != player) && (oldOwner != Nobody)) { - qDebug() << "ILLEGAL MOVE: player" << player << "old" << oldOwner << - "at" << index/m_side << index%m_side; + qDebug() << "ILLEGAL MOVE: player" << player << "old" << oldOwner + << "at" << index/m_side << index%m_side; + return false; // The move is not valid. } + if (undodata) { + undodata->oldCubesToWin[Nobody] = m_cubesToWin[Nobody]; + undodata->oldCubesToWin[One] = m_cubesToWin[One]; + undodata->oldCubesToWin[Two] = m_cubesToWin[Two]; + } + + // Bitfield to mark saved cube indices. + quint64 savedCubes[(maxSide * maxSide - 1) / 64 + 1]; + for (int i = 0; i < (maxSide * maxSide - 1) / 64 + 1; ++i) + savedCubes[i] = 0ULL; + + // Save old values of changed cubes (owner + value) into the + // MoveUndodata to be restored by undoMove(). + int saveCubes = 0; + if (undodata) { + undodata->changedCubes[saveCubes++] = ((index << 8) + | (m_owners[index] << 4) + | (m_values[index] << 0)); + savedCubes[index / 64] |= 1ULL << (index % 64); + + } + m_stackPtr = -1; m_owners[index] = player; // Take ownership if not already owned. if (m_maxValues [index] == m_values [index]++) { // Increase the cube. @@ -106,6 +135,7 @@ while (m_stackPtr >= 0) { // Pop the stack and decrease an overloaded cube. index = m_stack [m_stackPtr--]; + // fprintf (stderr, " Expand at %d, value %d\n", index, m_values[index]); m_values[index] = m_values[index] - m_maxValues[index]; @@ -121,6 +151,13 @@ if ((indexN = m_neighbors [offset + nb]) < 0) continue; // No neighbor on this side. + if (undodata && !(savedCubes[indexN / 64] & (1ULL << (indexN % 64)))) { + undodata->changedCubes[saveCubes++] = ((indexN << 8) + | (m_owners[indexN] << 4) + | (m_values[indexN] << 0)); + savedCubes[indexN / 64] |= 1ULL << (indexN % 64); + } + // Increase the neighbor and take over ownership. oldOwner = m_owners[indexN]; m_owners[indexN] = player; @@ -147,6 +184,12 @@ if (steps) { steps->append (0); } + + // Mark the end of changed cubes in the undodata. + if (undodata) { + undodata->changedCubes[saveCubes++] = 0xffff; + } + // printBox(); // fprintf (stderr, "PLAYER WON\n"); return true; @@ -154,10 +197,32 @@ // printBox(); } // End while() + if (undodata) { + undodata->changedCubes[saveCubes++] = 0xffff; + } + // printBox(); return false; } +void AI_Box::undoMove (MoveUndodata * undodata) +{ + m_cubesToWin[Nobody] = undodata->oldCubesToWin[Nobody]; + m_cubesToWin[One] = undodata->oldCubesToWin[One]; + m_cubesToWin[Two] = undodata->oldCubesToWin[Two]; + + for (int i = 0; undodata->changedCubes[i] != 0xffff; ++i) { + int index = (undodata->changedCubes[i] >> 8) & 0xff; + m_owners[index] = Player((undodata->changedCubes[i] >> 4) & 0xf); + m_values[index] = (undodata->changedCubes[i] >> 0) & 0xf; + } +} + + +// ---------------------------------------------------------------- +// Game history + + void AI_Box::copyPosition (Player player, bool isAI, int index) { #if AILog > 4 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kjumpingcube-4.12.2/ai_box.h new/kjumpingcube-4.12.90/ai_box.h --- old/kjumpingcube-4.12.2/ai_box.h 2013-08-17 08:41:22.000000000 +0200 +++ new/kjumpingcube-4.12.90/ai_box.h 2014-02-07 09:41:59.000000000 +0100 @@ -73,7 +73,18 @@ } } - bool doMove (Player player, int index, QList<int> * steps = 0); + // This struct is passed to doMove() and is used to store + // everything that is needed by undoMove() to actually undo it. + struct MoveUndodata { + Player oldPlayer; // The player previously to move in the position + int oldCubesToWin[3]; + quint16 changedCubes[maxSide * maxSide]; // 8 bits index, 4 bits owner and 4 bits value + // end with 0xffff + }; + + bool doMove (Player player, int index, + MoveUndodata * undodata = 0, QList<int> * steps = 0); + void undoMove (MoveUndodata * undodata); #if AILog > 0 void printBox(); #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kjumpingcube-4.12.2/ai_main.cpp new/kjumpingcube-4.12.90/ai_main.cpp --- old/kjumpingcube-4.12.2/ai_main.cpp 2013-08-17 08:41:22.000000000 +0200 +++ new/kjumpingcube-4.12.90/ai_main.cpp 2014-02-07 09:41:59.000000000 +0100 @@ -277,8 +277,9 @@ << "val" << cubesToMove[n].val; #endif - copyPosition (player, true, 0); - bool won = doMove (player, cubesToMove[n].index); + MoveUndodata undodata; + bool won = doMove (player, cubesToMove[n].index, &undodata); + #if AILog > 2 n_simulate++; #endif @@ -298,7 +299,7 @@ << "move" << cubesToMove[n].index/m_side << cubesToMove[n].index%m_side; #endif - undoPosition (player); + undoMove(&undodata); break; } else if (level >= m_maxLevel) { @@ -344,7 +345,7 @@ #endif } Player p = player; - undoPosition (player); + undoMove(&undodata); if (p != player) qDebug() << "ERROR: PLAYER CHANGED: from" << p << "to" << player; if (m_stopped) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kjumpingcube-4.12.2/game.cpp new/kjumpingcube-4.12.90/game.cpp --- old/kjumpingcube-4.12.2/game.cpp 2013-08-17 08:41:22.000000000 +0200 +++ new/kjumpingcube-4.12.90/game.cpp 2014-02-07 09:41:59.000000000 +0100 @@ -361,7 +361,7 @@ emit setAction (UNDO, true); // Update Undo and Redo actions. emit setAction (REDO, false); m_steps->clear(); - bool won = m_box->doMove (m_currentPlayer, index, m_steps); + bool won = m_box->doMove (m_currentPlayer, index, 0, m_steps); #if AILog > 1 qDebug() << "GAME WON?" << won << "STEPS" << (* m_steps); // m_box->printBox(); -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
