示例#1
0
文件: movebox.cpp 项目: esaye/quackle
MoveBox::MoveBox(QWidget *parent)
	: View(parent)
{
	QVBoxLayout *vlayout = new QVBoxLayout(this);
	Geometry::setupInnerLayout(vlayout);
	vlayout->setSpacing(0);

	m_treeWidget = new QTreeWidget(this);

	m_treeWidget->setColumnCount(3);
	m_treeWidget->setSelectionMode(QTreeWidget::ExtendedSelection);
	QStringList headers;
	headers << tr("Move") << tr("Score") << tr("Leave") << tr("Win %") << tr("Valuation");
	m_treeWidget->setHeaderLabels(headers);
	
	QHBoxLayout *buttonLayout = new QHBoxLayout;
	Geometry::setupInnerLayout(buttonLayout);
	m_removeButton = new QPushButton(tr("Remove"));
	connect(m_removeButton, SIGNAL(clicked()), this, SLOT(removeMove()));
	buttonLayout->addWidget(m_removeButton);

	m_commitButton = new QPushButton(tr("Commit"));
	connect(m_commitButton, SIGNAL(clicked()), this, SIGNAL(commit()));
	buttonLayout->addWidget(m_commitButton);

	setSelectionWatchingEnabled(true);

	vlayout->addWidget(m_treeWidget);
	vlayout->addLayout(buttonLayout);
}
void edaSimpleMoveTabuList::add(const edaMove *_move, const edaSolution *_sol)
{
  edaMove *myMove = _move->clone();

  // Remove old move if it is already existed
  if (currentSize != 0)
  {
    removeMove(myMove);
  }

  tabuList.push_back(myMove);
  if (currentSize == maxSize)
  {
    // delete the move in the front and pop off the list
    edaMove *frontmove = tabuList.front();
    delete frontmove;
    tabuList.pop_front();
  }
  else
  {
    currentSize++;
  }

  // No need to delete myMove, destructor will do
  //delete myMove
}
示例#3
0
int MoveBox::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = View::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: positionChanged((*reinterpret_cast< const Quackle::GamePosition(*)>(_a[1]))); break;
        case 1: movesChanged((*reinterpret_cast< const Quackle::MoveList(*)>(_a[1]))); break;
        case 2: moveActivated((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1]))); break;
        case 3: selectionChanged(); break;
        case 4: removeMove(); break;
        case 5: checkGeometry(); break;
        }
        _id -= 6;
    }
    return _id;
}
示例#4
0
int updateAllMoves(struct board * b)
{
	struct piece * k0 = NULL;
	struct piece * k1 = NULL;
	for(int a = 0 ; a< b->s_pieces; a++)
	{
		// saves kings for later, all other pieces must
		// be updated BEFORE the king
		if(b->pieces[a]->p == KING)
		{
			if(b->pieces[a]->player == 0)
				k0 = b->pieces[a];
			else
				k1 = b->pieces[a];
			continue;
		}
		updateMoves(b,b->pieces[a]);
	}
	for(int a = 0 ; a< b->s_pieces; a++)
	{
		if(b->pieces[a]->p == ROOK)
		{
			addCastleing(b,b->pieces[a]);
		}
	}
	if(k0 != NULL)
	{
		for(int a = 0 ; a< b->s_pieces; a++)
		{
			if(b->pieces[a]->player == 1)
				continue;
			for(int c = 0 ; c < b->pieces[a]->s_moves;c++)
			{
				if(b->pieces[a]->moves[c]-> type == 2 ||b->pieces[a]->moves[c]-> type == 4)
				{
					continue;
				}
				if(simCheck(b,b->pieces[a],b->pieces[a]->moves[c],k0) == 1)
				{
					removeMove(b->pieces[a],c);
				}
			}
		}
	}
	if(k1 != NULL)
	{
		for(int a = 0 ; a< b->s_pieces; a++)
		{
			if(b->pieces[a]->player == 0)
				continue;
			for(int c = 0 ; c < b->pieces[a]->s_moves;c++)
			{
				if(simCheck(b,b->pieces[a],b->pieces[a]->moves[c],k1) == 1)
				{
					removeMove(b->pieces[a],c);
				}
			}
		}
	}

	if(k0 != NULL)
	{
		updateMoves(b,k0);
	}
	if(k1 != NULL)
	{
		updateMoves(b,k1);
	}
	specialKingMoveCheck(b,k0, k1);

}