📄 memplayer.h
字号:
/* -*- Mode: C++ -*- *//* MemPlayer.h * CMUnited99 (soccer client for Robocup99) * Peter Stone <pstone@cs.cmu.edu> * Computer Science Department * Carnegie Mellon University * Copyright (C) 1999 Peter Stone * * CMUnited-99 was created by Peter Stone, Patrick Riley, and Manuela Veloso * * You may copy and distribute this program freely as long as you retain this notice. * If you make any changes or have any comments we would appreciate a message. * For more information, please see http://www.cs.cmu.edu/~robosoccer/ */#ifndef __player_h#define __player_h#include "netif.h"#include "types.h"#include "MemOption.h"#include "utils.h"#include "geometry.h"class Command {public: CMDType type; float power; float angle; float x; float y; Vqual qual; Vwidth width; char command[MAXMESG]; Time time; Command() { type = CMD_none; } inline Bool valid() { return (Bool) (type != CMD_none); } inline Bool valid(Time t) { return (Bool) (type != CMD_none && t == time); }};/*****************************************//*****************************************//*****************************************/class PlayerInfo : public OptionInfo{public: PlayerInfo(); virtual ~PlayerInfo(); void Initialize(); void SetPlayMode(Pmode mode); void sanitize_time(Time &tm); void EstimateMyPos(); void EstimateMyVel(Time time); Vector NewVelFromDash(Vector old_vel, float dash_power); void UpdateFromMyAction(Time time); void update_self_estimate(Time time); void update_self_neck_rel_ang(Time time); void update_stamina(Time time); void reset_stamina(); Time update_time(int time); virtual void VerifyDash(float *dash_power); /* You can specify a flag at compile time so that all the LogAction calls disappear If you add a LogAction, make sure to add it in both places */ /* The # at the end of the function name is the total # of args */#ifdef NO_ACTION_LOG inline void nothing_func(void) {}#define LogAction1(x1) nothing_func() #define LogAction2(x1,x2) nothing_func() #define LogAction3(x1,x2,x3) nothing_func() #define LogAction4(x1,x2,x3,x4) nothing_func() #define LogAction5(x1,x2,x3,x4,x5) nothing_func() #define LogAction6(x1,x2,x3,x4,x5,x6) nothing_func() #define LogAction7(x1,x2,x3,x4,x5,x6,x7) nothing_func() #define LogAction8(x1,x2,x3,x4,x5,x6,x7,x8) nothing_func() #define LogAction9(x1,x2,x3,x4,x5,x6,x7,x8,x9) nothing_func() #define LogAction10(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) nothing_func() /* inline void LogAction(int, char*) {} inline void LogAction(int, char*, char*) {} inline void LogAction(int, char*, char*, char*) {} inline void LogAction(int, char*, char) {} inline void LogAction(int, char*, float) {} inline void LogAction(int, char*, float, int) {} inline void LogAction(int, char*, float, float) {} inline void LogAction(int, char*, float, float, float) {} inline void LogAction(int, char*, float, float, float, float) {} inline void LogAction(int, char*, float, float, float, float, float) {} inline void LogAction(int, char*, float, float, float, float, float, float) {} inline void LogAction(int, char*, int) {} inline void LogAction(int, char*, int, int) {} */#else void LogAction2(int level, char* str); /* will be timestamped automatically */ void LogAction3(int level, char* str, char* param); void LogAction4(int level, char* str, char* param1, char* param2); void LogAction3(int level, char* str, char c1); void LogAction3(int level, char* str, float f1); void LogAction4(int level, char* str, float f1, int d1); void LogAction4(int level, char* str, float f1, float f2); void LogAction5(int level, char* str, float f1, float f2, float f3); void LogAction6(int level, char* str, float f1, float f2, float f3, float f4); void LogAction7(int level, char* str, float f1, float f2, float f3, float f4, float f5); void LogAction8(int level, char* str, float f1, float f2, float f3, float f4, float f5, float f6); void LogAction3(int level, char* str, int d1); void LogAction4(int level, char* str, int d1, int d2); void LogAction4(int level, char* str, int d1, float f1); void LogAction5(int level, char* str, int d1, float f1, float f2); void LogAction6(int level, char* str, int d1, float f1, float f2, float f3); void LogAction7(int level, char* str, int d1, float f1, float f2, float f3, float f4); void LogAction7(int level, char* str, int d1, int d2, float f1, float f2, float f3);#endif Socket *sock; char SaveLogFileName[MAX_FILE_LEN]; FILE *SaveLogFile; int SaveLogCounter; char SaveSoundLogFileName[MAX_FILE_LEN]; FILE *SaveSoundLogFile; int SaveSoundLogCounter; char SaveActionLogFileName[MAX_FILE_LEN]; FILE *SaveActionLogFile; int SaveActionLogCounter; char MySide; // 'l' or 'r' char TheirSide; // 'l' or 'r' char TheirTeamName[MAX_TEAMNAME_LEN]; // The name of their team int MyTeamNameLen; // strlen of MyTeamName Unum MyNumber; // uniform number int Initialized; Bool ServerAlive; // is the server going? Bool TestVersion; // is this the test version of the program? Bool CoachActive; // is there an on-line coach? int TimerInterval; Bool ClockStopped; int StoppedClockMSec; // time elapsed in before_kick_off_mode (msec) Time CurrentTime; // Most recently observed time Time LastTime; // previous time Time LastSightTime; // last time I saw Time LastSenseTime; // last time I sensed Time LastSoundTime; // last time I heard /* Don't need these after server 5.23 void SetRealTimeOfLastSend(struct timeval& tv) { real_time_of_last_send = tv;} struct timeval GetRealTimeOfLastSend() { return real_time_of_last_send;} Bool TooSoonForAnotherSend(); */ int LastSightInterval; // cycles between last 2 sights inline Time PreviousSightTime() { return LastSightTime - LastSightInterval; } // previous time I saw Command *Action; Command *LastAction; Command ChangeView; Command TurnNeck; inline Bool ResendNeeded() { return (RequestResend && CurrentTime == LastActionTime() && ResendTime == CurrentTime && LastActionType() == ResendType) ? TRUE : FALSE; } Bool RequestResend; CMDType ResendType; Time ResendTime; inline AngleDeg LastActionAngle() { return LastAction->angle; } inline float LastActionPower() { return LastAction->power; } inline float LastActionX() { return LastAction->y; } inline float LastActionY() { return LastAction->x; } inline CMDType LastActionType() { return LastAction->type; } inline Time LastActionTime() { return LastAction->time; } inline Bool LastActionValid() { return LastAction->valid(); } inline Bool LastActionValid(Time t) { return LastAction->valid(t); } /* have I already called a turn-neck? */ inline Bool TurnNeckThisCycle() { return TurnNeck.time == CurrentTime ? TRUE : FALSE; } Time LastBehaveTime; // last time into behave Time LastActionOpTime; // last time I could have acted Time LastInterruptTime; // last time into the alarm handler int InterruptsThisCycle; // number of times in so far Time LastStartClockTime; // time when server clock started again Time SecondLastStartClockTime; // time when server clock started again Bool NewSight; Bool NewAction; Bool FirstActionOpSinceLastSight; Bool SightPredictedEarlyThisCycle(); Bool GotSightFromCurrentPosition(); inline Bool TimeToTurnForScan() { return (SightPredictedEarlyThisCycle() || GotSightFromCurrentPosition()) ? TRUE : FALSE; } SenseType LastSenseType; Vqual ViewQuality; Vwidth ViewWidth; Vwidth LastViewWidth; Time ViewWidthTime;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -