📄 syncedcoach.cpp
字号:
/* * Copyright 2002-2005, Mersad Team, Allameh Helli High School (NODET). * * This program is free software, you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * This file is created by: Mohammad Salehe * * Released on Monday 1 August 2005, 10 Mordad 1384 by Mersad RoboCup Team. * For more information please read README file.*/#include <iostream>#include <Logger.h>#include <SyncedCoach.h>using namespace std;SyncedCoach::SyncedCoach(int argc, char **argv): BasicCoach(argc, argv){ freeFormCycleCommandSentFlag = false; changePlayerCycleCommandSentFlag = false;}SyncedCoach::~SyncedCoach(){}void SyncedCoach::seeGlobal(const SExpression &exp){ BasicCoach::seeGlobal(exp); delete freeFormCycleCommand; freeFormCycleCommand = NULL; setFreeFormCycleCommandSent(false); delete changePlayerCycleCommand; changePlayerCycleCommand = NULL; setChangePlayerCycleCommandSent(false); setSeeGlobalReceived(true);}void SyncedCoach::hear(const SExpression &exp){ BasicCoach::hear(exp);}void SyncedCoach::fullState(const SExpression &exp){ BasicCoach::fullState(exp);}void SyncedCoach::serverParam(const SExpression &exp){ BasicCoach::serverParam(exp);}void SyncedCoach::playerParam(const SExpression &exp){ BasicCoach::playerParam(exp);}void SyncedCoach::playerType(const SExpression &exp){ BasicCoach::playerType(exp);}void SyncedCoach::init(const SExpression &exp){ BasicCoach::init(exp);}void SyncedCoach::think(const SExpression &exp){ BasicCoach::think(exp);}void SyncedCoach::changePlayerType(const SExpression &exp){ BasicCoach::changePlayerType(exp);}bool SyncedCoach::decide(){ LOG << "SyncedCoach::decide" << endl; if (!isSeeGlobalReceived()) return true; string queue = ""; // bodyCycleCommand Deciding if (!freeFormCycleCommand || !changePlayerCycleCommand) { processTasks(); } // bodyCycleCommand Sending if (freeFormCycleCommand && !isFreeFormCycleCommandSent()) {// LOG << "Sending 1" << freeFormCycleCommand->toString() << endl; queue += freeFormCycleCommand->toString();// LOG << "Sending 1E" << queue << endl; setFreeFormCycleCommandSent(true); } if (changePlayerCycleCommand && !isChangePlayerCycleCommandSent()) {// LOG << "Sending 2 ";// LOG << changePlayerCycleCommand->toString() << endl; queue += changePlayerCycleCommand->toString();// LOG << "Sending 2E " << queue << endl; setChangePlayerCycleCommandSent(true); }// LOG << "queue = /" << queue << "/" << endl; if (queue != "") {// LOG << "Sending 3" << endl; connection->send(queue); LOG << "SendStr: " << queue << endl; } return true;}bool SyncedCoach::synchronize(){ if (worldModel->getTimer().now() > SERVER_TIME_OUT) { LOG << "Server does not respond in the expected time." << endl; cout << "Server does not respond in the expected time." << endl; return false; } return true;}void SyncedCoach::logEndInf(){ LOG << "End of cycle." << endl; OFFLOG << "EndInf: " << (int)(freeFormCycleCommand != NULL) << (int)(isFreeFormCycleCommandSent()) << (int)(freeFormCycleCommand != NULL) << (int)(isFreeFormCycleCommandSent()) << endl;}bool SyncedCoach::isSeeGlobalReceived() const{ return seeGlobalReceivedFlag;}bool SyncedCoach::isFreeFormCycleCommandSent() const{ return freeFormCycleCommandSentFlag;}bool SyncedCoach::isChangePlayerCycleCommandSent() const{ return changePlayerCycleCommandSentFlag;}void SyncedCoach::setSeeGlobalReceived(bool seeGlobalReceivedFlagArg){ seeGlobalReceivedFlag = seeGlobalReceivedFlagArg;}void SyncedCoach::setFreeFormCycleCommandSent(bool freeFormCycleCommandSentFlagArg){ freeFormCycleCommandSentFlag = freeFormCycleCommandSentFlagArg;}void SyncedCoach::setChangePlayerCycleCommandSent(bool changePlayerCycleCommandSentFlagArg){ changePlayerCycleCommandSentFlag = changePlayerCycleCommandSentFlagArg;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -