Is the king safe, picoEngine?


One of the really important rules of playing chess, in fact, the rule upon which the entire game hinges, is king safety. You can’t make a move that puts your king in an unsafe position. This position of unsafe-ness is referred to as ‘check’. If you can’t find a way to get out of the position of being in ‘check’, then you are in ‘checkmate’.

Of course, if you are not in ‘check’ but any move would make you so, it is called a ‘stalemate’.

Thus, you can see the absolute need for a method or function to assess if the king is in check or not. So, I borrowed a method from my previous work in Java, the justchess engine. Of course it had to be edited for C++, but since both languages are object oriented programming languages, then it wasn’t too difficult.

You can check the commit at my GitLab for the full scoop, but essentially, my method assumes that the king is safe unless proven otherwise. This saves time, because at any point, if the king is proven unsafe, or in check, it will stop recursing through the board and other pieces and return a status of false: the king is not safe.

Linux – keep it simple.


Qt Error: ‘string’ was not declared in this scope.

Oddly enough, I ran into this same problem while using SFML. Here in Qt-creator, I’m getting this error while trying to use a string. I declared something like so:

#include <QCoreApplication>
#include <QDebug>
#include <QList>

int main(int argc, char *argv[])
    QCoreApplication a(argc, argv);

    QList<String> myStringList;

    myStringList << "Howdy."
                 << " I "
                 << " like this"
                 << " course on Qt.";

    myStringList.append(" I hope");
    myStringList.append(" you do too!");

    //qDebug() << myStringList[1];

    for (int i=0; i < myStringList.count(); i++) {
        qDebug() << myStringList[i];

    return a.exec();

And I get the error that the string is not declared in this scope! So, I tried adding:

#include <string>

to add the string library from C++. However, then I got errors when returning those strings to qDebug, which said it couldn’t take a ‘char’ as a ‘string’.

Well, just like SFML, Qt has its very own string library, and it is automatically included, called QString, like this:

QList<QString> myStringList;

QString automagically changes the string to character or strings or whatever to make it work when you need it to. Seems like a bit of laziness for me as a programmer, but pretty handy and very convenient in my Qt apps!

Linux – keep it simple.

Once again, and from the top, picoEngine.

Last time I mentioned how the UCI (Universal Chess Interface) required two types of input, the FEN input, and a move by move input style. The second is rather interesting, especially for the internal chess board I have set up, because the input uses standard notation with alphanumeric characters.


Here you can see my code in action, moving the pieces of the board.

Once I figured out how to convert char (actors) to int (egers) than all was well, but doing that is harder than it seems. Especially coming from Java to C++. I would think that there was a more “intuitive” way to do this, but alas, I could not find one.

Supposedly, you could simply use it like so:

char aChar = ‘1’;

char bChar = ‘a’;

int c = aChar;

int d = bChar;

But I get strange numbers from that. Instead, I needed to do this:

char aChar = ‘1’;

char bChar = ‘d’;

int c = aChar – ‘0’;

int d = bChar – ‘a’;

To convert them to useful numbers. Now it would return 4 for d, and 1 for 1. Great huh? Then I just used some simple math:

int first =63 – ((sepVect[k].at(0) – ‘a’ + 1) + (((sepVect[k].at(1) – ‘1’) * 8) – 1));

int second =63 – ((sepVect[k].at(2) – ‘a’ + 1) + (((sepVect[k].at(3) – ‘1’) * 8) – 1));

And converted them to space numbers for my board! It was pretty easy after that, to just move the piece from the first spot to the second spot and leave a blank space behind. Be sure to check out the full code on my GitLab repository!

Linux – keep it simple.

QLayout::addChildLayout: layout already has a parent!


While working with layouts in Qt creator, I ran into an interesting problem. I am trying to add my “gridLayout_2” (the box with 9 push buttons) into the “myGrid” (the box with 8 text labels). When I run this code:

#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent) :
    ui(new Ui::Widget)

    QGridLayout * myGrid = new QGridLayout(this);



    delete ui;

I get this error:

QLayout::addChildLayout: layout “gridLayout_2” already has a parent

And the “gridLayout_2” is not added to the “myGrid” layout. At first I thought I was doing something wrong (maybe I still am), but I found that this is a known bug in Qt Creator:

QBoxLayout::addLayout() and QGridLayout::addLayout() functions should reparent the added layout automatically if it already has a parent. Currently these functions call QLayout::addChildLayout() which does not add the child layout if it already has been added to some other layout i.e. has a parent.

Please note that QBoxLayout::addWidget() and QGridLayout::addWidget() reparent the added widget. Thus there is an inconsistency on the functionality.

So I didn’t figure out a way to add a grid layout inside one of the grids of another grid layout. If you figure this out, then be sure to let me know!

Linux – keep it simple.

picoEngine Meets FEN


One of the more interesting parts to programming chess engines, is using the UCI, Universal Chess Interface. In that interface standard are very specific settings. One of those is that engines should accept input as either move by move, or through FEN.

The FEN part was actually quite easy. Just breaking down characters of the line and figuring out what goes where. The toughest part was understanding vectors so I could do what I wanted to do. Here’s a glimps of the code:

vector<string> split(string str, char delimiter) {
vector<string> internal;
stringstream ss(str); // Turn the string into a stream.
string tok;

while(getline(ss, tok, delimiter)) {

return internal;
………………………………………..Edited for space…………………………………
void inputPosition(string posString)
vector<string> sepVect = split(posString, ‘ ‘);
string str1 = sepVect[1];
if (sepVect[1] == “fen”)
// FEN board setup.
string stringBoard = “”;
string str2 = sepVect[2];
for (int i = 0; (unsigned)i < str2.length(); i++) {
char myChar =;
if (isdigit(myChar))
{ int imyChar = myChar – ‘0’;
for (int a = 0; a < imyChar; a++)
{ stringBoard = stringBoard + “-“; }
else if (isalpha(myChar))
{ stringBoard = stringBoard + myChar; }
} // end for.
int j = stringBoard.length();
for (int i = 0; i < j; i++) {
if (i < 64){ theBoard[i] =; }
if (sepVect[3].at(0) == ‘w’)
{ whitesTurn = true; } else { whitesTurn = false; }
if (sepVect[4].at(0) == ‘K’)
{ Kcastle = true; } else { Kcastle = false; }
if (sepVect[4].at(1) == ‘Q’)
{ Qcastle = true; } else { Qcastle = false; }
if (sepVect[4].at(2) == ‘k’)
{ kcastle = true; } else { kcastle = false; }
if (sepVect[4].at(3) == ‘q’)
{ qcastle = true; } else { qcastle = false; }
if (sepVect[5].at(0) == ‘-‘)
{ enPassant = false;} else { enPassant = true;}
moveSince = stoi (sepVect[6]);
turnCount = stoi (sepVect[7]);
} // End FEN

I just broke down the string into vectors separated by spaces. Then in each vector, I figured out where the piece needed to go, or how many blank spaces I needed.

Now I still have to work out a few oddities, but I think this should work fairly well, and seems to have in the few test runs I’ve given it. You can check out the whole commit on my GitLab if you’d like!

Linux – keep it simple.

Qt Creator, changing the default template for .pro files….


The .pro file holds key information for your project that is used for compiling.

One issue that I have previously mentioned here was that certain styles of lambdas require you to use a C++ standard of 2011 or newer. This can be quickly overcome by adding the proper QMAKE flags to your .pro file in your project directory.

This becomes a bit tedious though, when you forget that and need to re-find the QMAKE flags so you can add them to your .pro file every time that you start a new project. Some web searching lead me to the conclusion that the templates for the files created in Qt Creator are held here:


There are numerous folders here, each pertaining to a different kind of application/program that you can make. Within each folder are the template files used to create the default files you get when you create a new project. If you open them as a root user, you can edit them to your hearts content and then save them. Next time that you use Qt Creator to create a new project, these now edited files will be used (no restarting Qt Creator required).

This works great, and I have fixed numerous .pro files for console apps, etc., however, the one I can’t find is the Qt Widget Application .pro file, and that is the one I use the most! So I’ll keep looking. In the mean time, you can use these to edit your other default files.

Linux – keep it simple.

BLOX2: KCAL – Sovoca’s Color Calibration

This is my OnePlus One with my KPPD control app.

Another update to the BLOX2 (BLU Life One X2) kernel, I just added Sovoca’s KCAL color calibration for the screen! You can check out the commit on GitLab, but unfortunately, while it builds without error, it doesn’t function quite right. I am looking into the commits further and considering KPPD as well. It’s all part of my video series for modifying 64 bit kernels, which you can check out on my YouTube channel:

Linux – keep it simple.

Blindfold Chess, Mr. picoEngine?

While building the picoEngine in C++, I will often be wondering what the engine is thinking. One of the problems is that I can not “see” the engine’s board, so I don’t know why it would make a particular move. So, I added a print function. This also is in keeping with my “engine mentor” Logic Crazy, who often used this technique so he could evaluate the board position.

The code is rather straight forward:

string printBoard = “”;

for (int i = 0; i < 64; i++){

printBoard = printBoard + theBoard[i];


cout << printBoard << ” ” << whitesTurn << ” ” << Kcastle

<< ” ” << Qcastle << ” ” << kcastle << ” ” << qcastle

<< ” ” << moveSince << ” ” << turnCount << endl;

Not only did it work, but it seems to be rather helpful. Now, as I work on inserting positions via FEN and the startpos moves system that is defined in the UCI, it makes checking my work easy. Here is a screen shot of it in action:


Linux – keep it simple.

error: no matching function for call to ‘QAction::QAction(const char [5])’


While working through section 4 of my Qt GUI creator course, I ran into an interesting error:

/home/alaskalinuxuser/Documents/qt_course/section_4_21_qmainwindow/mainwindow.cpp:19: error: no matching function for call to ‘QAction::QAction(const char [5])’
QAction * quitAction = new QAction(“Quit”);

What made the error interesting was that my code mirrored the instructors to a T:

// Now some QActions….
// Quiting
QAction * quitAction = new QAction(“Quit”);
// And connect it.
connect (quitAction,&QAction::triggered,[=](){

However, after reading up a bit on it, I needed to add “this” to my QAction, like so:

// Now some QActions….
// Quiting
QAction * quitAction = new QAction(“Quit”, this);
// And connect it.
connect (quitAction,&QAction::triggered,[=](){

Once I did that, it was smooth sailing. I don’t know for sure, it may be because the instructor was using Windows with MinGW and I am using Linux with GCC, or if it is a Qt version difference. Either way, if you run into this error, here’s the quick fix!

Linux – keep it simple.

BLOX2: Voltage Control for the Little Cores!


Another update to the BLOX2 (BLU Life One X2) kernel, I just extended the voltage control from the big cores to the little cores as well! You can check out the commit on GitLab, but essentially we saw that the “bc” in the code stood for “big cores” and we made a duplicate of the code, labeled “lc” for “little cores”. It’s all part of my video series for modifying 64 bit kernels, which you can check out on my YouTube channel:

Linux – keep it simple.