00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00048 #ifndef _WORLD_MODEL_
00049 #define _WORLD_MODEL_
00050
00051 #include "Objects.h"
00052 #include "PlayerSettings.h"
00053 #include "Logger.h"
00054 #include "Formations.h"
00055 #include <list>
00056
00057 #ifdef WIN32
00058 #include <windows.h>
00059 #else
00060 #include <pthread.h>
00061 #include <sys/time.h>
00062 #endif
00063
00064
00065 extern Logger Log;
00066 extern Logger LogDraw;
00067
00068 #ifdef WIN32
00069
00077 inline double rint(double x)
00078 {
00079 return floor(x+0.5);
00080 }
00081
00086 inline double drand48()
00087 {
00088 return ((double)(rand() % 100)) / 100;
00089 }
00090 #endif
00091
00092
00093
00094
00095
00111 class WorldModel
00112 {
00113 private:
00114
00115
00116
00117
00118
00120
00121 ServerSettings *SS;
00122 PlayerSettings *PS;
00123 HeteroPlayerSettings pt[MAX_HETERO_PLAYERS];
00124 Formations *formations;
00126
00127
00128
00129 Time timeLastSeeMessage;
00130 Time timeLastRecvSeeMessage;
00131 Time timeLastSenseMessage;
00132 Time timeLastRecvSenseMessage;
00133 Time timeLastHearMessage;
00134 bool bNewInfo;
00135 Time timeLastCatch;
00136 Time timeLastRefMessage;
00138
00139 char strTeamName[MAX_TEAM_NAME_LENGTH];
00140 int iPlayerNumber;
00141 SideT sideSide;
00143
00144 PlayModeT playMode;
00145 int iGoalDiff;
00148
00149
00150
00151 BallObject Ball;
00152 AgentObject agentObject;
00153 PlayerObject Teammates[MAX_TEAMMATES];
00154 PlayerObject Opponents[MAX_OPPONENTS];
00155 PlayerObject UnknownPlayers[MAX_TEAMMATES+MAX_OPPONENTS];
00158 int iNrUnknownPlayers;
00160
00161 FixedObject Flags[MAX_FLAGS];
00162 FixedObject Lines[MAX_LINES];
00164
00165
00166 static const int iNrParticlesAgent = 100;
00168 static const int iNrParticlesBall = 100;
00170 VecPosition particlesPosAgent[iNrParticlesAgent];
00172 VecPosition particlesPosBall[iNrParticlesBall];
00174 VecPosition particlesVelBall[iNrParticlesBall];
00176 double dTotalVarVel;
00177 double dTotalVarPos;
00179
00180
00181 SoccerCommand queuedCommands[CMD_MAX_COMMANDS];
00183 bool performedCommands[CMD_MAX_COMMANDS];
00186 int iCommandCounters[CMD_MAX_COMMANDS];
00190
00191
00192
00193 Time timeCheckBall;
00194 BallStatusT bsCheckBall;
00196
00197 #ifdef WIN32
00198 CRITICAL_SECTION mutex_newInfo;
00199 HANDLE event_newInfo;
00200 #else
00201 pthread_mutex_t mutex_newInfo;
00202 pthread_cond_t cond_newInfo;
00203 #endif
00204 bool m_bRecvThink;
00206
00207 char m_strPlayerMsg[MAX_MSG];
00208 int m_iCycleInMsg;
00209 Time m_timePlayerMsg;
00210 int m_iMessageSender;
00211 char m_strCommunicate[MAX_SAY_MSG];
00213
00214 ObjectT m_objFocus;
00216
00217 double m_dCommOffsideX;
00218 Time m_timeCommOffsideX;
00220
00221 Feature m_features[MAX_FEATURES];
00223
00224 bool m_bPerformedKick;
00226
00227 set<ObjectT> m_setSubstitutedOpp;
00229
00230 SoccerCommand m_changeViewCommand;
00232
00233 SideT m_sidePenalty;
00234
00235 public:
00236
00237 bool m_bWasCollision;
00238 Time m_timeLastCollision;
00240
00241 int iNrHoles;
00242 int iNrOpponentsSeen;
00243 int iNrTeammatesSeen;
00245
00246 char strLastSeeMessage [MAX_MSG];
00247 char strLastSenseMessage[MAX_MSG];
00248 char strLastHearMessage [MAX_MSG];
00251
00252
00253
00254
00256
00257 private:
00258
00259 Object* getObjectPtrFromType ( ObjectT o );
00260
00261 public:
00262
00263
00264 void setTimeLastCatch ( Time time );
00265 int getTimeSinceLastCatch ( );
00266 bool setTimeLastRefereeMessage ( Time time );
00267 Time getTimeLastRefereeMessage ( );
00268 Time getCurrentTime ( );
00269 int getCurrentCycle ( );
00270 bool isTimeStopped ( );
00271 bool isLastMessageSee ( )const;
00272 Time getTimeLastSeeGlobalMessage( )const;
00273 bool setTimeLastSeeGlobalMessage( Time time );
00274 Time getTimeLastSeeMessage ( )const;
00275 Time getTimeLastRecvSeeMessage ( )const;
00276 bool setTimeLastSeeMessage ( Time time );
00277 Time getTimeLastSenseMessage ( )const;
00278 Time getTimeLastRecvSenseMessage( )const;
00279 bool setTimeLastSenseMessage ( Time time );
00280 Time getTimeLastHearMessage ( )const;
00281 bool setTimeLastHearMessage ( Time time );
00282 int getPlayerNumber ( )const;
00283 bool setPlayerNumber ( int i );
00284 SideT getSide ( )const;
00285 bool setSide ( SideT s );
00286 const char* getTeamName ( )const;
00287 bool setTeamName ( char *str );
00288 PlayModeT getPlayMode ( )const;
00289 bool setPlayMode ( PlayModeT pm );
00290 int getGoalDiff ( )const;
00291 int addOneToGoalDiff ( );
00292 int subtractOneFromGoalDiff ( );
00293 int getNrOfCommands ( CommandT c )const;
00294 bool setNrOfCommands ( CommandT c,
00295 int i );
00296 Time getTimeCheckBall ( )const;
00297 bool setTimeCheckBall ( Time time );
00298 BallStatusT getCheckBallStatus ( )const;
00299 bool setCheckBallStatus ( BallStatusT bs );
00300 bool getRecvThink ( );
00301 char* getCommunicationString ( );
00302 bool setCommunicationString ( char* srt );
00303 ObjectT getObjectFocus ( );
00304 bool setObjectFocus ( ObjectT obj );
00305
00306
00307 ObjectT iterateObjectStart ( int &iIndex,
00308 ObjectSetT g,
00309 double dConf = -1.0,
00310 bool bForward = false );
00311 ObjectT iterateObjectNext ( int &iIndex,
00312 ObjectSetT g,
00313 double dConf = -1.0,
00314 bool bForward = false );
00315 void iterateObjectDone ( int &iIndex );
00316
00317
00318 ObjectT getAgentObjectType ( )const;
00319 int getAgentIndex ( )const;
00320 bool setAgentObjectType ( ObjectT o );
00321 AngDeg getAgentBodyAngleRelToNeck ( )const;
00322 AngDeg getAgentGlobalNeckAngle ( )const;
00323 AngDeg getAgentGlobalBodyAngle ( );
00324 Stamina getAgentStamina ( )const;
00325 TiredNessT getAgentTiredNess ( )const;
00326 double getAgentEffort ( )const;
00327 VecPosition getAgentGlobalVelocity ( )const;
00328 double getAgentSpeed ( )const;
00329 VecPosition getAgentGlobalPosition ( )const;
00330 bool setAgentViewAngle ( ViewAngleT va ) ;
00331 ViewAngleT getAgentViewAngle ( )const;
00332 bool setAgentViewQuality ( ViewQualityT vq ) ;
00333 ViewQualityT getAgentViewQuality ( )const;
00334 double getAgentViewFrequency ( ViewAngleT va = VA_ILLEGAL,
00335 ViewQualityT vq = VQ_ILLEGAL );
00336 bool getAgentArmMovable ( );
00337 VecPosition getAgentArmPosition ( );
00338 int getAgentArmExpires ( );
00339
00340
00341 VecPosition getBallPos ( );
00342 double getBallSpeed ( );
00343 AngDeg getBallDirection ( );
00344
00345
00346 Time getTimeGlobalPosition ( ObjectT o );
00347 VecPosition getGlobalPosition ( ObjectT o );
00348 Time getTimeGlobalVelocity ( ObjectT o );
00349 VecPosition getGlobalVelocity ( ObjectT o );
00350 double getRelativeDistance ( ObjectT o );
00351 VecPosition getRelativePosition ( ObjectT o );
00352 AngDeg getRelativeAngle ( ObjectT o,
00353 bool bWithBody = false);
00354 Time getTimeGlobalAngles ( ObjectT o );
00355 AngDeg getGlobalBodyAngle ( ObjectT o );
00356 AngDeg getGlobalNeckAngle ( ObjectT o );
00357 AngDeg getGlobalAngle ( ObjectT o );
00358 double getConfidence ( ObjectT o );
00359 bool isKnownPlayer ( ObjectT o );
00360 ObjectT getOppGoalieType ( );
00361 ObjectT getOwnGoalieType ( );
00362 Time getTimeLastSeen ( ObjectT o );
00363 Time getTimeChangeInformation ( ObjectT o );
00364 VecPosition getGlobalPositionLastSee ( ObjectT o );
00365 Time getTimeGlobalPositionLastSee( ObjectT o );
00366 VecPosition getGlobalVelocityLastSee ( ObjectT o );
00367 AngDeg getGlobalBodyAngleLastSee ( ObjectT o );
00368 int getTackleExpires ( ObjectT o =OBJECT_ILLEGAL);
00369 AngDeg getGlobalArmDirection ( ObjectT o );
00370 Time getTimeGlobalArmDirection ( ObjectT o );
00371 double getProbTackleSucceeds ( ObjectT o = OBJECT_ILLEGAL,
00372 int iExtraCycles = 0,
00373 VecPosition *pos = NULL );
00374 double getProbTackleClosestOpp ( int iExtraCycles = 0 );
00375 list<ObjectT> getListCloseOpponents ( VecPosition pos,
00376 double dDist = 15 );
00377
00378
00379 bool setIsKnownPlayer ( ObjectT o,
00380 bool isKnownPlayer );
00381 bool setTimeLastSeen ( ObjectT o,
00382 Time time );
00383 bool setHeteroPlayerType ( ObjectT o,
00384 int iPlayer );
00385
00386
00387 PlayerT getPlayerType ( ObjectT o =OBJECT_ILLEGAL);
00388 bool isInPlayerSet ( ObjectT o,
00389 PlayerSetT ps );
00390
00391
00392 VecPosition getPosOpponentGoal ( );
00393 VecPosition getPosOwnGoal ( );
00394 double getRelDistanceOpponentGoal ( );
00395 AngDeg getRelAngleOpponentGoal ( );
00396 ObjectT getLastOpponentDefender ( double *dX = NULL );
00397
00398
00399 HeteroPlayerSettings getInfoHeteroPlayer ( int iIndex );
00400 HeteroPlayerSettings getHeteroInfoPlayer ( ObjectT obj );
00401 int getHeteroPlayerType ( ObjectT obj );
00402 bool setSubstitutedOpp ( ObjectT obj );
00403 ObjectT getSubstitutedOpp ( );
00404 double getDashPowerRate ( ObjectT obj );
00405 double getPlayerSpeedMax ( ObjectT obj );
00406 double getPlayerDecay ( ObjectT obj );
00407 double getMaximalKickDist ( ObjectT obj );
00408 double getStaminaIncMax ( ObjectT obj );
00409 double getPlayerSize ( ObjectT obj );
00410 double getInertiaMoment ( ObjectT obj );
00411 double getEffortMax ( ObjectT obj );
00412 double getEffectiveMaxSpeed ( ObjectT obj,
00413 bool bWithNoise =false);
00414
00415
00416 bool isQueuedActionPerformed ( );
00417
00418
00419 bool isFreeKickUs ( PlayModeT pm = PM_ILLEGAL );
00420 bool isFreeKickThem ( PlayModeT pm = PM_ILLEGAL );
00421 bool isCornerKickUs ( PlayModeT pm = PM_ILLEGAL );
00422 bool isCornerKickThem ( PlayModeT pm = PM_ILLEGAL );
00423 bool isOffsideUs ( PlayModeT pm = PM_ILLEGAL );
00424 bool isOffsideThem ( PlayModeT pm = PM_ILLEGAL );
00425 bool isKickInUs ( PlayModeT pm = PM_ILLEGAL );
00426 bool isKickInThem ( PlayModeT pm = PM_ILLEGAL );
00427 bool isFreeKickFaultUs ( PlayModeT pm = PM_ILLEGAL );
00428 bool isFreeKickFaultThem ( PlayModeT pm = PM_ILLEGAL );
00429 bool isKickOffUs ( PlayModeT pm = PM_ILLEGAL );
00430 bool isKickOffThem ( PlayModeT pm = PM_ILLEGAL );
00431 bool isBackPassUs ( PlayModeT pm = PM_ILLEGAL );
00432 bool isBackPassThem ( PlayModeT pm = PM_ILLEGAL );
00433 bool isGoalKickUs ( PlayModeT pm = PM_ILLEGAL );
00434 bool isGoalKickThem ( PlayModeT pm = PM_ILLEGAL );
00435 bool isBeforeKickOff ( PlayModeT pm = PM_ILLEGAL );
00436 bool isDeadBallUs ( PlayModeT pm = PM_ILLEGAL );
00437 bool isDeadBallThem ( PlayModeT pm = PM_ILLEGAL );
00438 bool isPenaltyUs ( PlayModeT pm = PM_ILLEGAL );
00439 bool isPenaltyThem ( PlayModeT pm = PM_ILLEGAL );
00440 bool isFullStateOn ( SideT s = SIDE_ILLEGAL );
00441
00442
00443 bool setChangeViewCommand ( SoccerCommand soc );
00444 SoccerCommand getChangeViewCommand ( );
00445
00446 SideT getSidePenalty ( );
00447 bool setSidePenalty ( SideT side );
00448
00450
00451
00452 void processSeeGlobalInfo ( ObjectT o,
00453 Time time,
00454 VecPosition pos,
00455 VecPosition vel,
00456 AngDeg angBody,
00457 AngDeg angNeck );
00458 bool processNewAgentInfo ( ViewQualityT vq,
00459 ViewAngleT va,
00460 double dStamina,
00461 double dEffort,
00462 double dSpeed,
00463 AngDeg angSpeed,
00464 AngDeg angHeadAngle,
00465 int iTackleExpires,
00466 int iArmMovable,
00467 int iArmExpires,
00468 VecPosition posArm );
00469 void processNewObjectInfo ( ObjectT o,
00470 Time time,
00471 double dDist,
00472 int iDir,
00473 double dDistChange,
00474 double dDirChange,
00475 AngDeg angRelBodyAng,
00476 AngDeg angRelNeckAng,
00477 bool isGoalie,
00478 ObjectT objMin,
00479 ObjectT objMax,
00480 double dPointDir,
00481 bool isTackling );
00482 bool processPerfectHearInfo ( ObjectT o,
00483 VecPosition pos,
00484 double dConf,
00485 bool bIsGoalie=0 );
00486 bool processPerfectHearInfoBall ( VecPosition pos,
00487 VecPosition vel,
00488 double dConf );
00489 bool processUnsureHearInfo ( ObjectT o,
00490 VecPosition pos,
00491 double dConf );
00492 bool processNewHeteroPlayer ( int iIndex,
00493 double dPlayerSpeedMax,
00494 double dStaminaIncMax,
00495 double dPlayerDecay,
00496 double dInertiaMoment,
00497 double dDashPowerRate,
00498 double dPlayerSize,
00499 double dKickableMargin,
00500 double dKickRand,
00501 double dExtraStamina,
00502 double dEffortMax,
00503 double dEffortMin );
00504 void processCatchedBall ( RefereeMessageT rm,
00505 Time time );
00506 void processQueuedCommands ( SoccerCommand commands[],
00507 int iCommands );
00508 bool storePlayerMessage ( int iPlayer,
00509 char *strMsg,
00510 int iCycle );
00511 bool processPlayerMessage ( );
00512 bool processRecvThink ( bool b );
00513
00514
00515 bool updateAll ( );
00516
00517
00518 bool updateAfterSenseMessage ( );
00519
00520 private:
00521
00522 void processLastSeeMessage ( );
00523 bool updateAfterSeeMessage ( );
00524 bool updateAgentObjectAfterSee ( );
00525 bool updateDynamicObjectAfterSee( ObjectT o );
00526
00527
00528 void processLastSenseMessage ( );
00529 bool updateAgentAndBallAfterSense( );
00530 bool updateBallAfterKick ( SoccerCommand soc );
00531 bool updateDynamicObjectForNextCycle( ObjectT o,
00532 int iCycle );
00533 bool updateBallForCollision ( VecPosition posAgent );
00534
00535
00536 bool updateRelativeFromGlobal ( );
00537 bool updateObjectRelativeFromGlobal( ObjectT o );
00538
00539
00540 bool calculateStateAgent ( VecPosition *posGlobal,
00541 VecPosition *velGlobal,
00542 AngDeg *angGlobal );
00543 void initParticlesAgent ( AngDeg angGlobal );
00544 void initParticlesAgent ( VecPosition posInitital );
00545 int checkParticlesAgent ( AngDeg angGlobalNeck );
00546 void updateParticlesAgent ( VecPosition vel,
00547 bool bAfterSense );
00548 VecPosition averageParticles ( VecPosition posArray[],
00549 int iLength );
00550 void resampleParticlesAgent ( int iLeft );
00551 bool calculateStateAgent2 ( VecPosition *posGlobal,
00552 VecPosition *velGlobal,
00553 AngDeg *angGlobal );
00554 bool calculateStateAgent3 ( VecPosition *posGlobal,
00555 VecPosition *velGlobal,
00556 AngDeg *angGlobal );
00557 VecPosition calculatePosAgentWith2Flags( ObjectT objFlag1,
00558 ObjectT objFlag2 );
00559 AngDeg calculateAngleAgentWithPos ( VecPosition pos );
00560
00561
00562
00563 bool calculateStateBall ( VecPosition *posGlobal,
00564 VecPosition *velGlobal );
00565 void initParticlesBall ( VecPosition posArray[],
00566 VecPosition velArray[],
00567 int iLength );
00568 void checkParticlesBall ( VecPosition posArray[],
00569 VecPosition velArray[],
00570 int iLength,
00571 int *iNrLeft );
00572 void updateParticlesBall ( VecPosition posArray[],
00573 VecPosition velArray[],
00574 int iLength,
00575 double dPower,
00576 AngDeg ang );
00577 void resampleParticlesBall ( VecPosition posArray[],
00578 VecPosition velArray[],
00579 int iLength,
00580 int iLeft );
00581 ObjectT getMaxRangeUnknownPlayer ( ObjectT obj,
00582 char* strMsg );
00583 VecPosition calculateVelocityDynamicObject( ObjectT o );
00584
00585
00586
00587 bool calculateStatePlayer ( ObjectT o,
00588 VecPosition *posGlobal,
00589 VecPosition *velGlobal );
00590
00591
00592 bool getMinMaxDistQuantizeValue ( double dInput,
00593 double *dMin,
00594 double *dMax,
00595 double x1,
00596 double x2 );
00597 bool getMinMaxDirChange ( double dOutput,
00598 double *dMin,
00599 double *dMax,
00600 double x1 );
00601 bool getMinMaxDistChange ( double dOutput,
00602 double dDist,
00603 double *dMin,
00604 double *dMax,
00605 double x1,
00606 double xDist1,
00607 double xDist2 );
00608 double invQuantizeMin ( double dOutput,
00609 double dQuantizeStep );
00610 double invQuantizeMax ( double dOutput,
00611 double dQuantizeStep );
00612
00613
00614 public:
00615
00616 void mapUnknownPlayers ( Time time );
00617 bool updateSSToHeteroPlayerType ( int iPlayerType );
00618 bool resetTimeObjects ( );
00619 void removeGhosts ( );
00620
00621
00623
00624
00625 bool predictStateAfterCommand ( SoccerCommand com,
00626 VecPosition *pos,
00627 VecPosition *vel,
00628 AngDeg *angGlobalBody,
00629 AngDeg *angGlobalNeck,
00630 ObjectT obj=OBJECT_ILLEGAL,
00631 Stamina *sta = NULL );
00632 bool predictAgentStateAfterCommand(SoccerCommand com,
00633 VecPosition *pos,
00634 VecPosition *vel,
00635 AngDeg *angBody,
00636 AngDeg *angNeck,
00637 Stamina *sta );
00638 bool predictObjectStateAfterCommand( ObjectT obj,
00639 SoccerCommand com,
00640 VecPosition *pos,
00641 VecPosition *vel,
00642 AngDeg *angBody,
00643 AngDeg *angNeck,
00644 Stamina *sta );
00645 VecPosition predictAgentPosAfterCommand( SoccerCommand com );
00646 void predictStateAfterDash ( double dActualPower,
00647 VecPosition *pos,
00648 VecPosition *vel,
00649 Stamina *sta,
00650 double dDirection,
00651 ObjectT o=OBJECT_ILLEGAL);
00652 void predictStateAfterTurn ( AngDeg dSendAngle,
00653 VecPosition *pos,
00654 VecPosition *vel,
00655 AngDeg *angBody,
00656 AngDeg *angNeck,
00657 ObjectT obj=OBJECT_ILLEGAL,
00658 Stamina *sta = NULL );
00659 void predictBallInfoAfterCommand( SoccerCommand soc,
00660 VecPosition *pos = NULL,
00661 VecPosition *vel = NULL );
00662 VecPosition predictPosAfterNrCycles ( ObjectT o,
00663 double dCycles,
00664 int iDashPower = 100,
00665 VecPosition *posIn = NULL,
00666 VecPosition *velIn = NULL,
00667 bool bUpdate = true );
00668 VecPosition predictAgentPos ( int iCycles,
00669 int iDashPower = 0 );
00670 VecPosition predictFinalAgentPos ( VecPosition *pos = NULL,
00671 VecPosition *vel = NULL );
00672 int predictNrCyclesForDistance ( ObjectT o,
00673 double dDist,
00674 double dCurSpeed );
00675 int predictNrCyclesToPoint ( ObjectT o,
00676 VecPosition posTo );
00677 int predictNrCyclesToObject ( ObjectT objFrom,
00678 ObjectT objTo );
00679 void predictStaminaAfterDash ( double dPower,
00680 Stamina *sta );
00681 SoccerCommand predictCommandTurnTowards ( ObjectT obj,
00682 VecPosition posTo,
00683 int iCycles,
00684 double dDistBack,
00685 bool bMoveBack,
00686 VecPosition *pos = NULL,
00687 VecPosition *vel = NULL,
00688 AngDeg *angBody = NULL );
00689 SoccerCommand predictCommandToMoveToPos ( ObjectT obj,
00690 VecPosition posTo,
00691 int iCycles,
00692 double dDistBack = 2.5,
00693 bool bMoveBack = false,
00694 VecPosition *pos = NULL,
00695 VecPosition *vel = NULL,
00696 AngDeg *angBody = NULL );
00697 SoccerCommand predictCommandToInterceptBall( ObjectT obj,
00698 SoccerCommand soc,
00699 int *iCycles = NULL ,
00700 VecPosition *posIntercept=NULL,
00701 VecPosition *pos = NULL,
00702 VecPosition *vel = NULL,
00703 AngDeg *angBody = NULL );
00704 bool isCollisionAfterCommand ( SoccerCommand soc );
00705
00706
00708
00709
00710 int getNrInSetInRectangle ( ObjectSetT objectSet,
00711 Rect *rect = NULL );
00712 int getNrInSetInCircle ( ObjectSetT objectSet,
00713 Circle c );
00714 int getNrInSetInCone ( ObjectSetT objectSet,
00715 double dWidth,
00716 VecPosition start,
00717 VecPosition end );
00718 bool isEmptySpace ( ObjectT obj,
00719 AngDeg ang,
00720 double dDist = 4.0 );
00721 bool coordinateWith ( ObjectT obj );
00722
00723
00724 ObjectT getClosestInSetTo ( ObjectSetT objectSet,
00725 ObjectT o ,
00726 double *dDist = NULL,
00727 double dConfThr = -1.0 );
00728 ObjectT getClosestInSetTo ( ObjectSetT objectSet,
00729 VecPosition pos,
00730 double *dDist = NULL,
00731 double dConfThr = -1.0 );
00732 ObjectT getClosestInSetTo ( ObjectSetT objectSet,
00733 Line l,
00734 VecPosition pos1,
00735 VecPosition pos2,
00736 double *dDistToLine= NULL,
00737 double *dDistPos1To=NULL);
00738 ObjectT getClosestRelativeInSet ( ObjectSetT set,
00739 double *dDist = NULL );
00740 ObjectT getSecondClosestInSetTo ( ObjectSetT objectSet,
00741 ObjectT o,
00742 double *dDist = NULL,
00743 double dConfThr = -1.0 );
00744 ObjectT getSecondClosestRelativeInSet( ObjectSetT set,
00745 double *dDist = NULL );
00746 void createInterceptFeatures ( );
00747 ObjectT getFastestInSetTo ( ObjectSetT objectSet,
00748 ObjectT o,
00749 int *iCycles = NULL );
00750 ObjectT getFastestInSetTo ( ObjectSetT objectSet,
00751 VecPosition pos,
00752 VecPosition vel,
00753 double dDecay,
00754 int *iCycles = NULL );
00755 ObjectT getFurthestInSetTo ( ObjectSetT objectSet,
00756 ObjectT o ,
00757 double *dDist = NULL,
00758 double dConfThr = -1.0 );
00759 ObjectT getFurthestRelativeInSet ( ObjectSetT set,
00760 double *dDist = NULL );
00761 VecPosition getPosClosestOpponentTo ( double *dDist = NULL,
00762 ObjectT o =OBJECT_ILLEGAL);
00763 double getMaxTraveledDistance ( ObjectT o );
00764
00765 ObjectT getFirstEmptySpotInSet ( ObjectSetT objectSet,
00766 int iUnknownPlayer=-1);
00767
00768
00769 bool isVisible ( ObjectT o );
00770 bool isBallKickable ( );
00771 bool isBallCatchable ( );
00772 bool isBallHeadingToGoal ( );
00773 bool isBallInOurPossesion ( );
00774 bool isBallInOwnPenaltyArea ( );
00775 bool isInOwnPenaltyArea ( VecPosition pos );
00776 bool isInTheirPenaltyArea ( VecPosition pos );
00777 bool isConfidenceGood ( ObjectT );
00778 bool isConfidenceVeryGood ( ObjectT );
00779 bool isOnside ( ObjectT );
00780 bool isOpponentAtAngle ( AngDeg ang,
00781 double dDist );
00782
00783
00784 Time getTimeFromConfidence ( double dConf );
00785 double getOffsideX ( bool bIncludeComm=true);
00786 VecPosition getOuterPositionInField ( VecPosition pos,
00787 AngDeg ang,
00788 double dDist = 3.0,
00789 bool bWithPenalty=true);
00790 AngDeg getDirectionOfWidestAngle ( VecPosition posOrg,
00791 AngDeg angMin,
00792 AngDeg angMax,
00793 AngDeg *ang,
00794 double dDist );
00795 bool isInField ( VecPosition pos,
00796 double dMargin = 1 );
00797 bool isBeforeGoal ( VecPosition pos );
00798
00799
00800 VecPosition getStrategicPosition ( ObjectT obj,
00801 FormationT ft = FT_ILLEGAL );
00802 VecPosition getStrategicPosition ( int iPlayer = -1,
00803 FormationT ft = FT_ILLEGAL );
00804 VecPosition getMarkingPosition ( VecPosition pos,
00805 double dDist,
00806 MarkT mark );
00807 int getClosestPlayerInFormationTo( VecPosition pos,
00808 bool bWithGoalie = 1,
00809 ObjectT obj=OBJECT_ILLEGAL,
00810 PlayerSetT ps = PS_ALL,
00811 FormationT ft = FT_ILLEGAL );
00812
00813
00814
00815 double getActualKickPowerRate ( );
00816 double getKickPowerForSpeed ( double dDesiredSpeed );
00817 double getKickSpeedToTravel ( double dDistance,
00818 double dEndSpeed );
00819 double getFirstSpeedFromEndSpeed ( double dEndSpeed,
00820 double dCycles,
00821 double dDecay = -1.0 );
00822 double getFirstSpeedFromDist ( double dDist,
00823 double dCycles,
00824 double dDecay = -1.0 );
00825 double getEndSpeedFromFirstSpeed ( double dFirstSpeed,
00826 double dCycles );
00827 AngDeg getAngleForTurn ( AngDeg angDesiredAngle,
00828 double dSpeed,
00829 ObjectT o=OBJECT_ILLEGAL);
00830 AngDeg getActualTurnAngle ( AngDeg angActualAngle,
00831 double dSpeed,
00832 ObjectT o=OBJECT_ILLEGAL);
00833 double getPowerForDash ( VecPosition posRelTo,
00834 AngDeg angBody,
00835 VecPosition vel,
00836 double dEffort,
00837 int iCycles = 1 );
00838
00839
00841
00842
00843 WorldModel ( ServerSettings *ss,
00844 PlayerSettings *ps,
00845 Formations *fs );
00846 ~WorldModel ( );
00847
00848
00849 void show ( ostream &os = cout );
00850 void show ( ObjectSetT set,
00851 ostream &os = cout );
00852 void showQueuedCommands ( ostream &os = cout );
00853 void show ( ObjectT o,
00854 ostream &os = cout );
00855
00856
00857 bool waitForNewInformation ( );
00858
00859
00860 void logObjectInformation ( int iLogLevel,
00861 ObjectT o );
00862 void logDrawInfo ( int iLogLevel );
00863 void logCoordInfo ( int iLogLevel );
00864 bool logCircle ( int iLogLevel,
00865 VecPosition pos,
00866 double dRadius,
00867 bool bAll = false );
00868 bool logLine ( int iLogLevel,
00869 VecPosition pos1,
00870 VecPosition pos2,
00871 bool bAll = false );
00872 bool logDrawBallInfo ( int iLogLevel );
00873 void drawCoordinationGraph ( );
00874
00875
00876 char m_colorPlayers[11][8];
00878 int m_iMultX;
00883 int m_iMultY;
00889 bool isFeatureRelevant ( FeatureT type );
00890 Feature getFeature ( FeatureT type );
00891 bool setFeature ( FeatureT type,
00892 Feature feature );
00893 };
00894
00895 #endif