Commit e2c2dca6 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Convert to qdebug

parent ff2aa332
......@@ -10,7 +10,7 @@
#include "aicontroller.h"
#include <ctime>
#include <kdebug.h>
#include <QDebug>
#include <QSet>
......@@ -22,7 +22,7 @@ aiController::aiController(int newPlayerId, const QList<bool> &newLines, const Q
lines = new bool[linesSize];
for (int i = 0; i < linesSize; ++i) lines[i] = newLines[i];
srand( (unsigned)time( NULL ) );
kDebug() << "AI: Starting AI level" << Settings::difficulty();
//qDebug() << "AI: Starting AI level" << Settings::difficulty();
}
aiController::~aiController()
......@@ -36,12 +36,12 @@ QList<int> aiController::autoFill(int safeMovesLeft)
// add a random safe moves while there are safe moves left
QList<int> next;
//kDebug() << safeMoves().isEmpty();
////qDebug() << safeMoves().isEmpty();
while( !( (next = safeMoves()).isEmpty() ) )
{
int nextLine = next[rand() % next.size()];
lines[nextLine] = true;
//kDebug() << nextLine;
////qDebug() << nextLine;
fillLines << nextLine;
}
......@@ -70,7 +70,7 @@ int aiController::chooseLine() const
if(countBorderLines(adjacentSquares.at(j), lines) == 3) //if 3 lines, draw there to get points!
{
choiceList.append(i);
//kDebug() << "AI: 1. Adding" << i << "to choices";
////qDebug() << "AI: 1. Adding" << i << "to choices";
}
}
}
......@@ -90,13 +90,13 @@ int aiController::chooseLine() const
QList<int> choices=chooseLeastDamaging(openLines); // run extended damage control
if(choices.size() > 0)
{
kDebug() << "AI: 4. Drawing line at index:" << choices.at(0);
//qDebug() << "AI: 4. Drawing line at index:" << choices.at(0);
return choices.at(0);
}
}
float randomFloat = ((float) rand()/(RAND_MAX + 1.0))*(choiceList.size()-1);
int randChoice = (short)(randomFloat)/1;
kDebug() << "AI: 1. Drawing line at index:" << choiceList.at(randChoice);
//qDebug() << "AI: 1. Drawing line at index:" << choiceList.at(randChoice);
return choiceList.at(randChoice);
}
......@@ -106,7 +106,7 @@ int aiController::chooseLine() const
{
float randomFloat = ((float) rand()/(RAND_MAX + 1.0))*(choiceList.size()-1);
int randChoice = (short)(randomFloat)/1;
kDebug() << "AI: 2. Drawing line at index:" << choiceList.at(randChoice);
//qDebug() << "AI: 2. Drawing line at index:" << choiceList.at(randChoice);
return choiceList.at(randChoice);
}
......@@ -122,7 +122,7 @@ int aiController::chooseLine() const
if(countBorderLines(adjacentSquares.at(j), lines) == 2) //if 2 lines (they're all that's left!)
{
choiceList.append(i);
//kDebug() << "AI: 3. Adding" << i << "to choices";
////qDebug() << "AI: 3. Adding" << i << "to choices";
}
}
}
......@@ -134,7 +134,7 @@ int aiController::chooseLine() const
{
float randomFloat = ((float) rand()/(RAND_MAX + 1.0))*(goodChoiceList.size()-1);
int randChoice = (short)(randomFloat)/1;
kDebug() << "AI: 3. Drawing line at index:" << goodChoiceList.at(randChoice);
//qDebug() << "AI: 3. Drawing line at index:" << goodChoiceList.at(randChoice);
return goodChoiceList.at(randChoice);
}
}
......@@ -143,7 +143,7 @@ int aiController::chooseLine() const
{
float randomFloat = ((float) rand()/(RAND_MAX + 1.0))*(choiceList.size()-1);
int randChoice = (short)(randomFloat)/1;
kDebug() << "AI: 3. Drawing line at index:" << choiceList.at(randChoice);
//qDebug() << "AI: 3. Drawing line at index:" << choiceList.at(randChoice);
return choiceList.at(randChoice);
}
return 0;
......@@ -168,7 +168,7 @@ QList<int> aiController::safeMoves() const
if(badCount == 0)
{
safeLines.append(i);
//kDebug() << "AI: 2. Adding" << i << "to choices";
////qDebug() << "AI: 2. Adding" << i << "to choices";
}
}
}
......@@ -177,7 +177,7 @@ QList<int> aiController::safeMoves() const
QList<int> aiController::chooseLeastDamaging(const QList<int> &choiceList) const
{
//kDebug() << "AI: Checking" << choiceList.size() << "possible moves";
////qDebug() << "AI: Checking" << choiceList.size() << "possible moves";
QMap<int,int> linePointDamage; //this will be a list of how damaging a certain move will be. Key = damage of move, Value = index of line
QScopedArrayPointer<bool> linesCopy(new bool[linesSize]); //make temporary local copies of lists
int sidesOfSquare[4];
......@@ -249,7 +249,7 @@ QList<int> aiController::chooseLeastDamaging(const QList<int> &choiceList) const
}
}
} while (chainFound);
//kDebug() << "ownChains:" << ownChains;
////qDebug() << "ownChains:" << ownChains;
// complete the shortest chain first if there is more than one chain. this is needed to stop alternating between two chains because that works against the hard ai move which takes the next chain by sacrificing 2/4 squares. when alternating between two chains it's possible that there are 3 remaining open lines in both chains combined which triggers the evil move too late because the chains were completed in the wrong order
int minChain=-1;
......@@ -266,7 +266,7 @@ QList<int> aiController::chooseLeastDamaging(const QList<int> &choiceList) const
{
ownMoves=ownChains.at(minChain);
}
//kDebug() << "ownMoves:" << ownMoves;
////qDebug() << "ownMoves:" << ownMoves;
}
for(int i = 0; i < choiceList.size(); i++) //cycle through all the possible moves
......@@ -326,7 +326,7 @@ QList<int> aiController::chooseLeastDamaging(const QList<int> &choiceList) const
chains.insert(choiceList.at(i), chain);
}
//kDebug() << "linePointDamage:" << linePointDamage;
////qDebug() << "linePointDamage:" << linePointDamage;
if(Settings::difficulty() < 2) // middle ai won't analyze the game further
{
......@@ -334,7 +334,7 @@ QList<int> aiController::chooseLeastDamaging(const QList<int> &choiceList) const
return bestMoves;
}
//kDebug() << chains;
////qDebug() << chains;
// remove double entries from chains to get chainSet
QMapIterator<int, QSet<int> > j(chains);
while(j.hasNext()) // walk through chains and add chain to chainSet (if not already contained)
......@@ -358,7 +358,7 @@ QList<int> aiController::chooseLeastDamaging(const QList<int> &choiceList) const
chainSet.insert(j.key(), chainCheck);
}
}
//kDebug() << "chainSet:" << chainSet;
////qDebug() << "chainSet:" << chainSet;
// analyze chains
// TODO: find loop chains to calculate sacrifices (loopChains are a subset of longChains)
......@@ -377,7 +377,7 @@ QList<int> aiController::chooseLeastDamaging(const QList<int> &choiceList) const
longChains++;
}
}
//kDebug() << "short chains:" << shortChains << ", long chains: " << longChains;
////qDebug() << "short chains:" << shortChains << ", long chains: " << longChains;
if(
(
......@@ -390,7 +390,7 @@ QList<int> aiController::chooseLeastDamaging(const QList<int> &choiceList) const
safeMoves().size() == 0 // only do it in endgames
)
{
kDebug() << "HAHA, our chance to do the evil thing!";
//qDebug() << "HAHA, our chance to do the evil thing!";
int magicLine = -1; // line in own moves that is used to get the next chain (draw there to give 2/4 squares to opponent)
// formal definition of magicLine: line that when completed will leave at least one other line in own moves that completes two squares at once
// the opposite of magic line will be used in the hard hearted handout to make sure that the opponent won't be able to do the evil move
......@@ -416,7 +416,7 @@ QList<int> aiController::chooseLeastDamaging(const QList<int> &choiceList) const
}
}
}
kDebug() << "Magic Line index:" << magicLine;
//qDebug() << "Magic Line index:" << magicLine;
QList<int> bestMoves;
if(ownMoves.size() > 1)
{
......@@ -475,7 +475,7 @@ QList<int> aiController::chooseLeastDamaging(const QList<int> &choiceList) const
}
if(handoutLine >= 0)
{
//kDebug() << "Hard hearted handout at" << opponentChain.at(handoutLine);
////qDebug() << "Hard hearted handout at" << opponentChain.at(handoutLine);
QList<int> retMove;
retMove.append(opponentChain.at(handoutLine));
return retMove;
......@@ -502,7 +502,7 @@ int aiController::countBorderLines(int *sidesOfSquare, int squareIndex, const bo
count++;
if(linesList[sidesOfSquare[3]] == true)
count++;
//kDebug() << "AI: Square" << squareIndex << "is bordered by" << count << "lines";
////qDebug() << "AI: Square" << squareIndex << "is bordered by" << count << "lines";
return count;
}
......@@ -514,7 +514,7 @@ int aiController::countBorderLines(int squareIndex, const bool *linesList) const
QList<int> aiController::squaresFromLine(int lineIndex) const
{
//kDebug() << "Line:" << lineIndex;
////qDebug() << "Line:" << lineIndex;
QList<int> squareList;
if (lineDirection(lineIndex) == KSquares::HORIZONTAL)
{
......@@ -535,8 +535,8 @@ QList<int> aiController::squaresFromLine(int lineIndex) const
if(lineIndex%((2*width)+1) == 2*width)
squareList.removeAt(0);
}
//kDebug() << "Size:" << squareList.size();
//kDebug() << "squares:" << squareList.at(0) << " " << squareList.at(1);
////qDebug() << "Size:" << squareList.size();
////qDebug() << "squares:" << squareList.at(0) << " " << squareList.at(1);
return squareList;
}
......
......@@ -16,11 +16,11 @@
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsEllipseItem>
#include <kdebug.h>
#include <QDebug>
GameBoardScene::GameBoardScene(int newWidth, int newHeight, QObject *parent) : QGraphicsScene(parent), width(newWidth), height(newHeight), acceptEvents(true)
{
//kDebug() << "GameBoardScene::GameBoardScene()";
////qDebug() << "GameBoardScene::GameBoardScene()";
for(int i = 0; i < (2*width*height + width + height); i++)
{
......@@ -75,7 +75,7 @@ GameBoardScene::GameBoardScene(int newWidth, int newHeight, QObject *parent) : Q
GameBoardScene::~GameBoardScene()
{
kDebug() << "GameBoardScene::~GameBoardScene()";
//qDebug() << "GameBoardScene::~GameBoardScene()";
delete indicatorLine;
}
......@@ -256,8 +256,8 @@ void GameBoardScene::mouseMoveEvent (QGraphicsSceneMouseEvent* mouseEvent)
if (!acceptEvents) return;
//indicatorLine = 0;
//kDebug() << "GameBoardScene::mouseMoveEvent";
//kDebug() << "mouseEvent->scenePos():" << mouseEvent->scenePos().x() << "," << mouseEvent->scenePos().y();
////qDebug() << "GameBoardScene::mouseMoveEvent";
////qDebug() << "mouseEvent->scenePos():" << mouseEvent->scenePos().x() << "," << mouseEvent->scenePos().y();
QList<QGraphicsEllipseItem*> connectList = getTwoNearestPoints(mouseEvent->scenePos());
......
......@@ -17,7 +17,7 @@
#include <KApplication>
#include <KStatusBar>
#include <KActionCollection>
#include <kdebug.h>
#include <QDebug>
#include <KLocale>
#include <kstandardgameaction.h>
......@@ -65,7 +65,7 @@ void KSquaresDemoWindow::gameNew()
color = Qt::yellow;
break;
default:
kError() << "KSquaresGame::playerSquareComplete(); currentPlayerId() != 0|1|2|3";
qCritical() << "KSquaresGame::playerSquareComplete(); currentPlayerId() != 0|1|2|3";
}
playerList.append(KSquaresPlayer(i18n("Player %1", i+1), color, false));
}
......@@ -103,7 +103,7 @@ void KSquaresDemoWindow::aiChooseLine()
void KSquaresDemoWindow::gameOver(const QVector<KSquaresPlayer> & /*playerList*/)
{
kDebug() << "Game Over";
//qDebug() << "Game Over";
QTimer::singleShot(1000, this, SLOT(gameNew()));
}
......
......@@ -9,27 +9,27 @@
#include "ksquaresgame.h"
#include <kdebug.h>
#include <QDebug>
//generated
#include "settings.h"
KSquaresGame::KSquaresGame()
{
kDebug() << "Constructing Game";
//qDebug() << "Constructing Game";
gameInProgress = false;
}
KSquaresGame::~KSquaresGame()
{
kDebug() << "Destroying game";
//qDebug() << "Destroying game";
gameInProgress = false;
}
void KSquaresGame::createGame(const QVector<KSquaresPlayer> &startPlayers, int startWidth, int startHeight)
{
resetEverything(); //reset everything
kDebug() << "Creating Game with" << startPlayers.size() << "player(s)";
//qDebug() << "Creating Game with" << startPlayers.size() << "player(s)";
//BEGIN Initialisation
width = startWidth;
......@@ -48,7 +48,7 @@ void KSquaresGame::createGame(const QVector<KSquaresPlayer> &startPlayers, int s
}
//END Initialisation
kDebug() << "Game Starting";
//qDebug() << "Game Starting";
nextPlayer();
}
......@@ -62,8 +62,8 @@ int KSquaresGame::nextPlayer()
{
anotherGo = false; //just to reset the variable
currentPlayerId() >= (players.size()-1) ? i_currentPlayerId = 0 : i_currentPlayerId++;
kDebug()<< "- Moving to next player:" << currentPlayer()->name() << "(" << currentPlayerId() << ")";
kDebug() << "-";
//qDebug()<< "- Moving to next player:" << currentPlayer()->name() << "(" << currentPlayerId() << ")";
//qDebug() << "-";
emit takeTurnSig(currentPlayer());
return currentPlayerId();
......@@ -71,7 +71,7 @@ int KSquaresGame::nextPlayer()
void KSquaresGame::playerSquareComplete(int index)
{
kDebug() << "- - " << currentPlayer()->name() << "(" << currentPlayerId() << ") has completed a square";
//qDebug() << "- - " << currentPlayer()->name() << "(" << currentPlayerId() << ") has completed a square";
anotherGo = true;
squareOwnerTable[index] = currentPlayerId(); //add square to index
......@@ -83,10 +83,10 @@ void KSquaresGame::playerSquareComplete(int index)
{
totalPoints += players.at(i).score();
}
kDebug() << "- - Square Completed";
//qDebug() << "- - Square Completed";
if (totalPoints >= width*height) //if the board is full
{
kDebug() << "Game Over";
//qDebug() << "Game Over";
gameInProgress = false;
emit gameOver(players);
}
......@@ -94,20 +94,20 @@ void KSquaresGame::playerSquareComplete(int index)
void KSquaresGame::tryEndGo()
{
kDebug() << "- - Trying to end go";
//qDebug() << "- - Trying to end go";
if (anotherGo)
{
if(gameInProgress)
{
kDebug() << "- - - Having another go";
kDebug() << "-";
//qDebug() << "- - - Having another go";
//qDebug() << "-";
anotherGo = false;
emit takeTurnSig(currentPlayer());
}
}
else
{
kDebug() << "- - - Go ending";
//qDebug() << "- - - Go ending";
if (!currentPlayer()->isHuman())
{
emit highlightMove(lastLine);
......@@ -118,7 +118,7 @@ void KSquaresGame::tryEndGo()
void KSquaresGame::resetEverything()
{
kDebug() << "Game Values Resetting";
//qDebug() << "Game Values Resetting";
numOfPlayers = 0;
players.resize(0);
lineList.clear();
......@@ -135,7 +135,7 @@ void KSquaresGame::addLineToIndex(int index)
{
if (lineList[index] == true) //if there is already a line
{
kWarning() << "KSquaresGame::addLineToIndex():"
qWarning() << "KSquaresGame::addLineToIndex():"
<< "trying to add line already there!";
return;
}
......@@ -162,7 +162,7 @@ void KSquaresGame::checkForNewSquares()
//cout << index1 << "," << index2 << "," << index3 << "," << index4 << " - " << lineList.size() << endl;
if (lineList.at(index1) && lineList.at(index2) && lineList.at(index3) && lineList.at(index4))
{
kDebug() << "- - Square" << i << "completed.";
//qDebug() << "- - Square" << i << "completed.";
playerSquareComplete(i);
}
}
......
......@@ -17,7 +17,7 @@
//kde
#include <KConfigDialog>
#include <KActionCollection>
#include <KDebug>
#include <QDebug>
#include <KLocale>
#include <KScoreDialog>
#include <KHighscore>
......@@ -162,7 +162,7 @@ void KSquaresWindow::gameReset()
color = QColor(243,195,0); //or darker: (227,173,0);
break;
default:
kError() << "KSquaresGame::playerSquareComplete(); currentPlayerId() != 0|1|2|3";
qCritical() << "KSquaresGame::playerSquareComplete(); currentPlayerId() != 0|1|2|3";
}
playerList.append(KSquaresPlayer(Settings::playerNames().at(i), color, Settings::humanList().at(i)));
}
......@@ -264,7 +264,7 @@ void KSquaresWindow::gameOver(const QVector<KSquaresPlayer> &_playerList)
void KSquaresWindow::playerTakeTurn(KSquaresPlayer* currentPlayer)
{
//kDebug() << "void KSquares::playerTakeTurn(KSquaresPlayer* currentPlayer)";
////qDebug() << "void KSquares::playerTakeTurn(KSquaresPlayer* currentPlayer)";
#if 0 //QT5
statusBar()->changeItem(
QString::fromLatin1("<font color=\"%1\">%2</font>")
......
......@@ -13,7 +13,7 @@
#include <KLocale>
#include <KUser>
#include <KGlobal>
#include <KDebug>
#include <QDebug>
#include "ksquareswindow.h"
#include "ksquaresdemowindow.h"
......
......@@ -8,7 +8,7 @@
***************************************************************************/
#include "newgamedialog.h"
#include <kdebug.h>
#include <QDebug>
NewGameDialog::NewGameDialog(QWidget* parent) : KDialog(parent)
{
......@@ -36,7 +36,7 @@ void NewGameDialog::adjustEnabledUsers(int numOfPlayers)
case 4:
break;
default:
kError() << "NewGameDialog::adjustEnabledUsers(): numOfPlayers out of range!!";
qCritical() << "NewGameDialog::adjustEnabledUsers(): numOfPlayers out of range!!";
}
switch(numOfPlayers)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment