Skip to content

Instantly share code, notes, and snippets.

@fdavidcl
Created April 8, 2015 11:41
Show Gist options
  • Save fdavidcl/6b48129907895d94475c to your computer and use it in GitHub Desktop.
Save fdavidcl/6b48129907895d94475c to your computer and use it in GitHub Desktop.
EnvShow
void Environment::Show(int w,int h) const
{
const static float trufa_level=50.0;
/* Formatting */
const static string RED = "\e[31m";
const static string GREEN = "\e[32m";
const static string ORNG = "\e[33m";
const static string BLUE = "\e[34m";
const static string BOLD = "\e[1m";
const static string INV = "\e[7m";
const static string NO = "\e[m";
for (int row=0; row<MAZE_SIZE; row+=1)
{
for (int col=0; col<MAZE_SIZE; col+=1)
{
if (maze_[row][col] == OBSTACLE){
cout << BLUE << INV << " ";
}
else
{
if (row == agentPosX_ && col == agentPosY_){
cout << INV << BOLD;
switch(preAction_){
case Agent::actIDLE:
switch (agentOriented_){
case 0: // Orientacion Norte
cout << '^';
break;
case 1: // Orientacion Este
cout << '>';
break;
case 2: // Orientacion Sur
cout << 'v';
break;
case 3: // Orientacion Oeste
cout << '<';
break;
}
break;
case Agent::actSNIFF:
cout << ORNG << "?";
break;
case Agent::actEXTRACT:
cout << GREEN << "o";
break;
break;
case Agent::actFORWARD:
switch (agentOriented_){
case 0: // Orientacion Norte
cout << '^';
break;
case 1: // Orientacion Este
cout << '>';
break;
case 2: // Orientacion Sur
cout << 'v';
break;
case 3: // Orientacion Oeste
cout << '<';
break;
}
break;
case Agent::actTURN_L:
case Agent::actTURN_R:
switch (agentOriented_){
case 0: // Orientacion Norte
cout << '^';
break;
case 1: // Orientacion Este
cout << '>';
break;
case 2: // Orientacion Sur
cout << 'v';
break;
case 3: // Orientacion Oeste
cout << '<';
break;
}
break;
}
}
else if (maze2_[row][col]==0){
if (maze_[row][col] == 0)
cout << " ";
else if (maze_[row][col] < 5)
cout << "'";
else if (maze_[row][col]<10)
cout << '"';
else if (maze_[row][col]<15)
cout << '+';
else
cout << '*';
}
else if (maze2_[row][col]==1){
cout << RED << "3";
}
else if (maze2_[row][col]==2){
cout << RED << "2";
}
else if (maze2_[row][col]==3){
cout << RED << "1";
}
else {
cout << INV << RED << "x";
}
}
cout << " " << NO;
}// for - col
cout << endl;
}// for - row
cout << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment