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
00049 #ifndef PLAYER
00050 #define PLAYER
00051
00052 #include "BasicPlayer.h"
00053 #include "Formations.h"
00054 #include "SituationsLog.h"
00055 #include "SoccerTypes.h"
00056 #include "ArsToolbox.h"
00057 #include "PlayerActionCG.h"
00058
00059 #ifdef WIN32
00060 DWORD WINAPI stdin_callback( LPVOID v );
00061 #else
00062 void* stdin_callback( void * v );
00063 #endif
00064
00065 #include <stdio.h>
00066
00067
00068
00071 class Player:public BasicPlayer
00072 {
00073 SituationsLog *log;
00074 Formations *formations;
00075 bool bContLoop;
00078 Time m_timeLastSay;
00079 ObjectT m_objMarkOpp;
00080 ObjectT m_objPassOption;
00082 int m_iPenaltyNr;
00084 ActionT m_actionPrev;
00086 SoccerCommand goalieMainLoop ( );
00087 SoccerCommand defenderMainLoop ( );
00088 SoccerCommand midfielderMainLoop ( );
00089 SoccerCommand attackerMainLoop ( );
00090
00091 void performPenalty ( );
00092
00093
00094 VecPosition getDeadBallPosition ( );
00095 VecPosition goalMiddle;
00096
00097
00098 bool shallISaySomething ( SoccerCommand soc );
00099 bool amIAgentToSaySomething ( SoccerCommand soc );
00100 void sayOppAttackerStatus ( char * str );
00101 void sayBallStatus ( char * str );
00102 void makeBallInfo ( VecPosition posBall,
00103 VecPosition velBall,
00104 int iDiff,
00105 char * str );
00106
00107 public:
00108 Player ( ActHandler *a,
00109 WorldModel *wm,
00110 ServerSettings *ss,
00111 PlayerSettings *cs,
00112 Formations *fs,
00113 char *strTeamName,
00114 double dVersion,
00115 int iReconnect = -1 );
00116 ~Player();
00117
00118 void mainLoop ( );
00119
00120
00121
00122 void handleStdin ( );
00123 void showStringCommands ( ostream& out );
00124 bool executeStringCommand ( char *str );
00125
00126
00127 SoccerCommand kickToPass (double* dFitness = NULL );
00128 SoccerCommand kickToPlay ( );
00129 SoccerCommand kickToDrible ( );
00130 SoccerCommand kickToScore ( );
00131 SoccerCommand deMeer5 ( );
00132 SoccerCommand deMeer5_goalie ( );
00133
00134
00135 RoleCG * getPlayerRoles();
00136
00137
00138 RoleCG getMyRole();
00139
00140
00141 int getPlayerIndexRole(ObjectT o);
00142
00143 ObjectT getPlayerTypeRole(int index);
00144
00145
00146 double valueRuleInterc1(PlayerActionCG agentAction);
00147 double passTo (AngRad angle,
00148 ObjectT oPlayer,
00149 VecPosition *pos = NULL,
00150 double dConfThr = 0.9);
00151
00152
00153 double valueRulePasser1(RoleCG * playerRoles, int teammateIndex, PlayerActionCG agentAction, PlayerActionCG teammateAction,
00154 DirCG passDirection);
00155
00156 double valueRulePasser2(PlayerActionCG agentAction, DirCG emptySpaceDirection);
00157
00158 double valueRulePasser3(PlayerActionCG agentAction);
00159
00160 double valueRulePasser4(PlayerActionCG agentAction);
00161
00162
00163 double valueRuleReceiver1(RoleCG * playerRoles, int teammateIndex, PlayerActionCG agentAction, PlayerActionCG teammateAction,
00164 DirCG passDirection);
00165
00166 double valueRuleReceiver2(RoleCG * playerRoles, int teammateIndex1, int teammateIndex2, PlayerActionCG agentAction,
00167 PlayerActionCG teammateAction1,
00168 DirCG passDirection1,
00169 PlayerActionCG teammateAction2,
00170 DirCG passDirection2);
00171
00172 double valueRuleReceiver3(PlayerActionCG agentAction);
00173
00174
00175 double valueRulePassive1(PlayerActionCG agentAction);
00176
00177
00178
00179
00180 PlayerActionCG * variableEliminationAlgorithmCG();
00181
00182
00183 PlayerActionCG * Player::variableEliminationAlgorithmCG(RoleCG * playerRoles);
00184
00185
00186
00187 bool isPassBlockedCG(int playerIndex, int teammateIndex, DirCG passDirection);
00188
00189 bool isEmptySpace(int playerIndex, DirCG direction);
00190
00191 double uCG(int teammateIndex, DirCG passDirection);
00192
00193
00194 double transformGlobalDirectionToAngleCG(DirCG globalDirection);
00195
00196
00197 double getMax(double val1, double val2);
00198
00199 bool isInFrontOfGoalCG(VecPosition pos);
00200
00201 PlayerActionCG * getOptimalCommonAction();
00202
00203 private:
00204 double passToFitness (double from1X,
00205 double from1Y,
00206 double to1X,
00207 double to1Y,
00208 double pX,
00209 double pY,
00210 double toX,
00211 double toY,
00212 double r);
00213 double passToTeammateFitness (double from1X,
00214 double from1Y,
00215 double to1X,
00216 double to1Y,
00217 double pX,
00218 double pY,
00219 double toX,
00220 double toY,
00221 double r = -1);
00222 double passToOpponentFitness (double from1X,
00223 double from1Y,
00224 double to1X,
00225 double to1Y,
00226 double pX,
00227 double pY,
00228 double toX,
00229 double toY,
00230 double r = -1);
00231 bool isPassBlocked(ObjectT oPlayer, AngRad ang);
00232 double leadingPass(ObjectT oPlayer, AngRad ang);
00233 SoccerCommand circleKickToPass (double* dFitness = NULL);
00234 };
00235
00236 #endif