gCycleChatBot::Sensor Class Reference

Inheritance diagram for gCycleChatBot::Sensor:

Inheritance graph
[legend]
Collaboration diagram for gCycleChatBot::Sensor:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Sensor (gCycle *o, const eCoord &start, const eCoord &d)
virtual void PassEdge (const eWall *ww, REAL time, REAL a, int r)
bool DoExtraDetectionStuff ()
REAL HitWallExtends (eCoord const &dir, eCoord const &origin)

Public Attributes

gCyclehitOwner_
REAL hitTime_
REAL hitDistance_
short lrSuggestion_
int windingNumber_


Detailed Description

Definition at line 329 of file gCycle.cpp.


Constructor & Destructor Documentation

gCycleChatBot::Sensor::Sensor ( gCycle o,
const eCoord &  start,
const eCoord &  d 
) [inline]

Definition at line 332 of file gCycle.cpp.

References gCycleMovement::GetDistance().

00333                 : gSensor(o,start,d)
00334                 , hitOwner_( 0 )
00335                 , hitTime_ ( 0 )
00336                 , hitDistance_( o->MaxWallsLength() )
00337                 , lrSuggestion_( 0 )
00338                 , windingNumber_( 0 )
00339         {
00340             if ( hitDistance_ <= 0 )
00341                 hitDistance_ = o->GetDistance();
00342         }

Here is the call graph for this function:


Member Function Documentation

virtual void gCycleChatBot::Sensor::PassEdge ( const eWall ww,
REAL  time,
REAL  a,
int  r 
) [inline, virtual]

Reimplemented from gSensor.

Definition at line 352 of file gCycle.cpp.

References gSensor::PassEdge().

00353         {
00354             try{
00355                 gSensor::PassEdge(ww,time,a,r);
00356             }
00357             catch( eSensorFinished & e )
00358             {
00359                 if ( DoExtraDetectionStuff() )
00360                     throw;
00361             }
00362         }

Here is the call graph for this function:

bool gCycleChatBot::Sensor::DoExtraDetectionStuff (  )  [inline]

Definition at line 364 of file gCycle.cpp.

References gPlayerWall::Cycle(), eWall::Edge(), gSENSOR_NONE, gSENSOR_RIM, gSENSOR_SELF, gPlayerWall::Pos(), eHalfEdge::Ratio(), REAL, sg_chatBotNewWallBlindness, gPlayerWall::Time(), and gPlayerWall::WindingNumber().

00365         {
00366             // move towards the beginning of a wall
00367             lrSuggestion_ = -lr;
00368 
00369             switch ( type )
00370             {
00371             case gSENSOR_NONE:
00372             case gSENSOR_RIM:
00373                 lrSuggestion_ = 0;
00374                 return true;
00375             default:
00376                 // unless it is an enemy, follow his wall instead (uncomment for a nasty cowardy campbot)
00377                 // lrSuggestion *= -1;
00378             case gSENSOR_SELF:
00379                 {
00380                     // determine whether we're hitting the front or back half of his wall
00381                     if ( !ehit )
00382                         return true;
00383                     eWall * wall = ehit->GetWall();
00384                     if ( !wall )
00385                         return true;
00386                     gPlayerWall * playerWall = dynamic_cast< gPlayerWall * >( wall );
00387                     if ( !playerWall )
00388                         return true;
00389                     hitOwner_ = playerWall->Cycle();
00390                     if ( !hitOwner_ )
00391                         return true;
00392 
00393                     // gCycleChatBot & enemyChatBot = Get( hitOwner_ );
00394 
00395                     REAL wallAlpha = playerWall->Edge()->Ratio( before_hit );
00396                     // that's an unreliable source
00397                     if ( wallAlpha < 0 )
00398                         wallAlpha = 0;
00399                     if ( wallAlpha > 1 )
00400                         wallAlpha = 1;
00401                     hitDistance_   = hitOwner_->GetDistance() - playerWall->Pos( wallAlpha );
00402                     hitTime_       = playerWall->Time( wallAlpha );
00403                     windingNumber_ = playerWall->WindingNumber();
00404 
00405                     // don't see new walls
00406                     if ( hitTime_ > hitOwner_->LastTime() - sg_chatBotNewWallBlindness && hitOwner_ != owned )
00407                     {
00408                         ehit = false;
00409                         hit = 1E+40;
00410                         return false;
00411                     }
00412 
00413                     // REAL cycleDistance = hitOwner_->GetDistance();
00414 
00415                     // REAL wallStart = 0;
00416 
00417                     /*
00418                     if ( gCycle::WallsLength() > 0 )
00419                     {
00420                         wallStart = cyclePos - playerWall->Cycle()->ThisWallsLength();
00421                         if ( wallStart < 0 )
00422                             wallStart = 0;
00423                     }
00424                     */
00425                 }
00426             }
00427 
00428             return true;
00429         }

Here is the call graph for this function:

REAL gCycleChatBot::Sensor::HitWallExtends ( eCoord const &  dir,
eCoord const &  origin 
) [inline]

Definition at line 432 of file gCycle.cpp.

References eCoord, and REAL.

Referenced by gCycleChatBot::Activate().

00433         {
00434             if ( !ehit || !ehit->Other() )
00435             {
00436                 return 1E+30;
00437             }
00438 
00439             REAL ret = -1E+30;
00440             eCoord ends[2] = { *ehit->Point(), *ehit->Other()->Point() };
00441             for ( int i = 1; i>=0; --i )
00442             {
00443                 REAL newRet = eCoord::F( dir, ends[i]-origin );
00444                 if ( newRet > ret )
00445                     ret = newRet;
00446             }
00447 
00448             return ret;
00449         }

Here is the caller graph for this function:


Member Data Documentation

gCycle* gCycleChatBot::Sensor::hitOwner_

Definition at line 451 of file gCycle.cpp.

Referenced by gCycleChatBot::Activate(), gCycleChatBot::Distance(), and gCycleChatBot::FindHugReplacement().

REAL gCycleChatBot::Sensor::hitTime_

Definition at line 452 of file gCycle.cpp.

Referenced by gCycleChatBot::Activate().

REAL gCycleChatBot::Sensor::hitDistance_

Definition at line 453 of file gCycle.cpp.

Referenced by gCycleChatBot::Distance().

short gCycleChatBot::Sensor::lrSuggestion_

Definition at line 454 of file gCycle.cpp.

int gCycleChatBot::Sensor::windingNumber_

Definition at line 455 of file gCycle.cpp.

Referenced by gCycleChatBot::Activate().


The documentation for this class was generated from the following file:
Generated on Sat Mar 15 23:36:30 2008 for Armagetron Advanced by  doxygen 1.5.4