Skip to content

Commit

Permalink
Negative goal is actually fine, collision avoidance is learned very w…
Browse files Browse the repository at this point in the history
…ell now, it's also collecting food perfectly
  • Loading branch information
patham9 committed Nov 11, 2020
1 parent 3d1f64f commit fdbfc8d
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/system_tests/Robot_Test.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,10 @@ Perception Agent_View()
world[pX][pY].food = false;
spawnFood(true);
}
if(ret.forward_pX != pX || ret.forward_pY != pY)
{
ret.moved = true;
}
return ret;
}

Expand Down Expand Up @@ -448,6 +452,7 @@ void buildRooms()
}
}

bool collided = false;
void Agent_Invoke()
{
Perception percept = Agent_View();
Expand All @@ -472,13 +477,29 @@ void Agent_Invoke()
{
NAR_AddInputNarsese(narseseR);
}
if(percept.moved && collided)
{
collided = false;
NAR_AddInputNarsese("(! collision). :|:");
}
if(percept.viewfield[1] == 'w') //distance or touch sensor
{
collided = true;
}
if(percept.reward)
{
eaten++;
NAR_AddInputNarsese("eaten. :|:");
}
allowAction = true;
NAR_AddInputNarsese("eaten! :|:");
if(collided)
{
NAR_AddInputNarsese("(! collision)! :|:");
}
else
{
NAR_AddInputNarsese("eaten! :|:");
}
}

void NAR_Robot(long iterations)
Expand Down

0 comments on commit fdbfc8d

Please sign in to comment.