Fixed krazy found spelling, foreach and desktop file issues
svn path=/trunk/playground/games/kgo/; revision=838781
This commit is contained in:
parent
f924c9e67c
commit
97c45e24d0
5 changed files with 46 additions and 53 deletions
|
@ -139,7 +139,7 @@ bool GoEngine::loadSgf(const QString &fileName, int moveNumber)
|
|||
|
||||
kDebug() << "Attempting to load move" << moveNumber << "from" << fileName;
|
||||
|
||||
QByteArray msg("loadsgf " + fileName.toLatin1() + " ");
|
||||
QByteArray msg("loadsgf " + fileName.toLatin1() + ' ');
|
||||
msg.append(QString::number(moveNumber));
|
||||
msg.append("\n");
|
||||
m_process.write(msg);
|
||||
|
@ -157,7 +157,7 @@ bool GoEngine::saveSgf(const QString &fileName)
|
|||
|
||||
kDebug() << "Attempting to save game to" << fileName;
|
||||
|
||||
m_process.write("printsgf " + fileName.toLatin1() + "\n");
|
||||
m_process.write("printsgf " + fileName.toLatin1() + '\n');
|
||||
return waitResponse();
|
||||
}
|
||||
|
||||
|
@ -399,10 +399,10 @@ QPair<GoEngine::PlayerColor, GoEngine::Stone> GoEngine::lastMove()
|
|||
if (waitResponse()) {
|
||||
if (m_response.startsWith("white")) {
|
||||
pair.first = WhitePlayer;
|
||||
pair.second = Stone(m_response.split(" ")[1]);
|
||||
pair.second = Stone(m_response.split(' ')[1]);
|
||||
} else if (m_response.startsWith("black")) {
|
||||
pair.first = BlackPlayer;
|
||||
pair.second = Stone(m_response.split(" ")[1]);
|
||||
pair.second = Stone(m_response.split(' ')[1]);
|
||||
}
|
||||
}
|
||||
return pair;
|
||||
|
@ -413,7 +413,7 @@ GoEngine::FieldStatus GoEngine::whatColor(const Stone &field)
|
|||
if (!field.isValid())
|
||||
return InvalidField;
|
||||
|
||||
m_process.write("color " + field.toLatin1() + "\n");
|
||||
m_process.write("color " + field.toLatin1() + '\n');
|
||||
if (waitResponse()) {
|
||||
if (m_response == "white") return WhiteField;
|
||||
else if (m_response == "black") return BlackField;
|
||||
|
@ -437,7 +437,7 @@ QList<GoEngine::Stone> GoEngine::listStones(PlayerColor color)
|
|||
msg.append("\n");
|
||||
m_process.write(msg);
|
||||
if (waitResponse()) {
|
||||
foreach (QString pos, m_response.split(" "))
|
||||
foreach (const QString &pos, m_response.split(' '))
|
||||
list.append(Stone(pos));
|
||||
}
|
||||
return list;
|
||||
|
@ -449,7 +449,7 @@ QList<QPair<GoEngine::PlayerColor, GoEngine::Stone> > GoEngine::moveHistory()
|
|||
|
||||
m_process.write("move_history\n");
|
||||
if (waitResponse()) {
|
||||
QStringList tokens = m_response.split(" ");
|
||||
QStringList tokens = m_response.split(' ');
|
||||
for (int i = 0; i < tokens.size(); i += 2) {
|
||||
if (tokens[i] == "white")
|
||||
list.append(QPair<PlayerColor, Stone>(WhitePlayer, Stone(tokens[i + 1])));
|
||||
|
@ -468,7 +468,7 @@ QList<GoEngine::Stone> GoEngine::moveHistory(PlayerColor color)
|
|||
|
||||
m_process.write("move_history\n");
|
||||
if (waitResponse()) {
|
||||
QStringList tokens = m_response.split(" ");
|
||||
QStringList tokens = m_response.split(' ');
|
||||
for (int i = 0; i < tokens.size(); i += 2)
|
||||
if (color == WhitePlayer && tokens[i] == "white" || color == BlackPlayer && tokens[i] == "black")
|
||||
list.append(Stone(Stone(tokens[i + 1])));
|
||||
|
@ -481,7 +481,7 @@ int GoEngine::countLiberties(const Stone &field)
|
|||
if (!field.isValid())
|
||||
return -1;
|
||||
|
||||
m_process.write("countlib " + field.toLatin1() + "\n");
|
||||
m_process.write("countlib " + field.toLatin1() + '\n');
|
||||
if (waitResponse())
|
||||
return m_response.toInt();
|
||||
else
|
||||
|
@ -494,10 +494,10 @@ QList<GoEngine::Stone> GoEngine::findLiberties(const Stone &field)
|
|||
if (!field.isValid())
|
||||
return list;
|
||||
|
||||
m_process.write("findlib " + field.toLatin1() + "\n");
|
||||
m_process.write("findlib " + field.toLatin1() + '\n');
|
||||
waitResponse();
|
||||
|
||||
foreach (QString entry, m_response.split(' '))
|
||||
foreach (const QString &entry, m_response.split(' '))
|
||||
list.append(GoEngine::Stone(entry));
|
||||
return list;
|
||||
}
|
||||
|
@ -552,7 +552,7 @@ QList<GoEngine::Stone> GoEngine::legalMoves(PlayerColor color)
|
|||
msg.append("black\n");
|
||||
m_process.write(msg);
|
||||
if (waitResponse()) {
|
||||
foreach (QString entry, m_response.split(' '))
|
||||
foreach (const QString &entry, m_response.split(' '))
|
||||
list.append(GoEngine::Stone(entry));
|
||||
}
|
||||
return list;
|
||||
|
@ -580,7 +580,7 @@ QString GoEngine::attack(const Stone &field)
|
|||
if (!field.isValid())
|
||||
return QString();
|
||||
|
||||
m_process.write("attack " + field.toLatin1() + "\n");
|
||||
m_process.write("attack " + field.toLatin1() + '\n');
|
||||
if (waitResponse())
|
||||
return m_response;
|
||||
else
|
||||
|
@ -592,7 +592,7 @@ QString GoEngine::defend(const Stone &field)
|
|||
if (!field.isValid())
|
||||
return QString();
|
||||
|
||||
m_process.write("defend " + field.toLatin1() + "\n");
|
||||
m_process.write("defend " + field.toLatin1() + '\n');
|
||||
if (waitResponse())
|
||||
return m_response;
|
||||
else
|
||||
|
@ -616,7 +616,7 @@ QString GoEngine::owlAttack(const Stone &field)
|
|||
if (!field.isValid())
|
||||
return QString();
|
||||
|
||||
m_process.write("owl_attack " + field.toLatin1() + "\n");
|
||||
m_process.write("owl_attack " + field.toLatin1() + '\n');
|
||||
if (waitResponse())
|
||||
return m_response;
|
||||
else
|
||||
|
@ -628,7 +628,7 @@ QString GoEngine::owlDefense(const Stone &field)
|
|||
if (!field.isValid())
|
||||
return QString();
|
||||
|
||||
m_process.write("owl_defend " + field.toLatin1() + "\n");
|
||||
m_process.write("owl_defend " + field.toLatin1() + '\n');
|
||||
if (waitResponse())
|
||||
return m_response;
|
||||
else
|
||||
|
@ -640,7 +640,7 @@ QString GoEngine::evalEye(const Stone &field)
|
|||
if (!field.isValid())
|
||||
return QString();
|
||||
|
||||
m_process.write("eval_eye " + field.toLatin1() + "\n");
|
||||
m_process.write("eval_eye " + field.toLatin1() + '\n');
|
||||
if (waitResponse())
|
||||
return m_response;
|
||||
else
|
||||
|
@ -652,7 +652,7 @@ GoEngine::DragonStatus GoEngine::dragonStatus(const Stone &field)
|
|||
if (!field.isValid())
|
||||
return UnknownDragon;
|
||||
|
||||
m_process.write("dragon_status " + field.toLatin1() + "\n");
|
||||
m_process.write("dragon_status " + field.toLatin1() + '\n');
|
||||
if (waitResponse()) {
|
||||
if (m_response == "alive") return AliveDragon;
|
||||
else if (m_response == "critical") return CriticalDragon;
|
||||
|
@ -665,7 +665,7 @@ GoEngine::DragonStatus GoEngine::dragonStatus(const Stone &field)
|
|||
|
||||
bool GoEngine::sameDragon(const Stone &field1, const Stone &field2)
|
||||
{
|
||||
m_process.write("same_dragon " + field1.toLatin1() + " " + field2.toLatin1() + "\n");
|
||||
m_process.write("same_dragon " + field1.toLatin1() + ' ' + field2.toLatin1() + '\n');
|
||||
if (waitResponse() && m_response == "1")
|
||||
return true;
|
||||
else
|
||||
|
@ -677,7 +677,7 @@ QString GoEngine::dragonData(const Stone &field)
|
|||
QByteArray msg("dragon_data ");
|
||||
if (field.isValid())
|
||||
msg.append(field.toLatin1());
|
||||
msg.append("\n");
|
||||
msg.append('\n');
|
||||
m_process.write(msg);
|
||||
if (waitResponse())
|
||||
return m_response;
|
||||
|
@ -690,10 +690,7 @@ GoEngine::FinalState GoEngine::finalStatus(const Stone &field)
|
|||
if (!field.isValid())
|
||||
return FinalStateInvalid;
|
||||
|
||||
QByteArray msg("final_status ");
|
||||
msg.append(field.toLatin1());
|
||||
msg.append("\n");
|
||||
m_process.write(msg);
|
||||
m_process.write("final_status " + field.toLatin1() + '\n');
|
||||
if (waitResponse()) {
|
||||
if (m_response == "alive") return FinalAlive;
|
||||
else if (m_response == "dead") return FinalDead;
|
||||
|
@ -722,10 +719,10 @@ QList<GoEngine::Stone> GoEngine::finalStatusList(FinalState state)
|
|||
case FinalDame: msg.append("dame"); break;
|
||||
case FinalStateInvalid: /* Will never happen */ break;
|
||||
}
|
||||
msg.append("\n");
|
||||
msg.append('\n');
|
||||
m_process.write(msg);
|
||||
if (waitResponse()) {
|
||||
foreach (QString entry, m_response.split(' '))
|
||||
foreach (const QString &entry, m_response.split(' '))
|
||||
list.append(Stone(entry));
|
||||
}
|
||||
return list;
|
||||
|
@ -841,7 +838,7 @@ QString GoEngine::wormData(const Stone &field)
|
|||
QByteArray msg("worm_data ");
|
||||
if (field.isValid())
|
||||
msg.append(field.toLatin1());
|
||||
msg.append("\n");
|
||||
msg.append('\n');
|
||||
m_process.write(msg);
|
||||
if (waitResponse())
|
||||
return m_response;
|
||||
|
@ -855,9 +852,9 @@ QList<GoEngine::Stone> GoEngine::wormStones(const Stone &field)
|
|||
if (!field.isValid())
|
||||
return list;
|
||||
|
||||
m_process.write("worm_stones " + field.toLatin1() + "\n");
|
||||
m_process.write("worm_stones " + field.toLatin1() + '\n');
|
||||
if (waitResponse()) {
|
||||
foreach (QString entry, m_response.split(' '))
|
||||
foreach (const QString &entry, m_response.split(' '))
|
||||
list.append(Stone(entry));
|
||||
}
|
||||
return list;
|
||||
|
@ -867,7 +864,7 @@ bool GoEngine::tuneMoveOrdering(int parameters)
|
|||
{
|
||||
QByteArray msg("tune_move_ordering ");
|
||||
msg.append(QString::number(parameters));
|
||||
msg.append("\n");
|
||||
msg.append('\n');
|
||||
m_process.write(msg);
|
||||
return waitResponse();
|
||||
}
|
||||
|
@ -877,7 +874,7 @@ QList<QString> GoEngine::help()
|
|||
m_process.write("help\n");
|
||||
QList<QString> list;
|
||||
if (waitResponse()) {
|
||||
foreach (QString entry, m_response.split('\n'))
|
||||
foreach (const QString &entry, m_response.split('\n'))
|
||||
list.append(entry);
|
||||
}
|
||||
return list;
|
||||
|
@ -887,7 +884,7 @@ bool GoEngine::reportUncertainty(bool enabled)
|
|||
{
|
||||
QByteArray msg("report_uncertainty ");
|
||||
msg.append(enabled ? "on" : "off");
|
||||
msg.append("\n");
|
||||
msg.append('\n');
|
||||
m_process.write(msg);
|
||||
return waitResponse();
|
||||
}
|
||||
|
@ -897,7 +894,7 @@ QString GoEngine::shell(const QString &command)
|
|||
if (command.isEmpty())
|
||||
return QString();
|
||||
|
||||
m_process.write(command.toLatin1() + "\n");
|
||||
m_process.write(command.toLatin1() + '\n');
|
||||
if (waitResponse())
|
||||
return m_response;
|
||||
else
|
||||
|
@ -909,7 +906,7 @@ bool GoEngine::knownCommand(const QString &command)
|
|||
if (command.isEmpty())
|
||||
return false;
|
||||
|
||||
m_process.write("known_command " + command.toLatin1() + "\n");
|
||||
m_process.write("known_command " + command.toLatin1() + '\n');
|
||||
return waitResponse();
|
||||
}
|
||||
|
||||
|
@ -918,7 +915,7 @@ QString GoEngine::echo(const QString &command)
|
|||
if (command.isEmpty())
|
||||
return QString();
|
||||
|
||||
m_process.write("echo " + command.toLatin1() + "\n");
|
||||
m_process.write("echo " + command.toLatin1() + '\n');
|
||||
if (waitResponse())
|
||||
return m_response;
|
||||
else
|
||||
|
@ -932,7 +929,7 @@ void GoEngine::readStandardOutput()
|
|||
|
||||
void GoEngine::readStandardError()
|
||||
{
|
||||
kWarning() << "Go engine I/O error occured:\n" << m_process.readAllStandardError();
|
||||
kWarning() << "Go engine I/O error occurred:\n" << m_process.readAllStandardError();
|
||||
}
|
||||
|
||||
bool GoEngine::waitResponse()
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace KGo {
|
|||
* // Run a session with a Go engine in GTP mode
|
||||
* engine->run("gnugo --mode gtp");
|
||||
*
|
||||
* // Get some informations about the Go engine
|
||||
* // Get some information about the Go engine
|
||||
* engine->name();
|
||||
* engine->version();
|
||||
* engine->help();
|
||||
|
@ -122,7 +122,7 @@ public:
|
|||
* @param x The x coordinate of the stone
|
||||
* @param y The y coordinate of the stone
|
||||
*/
|
||||
Stone(char x = -1, int y = -1) : m_x(x), m_y(y) {}
|
||||
explicit Stone(char x = -1, int y = -1) : m_x(x), m_y(y) {}
|
||||
|
||||
/**
|
||||
* Constructor to set from a stone given as a string.
|
||||
|
@ -132,7 +132,7 @@ public:
|
|||
Stone(const QString &stone);
|
||||
|
||||
/**
|
||||
* Checks wether the stone is valid or not
|
||||
* Checks whether the stone is valid or not
|
||||
*/
|
||||
bool isValid() const;
|
||||
|
||||
|
@ -177,7 +177,7 @@ public:
|
|||
Score(const QString &scoreString = QString());
|
||||
|
||||
/**
|
||||
* Checks wether the score is valid or not.
|
||||
* Checks whether the score is valid or not.
|
||||
*/
|
||||
bool isValid() const;
|
||||
|
||||
|
@ -233,7 +233,7 @@ public:
|
|||
bool run(const QString &command = "gnugo --mode gtp");
|
||||
|
||||
/**
|
||||
* Check wether the GoEngine object is connected to a Go engine, running
|
||||
* Check whether the GoEngine object is connected to a Go engine, running
|
||||
* and waiting for commands to be fed with.
|
||||
*/
|
||||
bool isRunning() const { return m_process.state() == QProcess::Running; }
|
||||
|
@ -251,7 +251,7 @@ public:
|
|||
|
||||
/**
|
||||
* Load a SGF file, possibly up to a move number or the first
|
||||
* occurence of a move.
|
||||
* occurrence of a move.
|
||||
*
|
||||
* @param fileName The SGF file name
|
||||
* @param moveNumber The move number
|
||||
|
@ -437,7 +437,7 @@ public:
|
|||
QList<Stone> findLiberties(const Stone &field);
|
||||
|
||||
/**
|
||||
* Tell wether a move at 'field' for player 'color' is legal.
|
||||
* Tell whether a move at 'field' for player 'color' is legal.
|
||||
*
|
||||
* @param color The player to test the move for
|
||||
* @param field The field to test the move for
|
||||
|
@ -511,7 +511,7 @@ public:
|
|||
QString owlDefense(const Stone &field);
|
||||
|
||||
/**
|
||||
* Evaluate an eye space and returns a minumum and maximum number of
|
||||
* Evaluate an eye space and returns a minimum and maximum number of
|
||||
* eyes. If these differ an attack and a defense point are additionally
|
||||
* returned. If the field is not an eye space or not of unique color,
|
||||
* a single -1 is returned.
|
||||
|
@ -537,7 +537,7 @@ public:
|
|||
DragonStatus dragonStatus(const Stone &field);
|
||||
|
||||
/**
|
||||
* Determine wether two stones belong to the same dragon.
|
||||
* Determine whether two stones belong to the same dragon.
|
||||
*
|
||||
* @param field1 The first stone
|
||||
* @param field2 The second stone
|
||||
|
@ -705,7 +705,7 @@ public:
|
|||
QString shell(const QString &command);
|
||||
|
||||
/**
|
||||
* Evaluate wether a command is known.
|
||||
* Evaluate whether a command is known.
|
||||
*
|
||||
* @param command The command to evaluate
|
||||
*/
|
||||
|
@ -748,7 +748,7 @@ private slots:
|
|||
/**
|
||||
* This slot reads everything from the process's stderr. This is
|
||||
* mainly for debugging purposes, because this should only happen
|
||||
* if a bug occured.
|
||||
* if a bug occurred.
|
||||
*/
|
||||
void readStandardError();
|
||||
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
[Desktop Entry]
|
||||
Type=Application
|
||||
Icon=kgo
|
||||
Encoding=UTF-8
|
||||
Exec=kgo %i -caption "%c"
|
||||
Terminal=false
|
||||
Categories=Qt;KDE;Game;BoardGame;
|
||||
DocPath=kgo/index.html
|
||||
#X-KDE-StartupNotify=true
|
||||
#X-DBUS-StartupType=Multi
|
||||
|
||||
Name=KGo
|
||||
Name[sv]=Kgo
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
* based on the parameters.
|
||||
*
|
||||
* @param fileName The SGF file to load the game from
|
||||
* @param showInfo Wether to show some info found in the SGF or not
|
||||
* @param showInfo Whether to show some info found in the SGF or not
|
||||
*/
|
||||
void setupLoadedGame(const QString &fileName, bool showInfo = false);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<default>default</default>
|
||||
</entry>
|
||||
<entry name="ShowBoardLabels" type="Bool">
|
||||
<label>Determines wether board labels are shown</label>
|
||||
<label>Determines whether board labels are shown</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
</group>
|
||||
|
|
Loading…
Add table
Reference in a new issue