Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
francescoriccio committed Mar 11, 2014
1 parent eede2ee commit d9ecaa6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
31 changes: 12 additions & 19 deletions machineLearning/DiveHandler/DiveHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

// Uncomment to have debug information
//#define DIVEHANDLER_DEBUG
//#define DIVEHANDLER_TRAINING_DEBUG
//#define DIVEHANDLER_TRAINING
#define DIVEHANDLER_TRAINING_DEBUG
#define DIVEHANDLER_TRAINING
//#define RAND_PERMUTATIONS

#define NEGATIVE_REWARD -1.0
Expand Down Expand Up @@ -253,8 +253,7 @@ float DiveHandler::PGLearner::evaluatePerturbation( std::vector<float> R )
new_coeffs.at(0) = coeffs.at(0) + R.at(0);
new_coeffs.at(1) = coeffs.at(1) + R.at(1);

return (diveHandler_ptr->estimatedInterval - ( R.at(0)*diveHandler_ptr->tBall2Goal))*
(diveHandler_ptr->estimatedInterval - ( R.at(0)*diveHandler_ptr->tBall2Goal)) ;
return ( std::abs(diveHandler_ptr->estimatedInterval - ( R.at(0)*diveHandler_ptr->tBall2Goal)) ) ;
// return (1.0-LAMBDA1)*fabs(diveHandler_ptr->tBall2Goal - tDiveAndRecover) +
// LAMBDA1*fabs(magnitude(coeffs) - magnitude(coeffsBest));

Expand Down Expand Up @@ -616,12 +615,15 @@ void DiveHandler::update(DiveHandle& diveHandle)
if( ((int) (clock() - timer.fallen)/(CLOCKS_PER_SEC/1000)) > 10001 &&
((int) (clock() - timer.fallen)/(CLOCKS_PER_SEC/1000)) < 10050 &&
(int) timer.fallen != 0)
// SPQR_SUCCESS("TooEarly time window START...");
#ifdef DIVEHANDLER_TRAINING
SPQR_SUCCESS("TooEarly time window START...");
#endif
if( ((int) (clock() - timer.fallen)/(CLOCKS_PER_SEC/1000)) > 14971 &&
((int) (clock() - timer.fallen)/(CLOCKS_PER_SEC/1000)) < 14999 &&
(int) timer.fallen != 0)
// SPQR_SUCCESS("TooEarly time window END.");

#ifdef DIVEHANDLER_TRAINING
SPQR_SUCCESS("TooEarly time window END.");
#endif
if( ((int) (clock() - timer.fallen)/(CLOCKS_PER_SEC/1000)) > 10000 &&
((int) (clock() - timer.fallen)/(CLOCKS_PER_SEC/1000)) < 15000 &&
(int) timer.fallen != 0)
Expand Down Expand Up @@ -663,7 +665,7 @@ void DiveHandler::update(DiveHandle& diveHandle)
if( tooEarly )
{
SPQR_FAILURE("too FAST dude!");
estimatedInterval += 2000;
estimatedInterval = timer.fallen + 3000;
tooEarly=false;
}
else
Expand All @@ -678,7 +680,7 @@ void DiveHandler::update(DiveHandle& diveHandle)
else if(ownScore != (int)theOwnTeamInfo.score && !estimatedTime)
{
SPQR_SUCCESS("SUPER!");
estimatedInterval -= 100;
estimatedInterval -= 200;
estimatedTime=true;
}

Expand Down Expand Up @@ -774,7 +776,7 @@ void DiveHandler::update(DiveHandle& diveHandle)
{
SPQR_INFO("diveTime: " << diveTime );
SPQR_INFO("estimated time interval: " << estimatedInterval );
SPQR_ERR("TimeError: "<< (estimatedInterval - diveTime)*(estimatedInterval - diveTime));
SPQR_ERR("TimeError: "<< std::abs(estimatedInterval - diveTime) );
SPQR_INFO("/-----------------------------------------/\n");
stamp = false;
}
Expand All @@ -791,15 +793,6 @@ void DiveHandler::update(DiveHandle& diveHandle)
diveHandle.diveTime = diveTime -tDive;
else
diveHandle.diveTime = -1.0;

#ifdef DIVEHANDLER_TRAINING
// if (diveTime > 0.0)
// {
// if(diveHandle.diveTime < SPQR::GOALIE_DIVE_TIME_TOLERANCE)
// SPQR_INFO("Dive now! ");
// }
#endif

}
// If the ball is far away or completely off target, no dive has to performed
else
Expand Down
6 changes: 3 additions & 3 deletions machineLearning/DiveHandler/DiveHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ END_MODULE
#define BUFFER_DIM 10
#define REWARDS_HISTORY_SIZE 10
#define EPSILON 0.05
#define T 15
#define T 5
// Evaluation weight
#define LAMBDA1 0.9
//#define LAMBDA2 0.3
Expand Down Expand Up @@ -214,15 +214,15 @@ class DiveHandler : public DiveHandlerBase
{
start = startTime;
setTimer = true;
// std::cerr << "\033[33;1m" <<"[DiveHandler] " << "set Timer!" << "\033[0m" << std::endl;
std::cerr << "\033[33;1m" <<"[DiveHandler] " << "set Timer!" << "\033[0m" << std::endl;
}
}
inline void reset()
{
if(setTimer)
{
setTimer = false;
// std::cerr << "\033[33;1m" <<"[DiveHandler] " << "reset Timer!" << "\033[0m" << std::endl;
std::cerr << "\033[33;1m" <<"[DiveHandler] " << "reset Timer!" << "\033[0m" << std::endl;
}
}
};
Expand Down

0 comments on commit d9ecaa6

Please sign in to comment.