📄 pass.cpp
字号:
// calculating statusShoot weight float statusShootDir = getShootDirValue( checkInterPlayer.getInterPoint(), worldModel); float statusShootDist = hypot(checkInterPlayer.getInterPoint().x - 52.5, fmin(checkInterPlayer.getInterPoint().y - 4, checkInterPlayer.getInterPoint().y + 4)); float statusShootValue = statusShootDir - fmax(statusShootDist - 10, 0) * 1.15; if (logLevel >= 2) LOG << "statusShootDir: " << statusShootDir << endl << "statusShootDist: " << statusShootDist << endl << "statusShootValue: " << statusShootValue << endl << "statusShootWeight:"; for (unsigned i = 0; i < num; i++) { statusShootWeight[i] = reRate(statusShootValue, factors[i]->statusShoot.minValue, factors[i]->statusShoot.maxValue, factors[i]->statusShoot.minWeight, factors[i]->statusShoot.maxWeight, RRM_DIRECT); if (logLevel >= 2) LOG << " " << statusShootWeight[i]; } if (logLevel >= 2) LOG << endl; // calculating dribblePath weight dribblePath.setBeginPoint(checkInterPlayer.getInterPoint()); dribblePath.setDefaultParams(); float dribblePathValue = dribblePath.getBestTargetWeight(); if (logLevel >= 2) LOG << "dribblePathValue: " << dribblePathValue << endl << "dribblePathWeight:"; for (unsigned i = 0; i < num; i++) { dribblePathWeight[i] = 0; if (logLevel >= 2) LOG << " " << dribblePathWeight[i]; } if (logLevel >= 2) LOG << endl; // calculating posDev weight float posDevValue = checkInterPlayer.getPlayer().getPosDeviation() * checkInterPlayer.getPlayer().getPosDeviation(); if (logLevel >= 2) LOG << "posDevValue: " << posDevValue << endl << "posDevWeight:"; for (unsigned i = 0; i < num; i++) { posDevWeight[i] = reRate(posDevValue, factors[i]->posDev.minValue, factors[i]->posDev.maxValue, factors[i]->posDev.minWeight, factors[i]->posDev.maxWeight, RRM_REVERSE); if (logLevel >= 2) LOG << " " << posDevWeight[i]; } if (logLevel >= 2) LOG << endl; // calculating ballDist weight float ballDistValue = interCalc.getFirstBall(). getDistance(checkInterPlayer.getInterPoint()); if (logLevel >= 2) LOG << "ballDistValue: " << ballDistValue << endl << "ballDistWeight:"; for (unsigned i = 0; i < num; i++) { ballDistWeight[i] = reRate(ballDistValue, factors[i]->ballDist.minValue, factors[i]->ballDist.maxValue, factors[i]->ballDist.minWeight, factors[i]->ballDist.maxWeight, RRM_REVERSE); if (logLevel >= 2) LOG << " " << ballDistWeight[i]; } if (logLevel >= 2) LOG << endl; // calculating dashDist weight float dashDistValue = checkInterPlayer.getDashDist(); if (logLevel >= 2) LOG << "dashDistValue: " << dashDistValue << endl << "dashDistWeight:"; for (unsigned i = 0; i < num; i++) { dashDistWeight[i] = reRate(dashDistValue, factors[i]->dashDist.minValue, factors[i]->dashDist.maxValue, factors[i]->dashDist.minWeight, factors[i]->dashDist.maxWeight, RRM_REVERSE); if (logLevel >= 2) LOG << " " << dashDistWeight[i]; } if (logLevel >= 2) LOG << endl; // calculating securityDeltaCycle weight unsigned securityDeltaCycleValue = checkInterPlayer.getInterTime() - interCalc.getFastestInterPlayer().getInterTime(); if (logLevel >= 2) LOG << "TarPlyGTBTime: " << checkInterPlayer.getInterTime() << endl << "FastestGTBTime: " << interCalc.getFastestInterPlayer().getInterTime() << endl << "securityDeltaCycleValue: " << securityDeltaCycleValue << endl << "securityDeltaCycleWeight:"; for (unsigned i = 0; i < num; i++) { securityDeltaCycleWeight[i] = reRate(securityDeltaCycleValue, factors[i]->securityDeltaCycle.minValue, factors[i]->securityDeltaCycle.maxValue, factors[i]->securityDeltaCycle.minWeight, factors[i]->securityDeltaCycle.maxWeight, RRM_REVERSE); if (logLevel >= 2) LOG << " " << securityDeltaCycleWeight[i]; } if (logLevel >= 2) LOG << endl; // calculating seeInfo weight float passAngle = interCalc.getFirstBall().getVel().getDirection(); float avgSeenBefore = worldModel->getSeeDeltaCycle(passAngle, 0.3); float seeInfoValue = 0.333 * (avgSeenBefore * avgSeenBefore) + avgSeenBefore; if (logLevel >= 2) LOG << "AvgSeenBefore: " << avgSeenBefore << endl << "SeeInfoValue: " << seeInfoValue << endl << "SeeInfoWeight:"; for (unsigned i = 0; i < num; i++) { seeInfoWeight[i] = reRate(seeInfoValue, factors[i]->seeInfo.minValue, factors[i]->seeInfo.maxValue, factors[i]->seeInfo.minWeight, factors[i]->seeInfo.maxWeight, RRM_REVERSE); if (logLevel >= 2) LOG << " " << seeInfoWeight[i]; } if (logLevel >= 2) LOG << endl; // calculating defenseLine weight float defenseLineValue = checkInterPlayer.getInterPoint().x - worldModel->getTmmDefenseLine(); if (logLevel >= 2) LOG << "defenseLineValue: " << defenseLineValue << endl << "defenseLineWeight:"; for (unsigned i = 0; i < num; i++) { defenseLineWeight[i] = reRate(defenseLineValue, factors[i]->defenseLine.minValue, factors[i]->defenseLine.maxValue, factors[i]->defenseLine.minWeight, factors[i]->defenseLine.maxWeight, RRM_DIRECT); if (logLevel >= 2) LOG << " " << defenseLineWeight[i]; } if (logLevel >= 2) LOG << endl; // calculating extraCatch weight float extraCatchValue = 0; if (logLevel >= 2) LOG << "extraCatchValue: " << extraCatchValue << endl << "extraCatchWeight:"; for (unsigned i = 0; i < num; i++) { extraCatchWeight[i] = reRate(extraCatchValue, factors[i]->extraCatch.minValue, factors[i]->extraCatch.maxValue, factors[i]->extraCatch.minWeight, factors[i]->extraCatch.maxWeight, RRM_DIRECT); if (logLevel >= 2) LOG << " " << extraCatchWeight[i]; } if (logLevel >= 2) LOG << endl; // calculating plan weight if (logLevel >= 2) LOG << "planInfo: " << interCalc.getKickPlayer()->getUniNum() << " --> " << checkInterPlayer.getPlayer().getUniNum() << endl << "planWeight:"; for (unsigned i = 0; i < num; i++) { planWeight[i] = getPlanWeight(interCalc.getKickPlayer()->getUniNum(), checkInterPlayer.getPlayer().getUniNum(), interCalc.getFirstBall().getPos()); if (logLevel >= 2) LOG << " " << planWeight[i]; } if (logLevel >= 2) LOG << endl; // calculating Current weight if (logLevel >= 1) LOG << "P" << checkInterPlayer.getPlayer().getUniNum() << "\tPoint: " << checkInterPlayer.getInterPoint() << "\t\tweights:"; for (unsigned i = 0; i < num; i++) { *valuesList[i] = offenseWeight[i] + statusShootWeight[i] + statusOppNumWeight[i] + statusOppDistWeight[i] + statusOppDirWeight[i] + breakOffsideWeight[i] + passedOppNumWeight[i] + statusShootWeight[i] + dribblePathWeight[i] + ballDistWeight[i] + dashDistWeight[i] + posDevWeight[i] + seeInfoWeight[i] + securityDeltaCycleWeight[i] + defenseLineWeight[i] + extraCatchWeight[i] + planWeight[i]; if (logLevel >= 1) LOG << "\t" << *valuesList[i]; } if (logLevel >= 1) LOG << endl;}void Pass::fillPassValuesByFactors(const KickCalculate &kickCalc, const PassFactors **factors, float *valuesList[], unsigned num){ float *values[MAX_FACTORS_NUM]; for (unsigned i = 0; i < kickCalc.getSimulatesNum(); i++) { if (logLevel >= 3) LOG << "New kick: ballVel: " << Point(kickCalc.getSimulate(i).getFirstBall().getVel().getMagnitude(), kickCalc.getSimulate(i).getFirstBall().getVel().getDirection()) << endl; if (!kickCalc.getSimulate(i).isValid()) { if (logLevel >= 3) LOG << "\tBREAK: is not valid." << endl; continue; } if (!kickCalc.getSimulate(i).existFastestPlayer()) { if (logLevel >= 3) LOG << "\tBREAK: no fastest." << endl; continue; } if (!kickCalc.getSimulate(i).existFastestTmmPlayer()) { if (logLevel >= 3) LOG << "\tBREAK: opp fastest: " << kickCalc.getSimulate(i).getFastestPlayer().getTeamId() << " " << kickCalc.getSimulate(i).getFastestPlayer().getUniNum() << endl; continue; } const KickInterceptPlayer &checkInterPlayer = kickCalc.getSimulate(i).getFastestTmmInterPlayer(); if (logLevel >= 2) LOG << "CheckPlayer: " << checkInterPlayer.getPlayer().getTeamId() << " " << checkInterPlayer.getPlayer().getUniNum() << endl; if (&checkInterPlayer.getPlayer() == kickCalc.getSimulate(i).getKickPlayer()) { if (logLevel >= 3) LOG << "\tBREAK: is kickPlayer." << endl; continue; } if (checkInterPlayer.getPlayer().isGoalie()) { if (logLevel >= 3) LOG << "\tBREAK: is goalie." << endl; continue; } if (!checkInterPlayer.isExtraCatched()) { if (logLevel >= 3) LOG << "\tBREAK: not extra catched." << endl; continue; }/* if (checkInterPlayer.getPlayer().getPos().getX() > worldModel->getOppOffsideLine() + PASS_OFFSIDE_DELTA_DIST) { if (logLevel >= 3) LOG << "\tBREAK: offside." << endl; continue; }*/ for (unsigned j = 0; j < num; j++) values[j] = &valuesList[j][i]; fillOnePassValuesByFactors(kickCalc.getSimulate(i), factors, values, num); }}void Pass::fillOtherCrossValuesByFactors(const CrossCalculate &crossCalc, const PassFactors &factors, float values[]){ float *valuesList[1]; const PassFactors *factorsList[1] = {&factors}; if (logLevel >= 1) LOG << "Cross Special Values:" << endl; for (unsigned i = 0; i < crossCalc.getSimulatesNum(); i++) { if (logLevel >= 3) LOG << "New cross kick: ballVel: " << Point(crossCalc.getSimulate(i).getFirstBall().getVel().getMagnitude(), crossCalc.getSimulate(i).getFirstBall().getVel().getDirection()) << endl; if (!crossCalc.getSimulate(i).isValid()) { if (logLevel >= 3) LOG << "\tBREAK: is not valid." << endl; continue; } if (!crossCalc.getSimulate(i).existFastestTmmPlayer()) { if (logLevel >= 3) LOG << "\tBREAK: no fastest." << endl; continue; } const KickInterceptPlayer &checkInterPlayer = crossCalc.getSimulate(i).getFastestTmmInterPlayer(); if (logLevel >= 2) LOG << "CheckPlayer: " << checkInterPlayer.getPlayer().getTeamId() << " " << checkInterPlayer.getPlayer().getUniNum() << endl; if (checkInterPlayer.getPlayer().isBody()) continue; if (checkInterPlayer.getPlayer().isGoalie()) continue; if (checkInterPlayer.getPlayer().getPos().getX() > worldModel->getOppOffsideLine() + PASS_OFFSIDE_DELTA_DIST) continue; valuesList[0] = &values[i + KICK_CALCULATES_NUM]; fillOnePassValuesByFactors(crossCalc.getSimulate(i), factorsList, valuesList); }}void Pass::calculateGlobalVars(){ logLevel = config["Pass"]["GlobalVars"]["LogLevel"].asInt(); crossRate = config["Pass"]["GlobalVars"]["CrossRate"].asFloat();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -