Commit 1e880da3 authored by Inge Wallin's avatar Inge Wallin

Revert "Establish some coding standards step I"

This reverts commit b80d0c6c.
parent f639981e
This diff is collapsed.
......@@ -125,6 +125,7 @@
//#include "Move.h"
//#include "Score.h"
//#include <sys/times.h>
#include <QVector>
#include <krandomsequence.h>
#include "commondefs.h"
......@@ -133,10 +134,10 @@ class KReversiGame;
static ChipColor opponentColorFor(ChipColor color)
{
if (color == NoColor)
if(color == NoColor)
return color;
else
return (color == White ? Black : White);
return ( color == White ? Black : White );
}
......@@ -145,31 +146,31 @@ static ChipColor opponentColorFor(ChipColor color)
class SquareStackEntry
{
public:
SquareStackEntry();
public:
SquareStackEntry();
void setXY(int x, int y);
void setXY(int x, int y);
public:
int m_x;
int m_y;
public:
int m_x;
int m_y;
};
class SquareStack
{
public:
SquareStack();
SquareStack(int size);
void resize(int size);
void init(int size);
SquareStackEntry Pop();
void Push(int x, int y);
private:
QVector<SquareStackEntry> m_squarestack;
int m_top;
public:
SquareStack();
SquareStack(int size);
void resize(int size);
void init(int size);
SquareStackEntry Pop();
void Push(int x, int y);
private:
QVector<SquareStackEntry> m_squarestack;
int m_top;
};
......@@ -177,16 +178,16 @@ class SquareStack
class MoveAndValue
{
public:
MoveAndValue();
MoveAndValue(int x, int y, int value);
public:
MoveAndValue();
MoveAndValue(int x, int y, int value);
void setXYV(int x, int y, int value);
void setXYV(int x, int y, int value);
public:
int m_x;
int m_y;
int m_value;
public:
int m_x;
int m_y;
int m_value;
};
class Score;
......@@ -194,62 +195,61 @@ class Score;
// The real beef of this program: the engine that finds good moves for
// the computer player.
//
class Engine
{
public:
Engine(int st, int sd);
Engine(int st);
Engine();
class Engine {
public:
Engine(int st, int sd);
Engine(int st);
Engine();
~Engine();
~Engine();
KReversiPos computeMove(const KReversiGame& game, bool competitive);
bool isThinking() const { return m_computingMove; }
KReversiPos computeMove(const KReversiGame& game, bool competitive);
bool isThinking() const { return m_computingMove; }
void setInterrupt(bool intr) { m_interrupt = intr; }
bool interrupted() const { return m_interrupt; }
void setInterrupt(bool intr) { m_interrupt = intr; }
bool interrupted() const { return m_interrupt; }
void setStrength(uint strength) { m_strength = strength; }
uint strength() const { return m_strength; }
private:
KReversiPos ComputeFirstMove(const KReversiGame& game);
int ComputeMove2(int xplay, int yplay, ChipColor color, int level,
int cutoffval,
quint64 colorbits, quint64 opponentbits);
void setStrength(uint strength) { m_strength = strength; }
uint strength() const { return m_strength; }
private:
KReversiPos ComputeFirstMove(const KReversiGame& game);
int ComputeMove2(int xplay, int yplay, ChipColor color, int level,
int cutoffval,
quint64 colorbits, quint64 opponentbits);
int TryAllMoves(ChipColor opponent, int level, int cutoffval,
quint64 opponentbits, quint64 colorbits);
int TryAllMoves(ChipColor opponent, int level, int cutoffval,
quint64 opponentbits, quint64 colorbits);
int EvaluatePosition(ChipColor color);
void SetupBcBoard();
void SetupBits();
int CalcBcScore(ChipColor color);
quint64 ComputeOccupiedBits(ChipColor color);
int EvaluatePosition(ChipColor color);
void SetupBcBoard();
void SetupBits();
int CalcBcScore(ChipColor color);
quint64 ComputeOccupiedBits(ChipColor color);
void yield();
void yield();
private:
private:
ChipColor m_board[10][10];
int m_bc_board[9][9];
Score* m_score;
Score* m_bc_score;
SquareStack m_squarestack;
ChipColor m_board[10][10];
int m_bc_board[9][9];
Score* m_score;
Score* m_bc_score;
SquareStack m_squarestack;
int m_depth;
int m_coeff;
int m_nodes_searched;
bool m_exhaustive;
bool m_competitive;
int m_depth;
int m_coeff;
int m_nodes_searched;
bool m_exhaustive;
bool m_competitive;
uint m_strength;
KRandomSequence m_random;
bool m_interrupt;
uint m_strength;
KRandomSequence m_random;
bool m_interrupt;
quint64 m_coord_bit[9][9];
quint64 m_neighbor_bits[9][9];
quint64 m_coord_bit[9][9];
quint64 m_neighbor_bits[9][9];
bool m_computingMove;
bool m_computingMove;
};
#endif
......@@ -17,8 +17,8 @@
#include "colorscheme.h"
ColorScheme::ColorScheme(QDeclarativeItem *parent)
: QDeclarativeItem(parent)
ColorScheme::ColorScheme(QDeclarativeItem *parent) :
QDeclarativeItem(parent)
{
}
......
......@@ -24,19 +24,12 @@
#define COMMONDEFS_H
// noColor = empty
enum ChipColor {
White = 0,
Black = 1,
NoColor = 2
};
enum ChipColor { White = 0, Black = 1, NoColor = 2 };
struct KReversiPos
{
KReversiPos( ChipColor col = NoColor, int r = -1, int c = -1 )
: color(col), row(r), col(c) { }
ChipColor color;
int row;
int col;
......
......@@ -29,10 +29,10 @@ namespace KExtHighscore
class ExtManager : public Manager
{
public:
public:
ExtManager();
private:
private:
virtual QString gameTypeLabel(uint gameTye, LabelType) const;
QStringList m_typeLabels;
};
......
This diff is collapsed.
......@@ -116,11 +116,11 @@ public:
/**
* @return score (number of chips) of the player
*/
int playerScore(ChipColor player) const;
int playerScore( ChipColor player ) const;
/**
* @return color of the chip at position [row, col]
*/
ChipColor chipColorAt(int row, int col) const;
ChipColor chipColorAt( int row, int col ) const;
/**
* @return if undo is possible
*/
......@@ -159,7 +159,7 @@ private:
* This function will tell you if the move is possible.
* That's why it was given such a name ;)
*/
bool isMovePossible(const KReversiPos& move) const;
bool isMovePossible( const KReversiPos& move ) const;
/**
* Searches for "chunk" in direction dir for move.
* As my English-skills are somewhat limited, let me introduce
......@@ -174,7 +174,7 @@ private:
* Performs move, i.e. marks all the chips that player wins with
* this move with current player color
*/
void makeMove(const KReversiPos& move);
void makeMove( const KReversiPos& move );
/**
* Sets the type of chip at (row,col)
*/
......
......@@ -121,9 +121,9 @@ void KReversiView::updateBoard()
for (int i = 0; i < 8; i++)
for (int j = 0; j < 8; j++) {
QMetaObject::invokeMethod(m_qml_root, "setPreAnimationTicks",
Q_ARG(QVariant, i),
Q_ARG(QVariant, j),
Q_ARG(QVariant, 0));
Q_ARG(QVariant, i),
Q_ARG(QVariant, j),
Q_ARG(QVariant, 0));
}
m_maxDelay = 0;
......@@ -131,14 +131,14 @@ void KReversiView::updateBoard()
PosList changed_chips = m_game->changedChips();
for (int i = 1; i < changed_chips.size(); i++) { //i == 0 is new chip it don't need animation time
QMetaObject::invokeMethod(m_qml_root, "setPreAnimationTicks",
Q_ARG(QVariant, changed_chips[i].row),
Q_ARG(QVariant, changed_chips[i].col),
Q_ARG(QVariant, i - 1));
Q_ARG(QVariant, changed_chips[i].row),
Q_ARG(QVariant, changed_chips[i].col),
Q_ARG(QVariant, i - 1));
}
m_maxDelay = qMax(0, (int)(changed_chips.size()) - 2);
}
for (int i = 0; i < 8; i++) {
for (int i = 0; i < 8; i++)
for (int j = 0; j < 8; j++) {
QString new_state = "";
if (m_game) // showing empty board if has no game
......@@ -173,7 +173,6 @@ void KReversiView::updateBoard()
Q_ARG(QVariant, j),
Q_ARG(QVariant, false));
}
}
if (m_game && m_showLegalMoves) {
PosList possible_moves = m_game->possibleMoves();
......
......@@ -231,5 +231,4 @@ private:
*/
int m_maxDelay;
};
#endif
......@@ -58,12 +58,14 @@ int main(int argc, char **argv)
KApplication application;
KGlobal::locale()->insertCatalog( QLatin1String( "libkdegames" ));
if (application.isSessionRestored()) {
RESTORE(KReversiMainWindow);
if( application.isSessionRestored() )
{
RESTORE(KReversiMainWindow)
}
else {
else
{
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
KReversiMainWindow *mainWin = new KReversiMainWindow(0, args->isSet("demo"));
KReversiMainWindow *mainWin = new KReversiMainWindow( 0, args->isSet( "demo" ) );
args->clear();
mainWin->show();
}
......
......@@ -22,7 +22,6 @@
* Boston, MA 02110-1301, USA.
*
********************************************************************/
#include "mainwindow.h"
#include "kreversigame.h"
#include "kreversiview.h"
......@@ -72,15 +71,10 @@ static QString moveToString(const KReversiPos& move)
}
KReversiMainWindow::KReversiMainWindow(QWidget* parent, bool startDemo)
: KXmlGuiWindow(parent), m_view(0), m_game(0)
, m_historyDock(0)
, m_historyView(0)
, m_firstShow(true)
, m_startInDemoMode(startDemo)
, m_lowestSkill(6)
, m_undoAct(0)
, m_hintAct(0)
, m_demoAct(0)
: KXmlGuiWindow(parent), m_view(0), m_game(0),
m_historyDock(0), m_historyView(0),
m_firstShow(true), m_startInDemoMode(startDemo), m_lowestSkill(6),
m_undoAct(0), m_hintAct(0), m_demoAct(0)
{
statusBar()->insertItem(i18n("Your turn."), 0);
statusBar()->insertItem(i18n("You: %1", 2), PLAYER_STATUSBAR_ID);
......@@ -147,8 +141,7 @@ void KReversiMainWindow::setupActions()
connect(m_coloredChipsAct, SIGNAL(triggered(bool)), SLOT(slotUseColoredChips(bool)));
// NOTE: read/write this from/to config file? Or not necessary?
KToggleAction *showMovesAct = new KToggleAction(KIcon(QLatin1String("view-history")),
i18n("Show Move History"), this);
KToggleAction *showMovesAct = new KToggleAction(KIcon(QLatin1String("view-history")), i18n("Show Move History"), this);
actionCollection()->addAction(QLatin1String("show_moves"), showMovesAct);
connect(showMovesAct, SIGNAL(triggered(bool)), SLOT(slotShowMovesHistory(bool)));
}
......
......@@ -20,7 +20,6 @@
* Boston, MA 02110-1301, USA.
*
********************************************************************/
#ifndef KREVERSI_MAIN_WINDOW_H
#define KREVERSI_MAIN_WINDOW_H
......@@ -79,5 +78,4 @@ private:
KSelectAction* m_animSpeedAct;
KToggleAction* m_coloredChipsAct;
};
#endif
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