Esempio n. 1
0
bool StoneHandler:: checkFalseEye(Matrix *m, int x, int y, int col)
{
    int bsize = m->getSize();

    // Stone to the North?
    if (y - 1 >= 0 && m->at(x, y - 1) == col)
	if (countLibertiesOnMatrix(assembleGroup(getStoneAt(x + 1, y),NULL), m) == 1) //SL added eb 8
	    return true;

    // Stone to the west?
    if (x - 1 >= 0 && m->at(x - 1, y) == col)                                    //SL added eb 8
	if (countLibertiesOnMatrix(assembleGroup(getStoneAt(x, y + 1),NULL), m) == 1)
	    return true;
    
    // Stone to the south?
    if (y + 1 < bsize && m->at(x, y + 1) == col)
	if (countLibertiesOnMatrix(assembleGroup(getStoneAt(x + 1, y + 2),NULL), m) == 1)    //SL added eb 8
	    return true;
    
    // Stone to the east?
    if (x + 1 < bsize && m->at(x + 1, y) == col)
	if (countLibertiesOnMatrix(assembleGroup(getStoneAt(x + 2, y + 1),NULL), m) == 1)     //SL added eb 8
	    return true;
    
    return false;
}
Esempio n. 2
0
bool StoneHandler::markSekiGroup(int x, int y, int &caps, StoneColor &col, bool &seki)
{
	if (hasStone(x, y) != 1)
		return false;
	
	Stone *s = getStoneAt(x, y);
	CHECK_PTR(s);
	col = s->getColor();
	
	if (!s->isSeki())
		seki = true;
	
	Group *g = assembleGroup(s, NULL);        //SL added eb 8
	CHECK_PTR(g);
	
	// Mark stones of this group as seki
	QListIterator<Stone *> it(*g);
	while (it.hasNext())
	{
		Stone *s = it.next();
		CHECK_PTR(s);
		if (seki && s->isDead())
			caps ++;
		s->setSeki(seki);
		if (seki)
		{
			s->togglePixmap(boardHandler->board->getImageHandler()->getGhostPixmaps(),
					false);
		}	
		else
		{
			s->togglePixmap(boardHandler->board->getImageHandler()->getStonePixmaps(),
					true);
		}
	}
	
	delete g;
	return true;
}
Esempio n. 3
0
bool StoneHandler::markSekiGroup(int x, int y, int &caps, StoneColor &col, bool &seki)
{
	if (hasStone(x, y) != 1)
		return false;
	
	Stone *s = getStoneAt(x, y);
	CHECK_PTR(s);
	col = s->getColor();
	
	if (!s->isSeki())
		seki = true;
	
	Group *g = assembleGroup(s, NULL);        //SL added eb 8
	CHECK_PTR(g);
	
	// Mark stones of this group as seki
	QListIterator<Stone> it(*g);
	for (; it.current(); ++it)
	{
		s = it.current();
		CHECK_PTR(s);
		if (seki && s->isDead())
			caps ++;
		s->setSeki(seki);
		if (seki)
		{
			s->setSequence(boardHandler->board->getImageHandler()->getGhostPixmaps());
			s->shadow->hide();
		}	
		else
		{
			s->setSequence(boardHandler->board->getImageHandler()->getStonePixmaps());
			s->shadow->show();
		}
	}
	
	delete g;
	return true;
}
Esempio n. 4
0
bool StoneHandler::removeDeadGroup(int x, int y, int &caps, StoneColor &col, bool &dead)
{
	if (hasStone(x, y) != 1)
		return false;
	
	Stone *s = getStoneAt(x, y);
	CHECK_PTR(s);
	col = s->getColor();
	
	if (!s->isDead())
		dead = true;
	
	Group *g = assembleGroup(s, NULL);        //SL added eb 8
	CHECK_PTR(g);
	
	caps = g->count();
	
	// Mark stones of this group as dead or alive again
	QListIterator<Stone *> it(*g);
	while (it.hasNext())
	{
		Stone *s = it.next();
		CHECK_PTR(s);
		s->setDead(dead);
		if (dead)
		{
			s->togglePixmap(boardHandler->board->getImageHandler()->getGhostPixmaps(),
					false);
		}
		else
		{
			s->togglePixmap(boardHandler->board->getImageHandler()->getStonePixmaps(),
					true);
		}
	}
	
	delete g;
	return true;
}
Esempio n. 5
0
bool StoneHandler::removeDeadGroup(int x, int y, int &caps, StoneColor &col, bool &dead)
{
	if (hasStone(x, y) != 1)
		return false;
	
	Stone *s = getStoneAt(x, y);
	CHECK_PTR(s);
	col = s->getColor();
	
	if (!s->isDead())
		dead = true;
	
	Group *g = assembleGroup(s, NULL);        //SL added eb 8
	CHECK_PTR(g);
	
	caps = g->count();
	
	// Mark stones of this group as dead or alive again
	QListIterator<Stone> it(*g);
	for (; it.current(); ++it)
	{
		s = it.current();
		CHECK_PTR(s);
		s->setDead(dead);
		if (dead)
		{
			s->setSequence(boardHandler->board->getImageHandler()->getGhostPixmaps());
			s->shadow->hide();
		}
		else
		{
			s->setSequence(boardHandler->board->getImageHandler()->getStonePixmaps());
			s->shadow->show();
		}
	}
	
	delete g;
	return true;
}