示例#1
0
TimeManager& TimeManager::operator+ (TimeManager input) {

	//calculate time
	int hourt = this->hour + input.hour;
	int mint = this->min + input.min;
	double sect = this->sec + input.sec; //TimeManager 부분에서는 double로 선언되어있어서 double로 형변환을 해줌

	//calculate date. Only uses Solar dates
	int solarDayt = this->solarDate.solarDay + input.getSolarDay();
	int solarMontht = this->solarDate.solarMonth + input.getSolarMonth();
	int solarYeart = this->solarDate.solarYear + input.getSolarYear();

	if (sect >= 60) {
	sect -= 60;
	mint++;
	}
	if (mint >= 60) {
	mint -= 60;
	hourt++;
	}
	if (hourt >= 24) {
	hourt -= 24;
	solarDayt++;
	}

	//calculate # of days for given month
	int dayLimit = isDays(this->solarDate.solarMonth);
	if (isLeap(solarYeart)) dayLimit += 1;

	if (solarDayt > dayLimit) {
	solarDayt -= dayLimit;
	solarMontht++;
	}
	if (solarMontht > 12) {
	solarMontht -= 12;
	solarYeart++;
	}

	return TimeManager(solarYeart, solarMontht, solarDayt, hourt, mint, sect);
}
示例#2
0
void InitSearch(typePos *Position, char *str)
    {
    char *p;
    sint64 wtime = Infinity, btime = Infinity, winc = 0, binc = 0, Time, OppTime, mtg = 0;
    int sm = 0;
    Depth = 255;
    AbsoluteTime = DesiredTime = Infinity;
    Stop = false;
    DoInfinite = false;
    DoPonder = false;
    NewPonderhit = false;
    DoSearchMoves = false;
    LastMessage = 0;
    p = strtok(str, " ");
    for (StrTok(p); p != NULL; StrTok(p))
        {
        if (!strcmp(p, "depth"))
            {
            StrTok(p);
            Depth = MAX(1, atoi(p));
            }
        else if (!strcmp(p, "movetime"))
            {
            StrTok(p);
            AbsoluteTime = MAX(1, atoll(p)) * 1000;
            }
        else if (!strcmp(p, "wtime"))
            {
            StrTok(p);
            wtime = atoll(p) * 1000;
            }
        else if (!strcmp(p, "winc"))
            {
            StrTok(p);
            winc = atoll(p) * 1000;
            }
        else if (!strcmp(p, "btime"))
            {
            StrTok(p);
            btime = atoll(p) * 1000;
            }
        else if (!strcmp(p, "binc"))
            {
            StrTok(p);
            binc = atoll(p) * 1000;
            }
        else if (!strcmp(p, "movestogo"))
            {
            StrTok(p);
            mtg = atoi(p);
            }
        else if (!strcmp(p, "infinite"))
            DoInfinite = true;
        else if (!strcmp(p, "ponder"))
            DoPonder = true;
        else if (!strcmp(p, "searchmoves"))
            DoSearchMoves = true;
        else if (DoSearchMoves)
            SearchMoves[sm++] = NumericMove(Position, p);
        else
            ErrorEnd("go string: %s", p);
        }
    BattleTime = Infinity;
    NormalTime = Infinity;
    EasyTime = Infinity;

    Time = Position->wtm ? wtime : btime;
    OppTime = Position->wtm ? btime : wtime;
    if (Time < 0)
        Time = 0;
    if (Time == Infinity)
        goto End;
    Increment = Position->wtm ? winc : binc;
        TimeManager(Time, OppTime, Increment, mtg);
    End:
    if (Time == Infinity)
        Analysing = true;
    else
        Analysing = false;
    if (DoSearchMoves)
        SearchMoves[sm] = MoveNone;
    }