Ejemplo n.º 1
0
int Player::distanceTo(const Player *other) const{
    if(this == other)
        return 0;

    if(fixed_distance.contains(other))
        return fixed_distance.value(other);

    int right = qAbs(seat - other->seat);
    int left = aliveCount() - right;
    int distance = qMin(left, right);

    distance += Sanguosha->correctDistance(this, other);

    // keep the distance >=1
    if(distance < 1)
        distance = 1;

    return distance;
}
Ejemplo n.º 2
0
void executeCGOL(int x, int y, int seed) {
  Serial.println("executeCGOL\n");
	b1 = (char*)malloc(sizeof(char)*x*y);
	b2 = (char*)malloc(sizeof(char)*x*y);
	fillBoard((char*)b1, x, y, seed);
	long itercount =0;

	while (itercount<MAX_GEN && aliveCount(b1, x,y)>3) {
		char *artemp = b1;
		b1=generate(b1,b2, x, y);
        b2 = artemp;
         // display board
		displayBoard(b1);
		delay(1000);
		if(!hasChanged(b1, b2, x, y)) {
			delay(60000);
			break;
		}
  	}		
}
Ejemplo n.º 3
0
int Player::distanceTo(const Player *other) const{
    if(this == other)
        return 0;

    if(hasSkill("changqu") && other->getRoleEnum() == Player::Lord)
        return 1;

    int right = qAbs(seat - other->seat);
    int left = aliveCount() - right;
    int distance = qMin(left, right);

    distance += correct.equip_src;
    distance += correct.skill_src;

    distance += other->correct.equip_dest;
    distance += other->correct.skill_dest;

    if(distance < 1)
        distance = 1;
    return distance;
}
Ejemplo n.º 4
0
int Player::distanceTo(const Player *other) const{
    if(this == other)
        return 0;

    if(fixed_distance.contains(other))
        return fixed_distance.value(other);

    int right = qAbs(seat - other->seat);
    int left = aliveCount() - right;
    int distance = qMin(left, right);

    // the shorten ways of distance
    if(getOffensiveHorse())
        distance --;

    if(hasSkill("mashu"))
        distance --;

    if(hasSkill("yicong") && getHp() > 2)
        distance --;

    // the lengthen ways of distance
    if(other->getDefensiveHorse())
        distance ++;

    if(other->hasSkill("feiying"))
        distance ++;

    if(other->hasSkill("yicong") && other->getHp() <= 2)
        distance ++;

    // keep the distance >=1
    if(distance < 1)
        distance = 1;

    return distance;
}
Ejemplo n.º 5
0
    if (hasSkill("zhuiji") && other->getHp() < getHp())
        return 1;

    if (fixed_distance.contains(other)) {
        QList<int> distance_list = fixed_distance.values(other);
        int min = 10000;
        foreach (int d, distance_list) {
            if (min > d)
                min = d;
        }

        return min;
    }

    int right = qAbs(seat - other->seat);
    int left = aliveCount() - right;
    int distance = qMin(left, right);

    distance += Sanguosha->correctDistance(this, other);
    distance += distance_fix;

    // keep the distance >=1
    if (distance < 1)
        distance = 1;

    return distance;
}

void Player::setGeneral(const General *new_general)
{
    if (this->general != new_general) {