25 #include <utils/DataCollector.hpp> 
   28 namespace algorithms {
 
   50         mic::types::MatrixXdPtr position_probabilities(
new mic::types::MatrixXd (maze_height, 
maze_width));
 
   66     if (hidden_maze_number_ == -1) {
 
   72     if (hidden_x_ == -1) {
 
   91     LOG(LNOTICE) << 
"Initial maze_position_probabilities:";
 
  122         mic::types::MatrixXiPtr maze = 
mazes[m];
 
  127                 short patch_id = (*maze)(i,j);
 
  135     LOG(LNOTICE) << 
"maze_patch_probabilities:";
 
  149     LOG(LINFO) << 
"Current observation=" << 
obs;
 
  157         mic::types::MatrixXiPtr maze = 
mazes[m];
 
  168                 if ((*maze)(y,x) == 
obs)
 
  169                     (*pos_probs)(y,x) *= hit_factor_;
 
  171                     (*pos_probs)(y,x) *= miss_factor_;
 
  172                 prob_sum += (*pos_probs)(y,x);
 
  177     prob_sum = 1/prob_sum;
 
  183                 (*pos_probs)(i,j) *= prob_sum;
 
  188         LOG(LNOTICE) << 
"maze(" <<m<<
"):\n" << (*
mazes[m]);
 
  195     LOG(LINFO) << 
"Current move dy,dx= ( " << ac_.dy << 
"," <<ac_.dx<< 
")";
 
  200         mic::types::MatrixXd old_pose_probs = (*pos_probs);
 
  210                 (*pos_probs)((y + maze_height +  ac_.dy) %maze_height, (x +maze_width +  ac_.dx) % 
maze_width) = old_pose_probs(y, x);
 
  216         LOG(LNOTICE) << 
"maze(" <<m<<
"):\n" << (*
mazes[m]);
 
  230     LOG(LINFO) << 
"Current move dy,dx= ( " << ac_.dy << 
"," <<ac_.dx<< 
")";
 
  236         mic::types::MatrixXd old_pose_probs = (*pos_probs);
 
  238         (*pos_probs).setZero();
 
  243                 size_t exact_y = (y + maze_height +  ac_.dy) %maze_height;
 
  244                 size_t overshoot_y = (y + maze_height +  ac_.dy + 1) %maze_height;
 
  245                 size_t undershoot_y = (y + maze_height +  ac_.dy - 1) %maze_height;
 
  247                 size_t exact_x = (x + maze_width +  ac_.dx) %maze_width;
 
  248                 size_t overshoot_x = (x + maze_width +  ac_.dx + 1) %maze_width;
 
  249                 size_t undershoot_x = (x + maze_width +  ac_.dx - 1) %maze_width;
 
  251                 (*pos_probs)(exact_y, exact_x) += exact_move_probability_  * old_pose_probs(y, x);
 
  252                 (*pos_probs)(overshoot_y, overshoot_x) += overshoot_move_probability_  * old_pose_probs(y, x);
 
  253                 (*pos_probs)(undershoot_y, undershoot_x) += undershoot_move_probability_  * old_pose_probs(y, x);
 
  259         LOG(LNOTICE) << 
"maze(" <<m<<
"):\n" << (*
mazes[m]);
 
  319     double best_action_utility = 0.0;
 
  320     size_t best_action = -1;
 
  323     for (
size_t act_t=0; act_t < 4; act_t++) {
 
  324         mic::types::NESWAction ac((types::NESW)act_t);
 
  333                     size_t new_y = (y + maze_height + ac.dy) % maze_height;
 
  334                     size_t new_x = (x + maze_width + ac.dx) % maze_width;
 
  336                     short patch = (*
mazes[m])(new_y, new_x);
 
  337                     LOG(LDEBUG) << 
"maze [" << m << 
"] (y=" << y <<
",x="<< x <<
") move="<< act_t << 
"=> (y+dy=" << new_y << 
",x+dx=" << new_x <<
") patch=" << patch << std::endl;
 
  342                     LOG(LDEBUG) << 
"patch_prob= " << patch_prob << 
" action_utility=" << action_utility << std::endl;
 
  343                     if (action_utility > best_action_utility) {
 
  344                         best_action_utility = action_utility;
 
  346                         LOG(LDEBUG) << 
"found action " << best_action << 
" with biggest utility " << best_action_utility << std::endl;
 
  354     mic::types::NESWAction a((types::NESW) best_action);
 
  360     mic::types::VectorXf action_utilities(4);
 
  361     action_utilities.setZero();
 
  365     for (
size_t act_t=0; act_t < 4; act_t++) {
 
  366         mic::types::NESWAction ac((types::NESW)act_t);
 
  375                     size_t new_y = (y + maze_height + ac.dy) % maze_height;
 
  376                     size_t new_x = (x + maze_width + ac.dx) % maze_width;
 
  378                     short patch = (*
mazes[m])(new_y, new_x);
 
  379                     LOG(LDEBUG) << 
"maze [" << m << 
"] (y=" << y <<
",x="<< x <<
") move="<< act_t << 
"=> (y+dy=" << new_y << 
",x+dx=" << new_x <<
") patch=" << patch << std::endl;
 
  384                     LOG(LDEBUG) << 
"patch_prob= " << patch_prob << 
" action_utility=" << tmp_action_utility << std::endl;
 
  387                     action_utilities(act_t) += tmp_action_utility;
 
  395     size_t best_action = -1;
 
  396     double best_action_utility = 0.0;
 
  397     for (
size_t act_t=0; act_t < 4; act_t++) {
 
  398         if (action_utilities(act_t) > best_action_utility) {
 
  399             best_action_utility = action_utilities(act_t);
 
  401             LOG(LDEBUG) << 
"found action " << best_action << 
" with biggest utility " << best_action_utility << std::endl;
 
  407     mic::types::NESWAction a((types::NESW) best_action);
 
void probabilisticMove(mic::types::Action2DInterface ac_, double exact_move_probability_, double overshoot_move_probability_, double undershoot_move_probability_)
 
void setHiddenPose(int hidden_maze_number_, int hidden_x_, int hidden_y_)
 
unsigned int maze_width
Width of maze. 
 
std::vector< mic::types::MatrixXiPtr > mazes
List of mazes. 
 
void move(mic::types::Action2DInterface ac_)
 
unsigned int maze_height
Height of maze. 
 
void assignInitialProbabilities()
 
int hidden_maze_number
shortariable denoting in which maze are we right now (unknown, to be determined). ...
 
void sense(double hit_factor_, double miss_factor_)
 
int hidden_x
Variable denoting the x position are we right now (unknown, to be determined). 
 
mic::types::Action2DInterface sumOfMostUniquePatchesActionSelection()
 
mic::types::Action2DInterface mostUniquePatchActionSelection()
 
std::vector< double > maze_patch_probabilities
Variable storing the probability that we can find given patch in a given maze. 
 
std::vector< double > maze_probabilities
Variable storing the probability that we are currently moving in/observing a given maze...
 
unsigned int number_of_mazes
Problem dimensions - number of mazes. 
 
std::vector< double > maze_y_coordinate_probilities
Variable storing the probability that we are currently in a given y coordinate. 
 
void updateAggregatedProbabilities()
 
unsigned int problem_dimensions
Problem dimensions - number of mazes * their width * their height. 
 
void setMazes(std::vector< mic::types::MatrixXiPtr > &mazes_, unsigned int number_of_distinctive_patches_)
 
int hidden_y
Variable denoting the y position are we right now (unknown, to be determined). 
 
std::vector< double > maze_x_coordinate_probilities
Variable storing the probability that we are currently in a given x coordinate. 
 
short obs
Current Observation. 
 
unsigned int number_of_distinctive_patches
Problem dimensions - number of distinctive patches (in here - number of different digits...
 
std::vector< mic::types::MatrixXdPtr > maze_position_probabilities
Variable storing the probability that we are in a given maze position.