void CMoveGen::getEvasions(CMoveList& moves) const { bb_t mask_evasion = bbEmptyBoard; EColor side = board().getSide(); bb_t x = board().getPieceBits(eKing, side); while (x) { EField kingpos = popFirstBit(x); bb_t attacks = board().getAttackBy(kingpos, toggleColor(side)); mask_evasion |= attacks; while (attacks) { EField from = popFirstBit(attacks); mask_evasion |= gl_bitboards.getGap(from, kingpos); } } genMoves(moves, true, true, bbFullBoard, mask_evasion); }
EtaKeyboard::EtaKeyboard(QWidget *parent) : QMainWindow(parent) { setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowDoesNotAcceptFocus | Qt::X11BypassWindowManagerHint); QDesktopWidget dw; screenWidth = dw.screenGeometry(dw.primaryScreen()).width(); screenHeight = dw.screenGeometry(dw.primaryScreen()).height(); key_height = screenHeight / 16; key_width = screenWidth / 26; dock_height = screenHeight / 30; m_width = 13*key_width; m_height = key_height*4+dock_height; configpath = QDir::homePath() + "/.config/etak/config.ini"; color = "gray"; Settings::setLanguage("trq"); Settings::setAutoShowBool(true); QFileInfo checkConfig(configpath); if (checkConfig.exists() && checkConfig.isFile()) { preferences = new QSettings(configpath,QSettings::IniFormat); preferences->beginGroup("etak"); Settings::setLanguage(preferences->value("Language").toString()); color= preferences->value("Color").toString(); Settings::setAutoShowBool(preferences->value("AutoShow").toBool()); preferences->endGroup(); } Settings::setColors(color); // 'blue' or 'gray' Helpers::langChange(Settings::getLanguage()); // intialization of X keyboard layout as trq setStyleSheet("background-color: "+Settings::getBackgroundColor()+";"); setGeometry(screenWidth/2+m_width,0,m_width,0); out = LabelInstance::Instance(); // Output text right up to keyboard out->setParent(this); out->setGeometry(0,0,m_width,dock_height); out->setStyleSheet("QLabel{color: white; qproperty-alignment: AlignCenter;}"); QFont f; f.setPointSize(key_height / 5); out->setFont(f); settingsRectangle = new QDialog(this,Qt::X11BypassWindowManagerHint); settingsRectangle->setStyleSheet("background-color: "+Settings::getBackgroundColor()+";"); settingsRectangle->hide(); toggleAuto = new QPushButton(settingsRectangle); toggleAuto->setGeometry(0,0,key_width*2,dock_height); toggleAuto->setCheckable(true); toggleAuto->setChecked(Settings::getAutoShowBool()); if(Settings::getAutoShowBool()) { toggleAuto->setText(QString::fromUtf8("Otomatik çıkma : Kapat")); } else { toggleAuto->setText(QString::fromUtf8("Otomatik çıkma : Aç")); } toggleAuto->setStyleSheet(Settings::getStyleSheet()+Settings::getStyleSheetExtra()); QFont g; g.setPointSize(key_height / 9); toggleAuto->setFont(g); connect(toggleAuto,SIGNAL(clicked()),this,SLOT(toggleAutoShow())); passwordButton = new QPushButton(this); passwordButton->setGeometry(1,1,dock_height,dock_height); passwordButton->setStyleSheet(Settings::getStyleSheet()+Settings::getStyleSheetExtra()); passwordButton->setCheckable(true); passwordButton->setChecked(false); passwordButton->setText("P"); g.setBold(true); g.setPointSize(key_height/4); passwordButton->setFont(g); QRegion *region = new QRegion(*(new QRect(passwordButton->x()+2,passwordButton->y()+2,dock_height-6,dock_height-6)),QRegion::Ellipse); passwordButton->setMask(*region); connect(passwordButton,SIGNAL(clicked()),this,SLOT(togglePassword())); QHash<int, QList<unsigned int> > hash; QList<unsigned int> listtmp; for ( int i = 24 ; i < 36 ; ++i) { listtmp.append(i); } hash.insert(1,listtmp); listtmp.clear(); for ( int j = 38 ; j < 49 ; ++j) { listtmp.append(j); } hash.insert(2,listtmp); listtmp.clear(); for ( int k = 52 ; k < 61 ; ++k) { listtmp.append(k); } hash.insert(3,listtmp); listtmp.clear(); Key *tmp; int posrow = key_width; int posy = dock_height; int posx; AlphaKey *tmp2; QString tmpLanguageLayout =""; if (Settings::getLanguage() == "trq") { tmpLanguageLayout = "TRQ"; } else if (Settings::getLanguage() == "trf") { tmpLanguageLayout = "TRF"; } else if (Settings::getLanguage() == "arabic") { tmpLanguageLayout = QString::fromUtf8("العربئة"); } lang = new SpecialKey(settingsRectangle,0,dock_height,key_width,key_height,tmpLanguageLayout); connect(lang,SIGNAL(clicked()),this,SLOT(changeLanguage())); tmp2 = new AlphaKey(this,0,dock_height,key_width,key_height,9,"Esc"); //Escape alpha_keys.append(tmp2); change = new SpecialKey(this,0,key_height+dock_height,key_width*3/2,key_height,"?123+"); connect(change,SIGNAL(clicked()),this,SLOT(toggleAlterns())); leftshift = new AlphaKey(this,0,key_height*2+dock_height,key_width*2,key_height,50,QString::fromUtf8("↑")); //caps alpha_keys.append(leftshift); connect(leftshift,SIGNAL(clicked()),this,SLOT(toggleCaps())); for (int y = 1 ; y<=3 ; ++y) { posx=posrow; for (int x =0; x < hash[y].length(); ++x) { if (y==2 && x==10) { tmp = new Key(this,posx,posy,key_width*3/2,key_height,hash[y].at(x)); } else { tmp = new Key(this,posx,posy,key_width,key_height,hash[y].at(x)); } keys.append(tmp); posx += key_width; } posy += key_height; posrow += key_width / 2; } tmp2 = new AlphaKey(this, posx, posy - key_height, key_width * 2, key_height, 22, QString::fromUtf8("⌫")); //backspace alpha_keys.append(tmp2); settingsButton = new QPushButton(this); settingsButton->setGeometry(0,posy,key_width,key_height); settingsButton->setStyleSheet(Settings::getStyleSheet()); QPixmap pm(":/icons/gear.png"); settingsButton->setIcon(QIcon(pm)); settingsButton->setIconSize(QSize(settingsButton->width()*2/3,settingsButton->height()*2/3)); connect(settingsButton,SIGNAL(clicked()),this,SLOT(toggleSettings())); hideButton = new QPushButton(this); hideButton->setGeometry(m_width-dock_height-1,1,dock_height,dock_height); QPixmap pm2(":/icons/window-close.png"); hideButton->setIcon(QIcon(pm2)); hideButton->setIconSize(QSize(hideButton->width(),hideButton->height())); connect(hideButton,SIGNAL(clicked()),this,SLOT(animationToggle())); colorButton = new QPushButton(settingsRectangle); colorButton->setGeometry(key_width,dock_height,key_width,key_height); colorButton->setStyleSheet(Settings::getStyleSheet()); connect(colorButton,SIGNAL(clicked()),this,SLOT(toggleColor())); tmp = new Key(this,key_width,posy,key_width,key_height,20); //asterix bottom_keys.append(tmp); tmp = new Key(this,key_width*2,posy,key_width*13/2,key_height,65); // space bottom_keys.append(tmp); tmp = new Key(this,key_width*17/2,posy,key_width,key_height,51); // comma bottom_keys.append(tmp); tmp = new Key(this,key_width*19/2,posy,key_width,key_height,61); // dot bottom_keys.append(tmp); tmp2 = new AlphaKey(this,key_width*21/2,posy,key_width*5/2,key_height,36,QString::fromUtf8("↵")); // enter alpha_keys.append(tmp2); server = new EtaLocalServer(this); Q_CHECK_PTR(server); const QString fullServerName = QString(QDir::homePath()+"/"+SERVER_NAME); QFile file(fullServerName); if (file.exists()) { file.remove(); } if (server->listen(QDir::homePath()+"/"+SERVER_NAME)) { //qDebug() << "Listenning"; } else { //qDebug() << "Failed to listen"; } connect(server, SIGNAL(newCommand(char*)), this, SLOT(onNewCommand(char*))); anime = new QPropertyAnimation(this, "geometry"); tog = false; QList<QString> alternatives; alternatives.append("1"); alternatives.append("2"); alternatives.append("3"); alternatives.append("4"); alternatives.append("5"); alternatives.append("6"); alternatives.append("7"); alternatives.append("8"); alternatives.append("9"); alternatives.append("0"); alternatives.append("braceleft"); alternatives.append("braceright"); alternatives.append("at"); alternatives.append("numbersign"); alternatives.append("dollar"); alternatives.append("percent"); alternatives.append("ampersand"); alternatives.append("parenleft"); alternatives.append("parenright"); alternatives.append("minus"); alternatives.append("less"); alternatives.append("greater"); alternatives.append("exclam"); alternatives.append("semicolon"); alternatives.append("colon"); alternatives.append("apostrophe"); alternatives.append("quotedbl"); alternatives.append("question"); alternatives.append("slash"); alternatives.append("plus"); alternatives.append("equal"); alternatives.append("underscore"); for (int cnt = 0; cnt < keys.size(); ++cnt) { keys.at(cnt)->setAlternString(alternatives.at(cnt)); } }
void CMoveGen::genMoves(CMoveList& moves, bool captures, bool quiets, bb_t from, bb_t to) const { EColor side = board().getSide(); bb_t occup = board().getOccupBits(); bb_t empty = board().getEmptyBits(); bb_t mask_to_pawn_c = board().getColorBits(toggleColor(side)) & to; bb_t mask_to_pawn_q = empty & to; bb_t mask_to_pieces = bbEmptyBoard; if (captures) mask_to_pieces |= board().getColorBits(toggleColor(side)); if (quiets) mask_to_pieces |= empty; mask_to_pieces &= to; bb_t x, y; bb_t pawns = board().getPieceBits(ePawn, side) & from; if (eWhite == side) { if (captures) { // caps NoWe x = shift_soea(shift_nowe(pawns & ~bbRank_7) & mask_to_pawn_c); while (x) moves.addDir(popFirstBit(x), eNowe); // caps NoEa x = shift_sowe(shift_noea(pawns & ~bbRank_7) & mask_to_pawn_c); while (x) moves.addDir(popFirstBit(x), eNoea); // prom NoWe x = shift_soea(shift_nowe(pawns & bbRank_7) & mask_to_pawn_c); while (x) addPromotions(moves, popFirstBit(x), eNowe); // prom NoEa x = shift_sowe(shift_noea(pawns & bbRank_7) & mask_to_pawn_c); while (x) addPromotions(moves, popFirstBit(x), eNoea); // prom North x = shift_sout(shift_nort(pawns & bbRank_7) & mask_to_pawn_q); while (x) addPromotions(moves, popFirstBit(x), eNort); // en-passant EField ep = board().getEp(); if (eNF != ep) { if (test_bit(shift_nowe(pawns), ep)) moves.add(EField(ep - eNowe), ep, eEnPassant); if (test_bit(shift_noea(pawns), ep)) moves.add(EField(ep - eNoea), ep, eEnPassant); } } if (quiets) { // single step x = shift_sout(shift_nort(pawns & ~bbRank_7) & mask_to_pawn_q); while (x) moves.addDir(popFirstBit(x), eNort); // double step x = shift_nort(shift_nort(pawns & bbRank_2) & empty) & mask_to_pawn_q; x = shift_sout(shift_sout(x)); while (x) moves.addDir(popFirstBit(x), EDir(eNort + eNort)); } } else { if (captures) { // caps SoWe x = shift_noea(shift_sowe(pawns & ~bbRank_2) & mask_to_pawn_c); while (x) moves.addDir(popFirstBit(x), eSowe); // caps SoEa x = shift_nowe(shift_soea(pawns & ~bbRank_2) & mask_to_pawn_c); while (x) moves.addDir(popFirstBit(x), eSoea); // prom SoWe x = shift_noea(shift_sowe(pawns & bbRank_2) & mask_to_pawn_c); while (x) addPromotions(moves, popFirstBit(x), eSowe); // prom SoEa x = shift_nowe(shift_soea(pawns & bbRank_2) & mask_to_pawn_c); while (x) addPromotions(moves, popFirstBit(x), eSoea); // prom South x = shift_nort(shift_sout(pawns & bbRank_2) & mask_to_pawn_q); while (x) addPromotions(moves, popFirstBit(x), eSout); EField ep = board().getEp(); if (eNF != ep) { if (test_bit(shift_sowe(pawns), ep)) moves.add(EField(ep - eSowe), ep, eEnPassant); if (test_bit(shift_soea(pawns), ep)) moves.add(EField(ep - eSoea), ep, eEnPassant); } } if (quiets) { // single step x = shift_nort(shift_sout(pawns & ~bbRank_2) & mask_to_pawn_q); while (x) moves.addDir(popFirstBit(x), eSout); // double step x = shift_sout(shift_sout(pawns & bbRank_7) & empty) & mask_to_pawn_q; x = shift_nort(shift_nort(x)); while (x) moves.addDir(popFirstBit(x), EDir(eSout + eSout)); } } x = board().getPieceBits(eKnight, side) & from; while (x) { EField from = popFirstBit(x); y = gl_bitboards.getAttacksN(from) & mask_to_pieces; while (y) moves.add(from, popFirstBit(y)); } x = board().getPieceBits(eBishop, side) & from; while (x) { EField from = popFirstBit(x); y = gl_bitboards.getAttacksB(from, occup) & mask_to_pieces; while (y) moves.add(from, popFirstBit(y)); } x = board().getPieceBits(eRook, side) & from; while (x) { EField from = popFirstBit(x); y = gl_bitboards.getAttacksR(from, occup) & mask_to_pieces; while (y) moves.add(from, popFirstBit(y)); } x = board().getPieceBits(eQueen, side) & from; while (x) { EField from = popFirstBit(x); y = gl_bitboards.getAttacksQ(from, occup) & mask_to_pieces; while (y) moves.add(from, popFirstBit(y)); } x = board().getPieceBits(eKing, side) & from; while (x) { EField from = popFirstBit(x); y = gl_bitboards.getAttacksK(from) & mask_to_pieces; while (y) moves.add(from, popFirstBit(y)); if (!board().isCheck() && quiets) { EField king_to = eNF; if (eWhite == side) { if (board().checkCastling(king_to, from, eCastleW_OO)) moves.add(from, king_to, eCastle, eCastleW_OO); if (board().checkCastling(king_to, from, eCastleW_OOO)) moves.add(from, king_to, eCastle, eCastleW_OOO); } if (eBlack == side) { if (board().checkCastling(king_to, from, eCastleB_OO)) moves.add(from, king_to, eCastle, eCastleB_OO); if (board().checkCastling(king_to, from, eCastleB_OOO)) moves.add(from, king_to, eCastle, eCastleB_OOO); } } } }
void ShooterControl::run() {//Run is called in Hohenheim. Methods must be placed here to run on the robot. //ManualShoot(); ballGrabber(); PIDShooter(); toggleColor(); }