-
Notifications
You must be signed in to change notification settings - Fork 1
/
sense_improved.cpp
33 lines (28 loc) · 786 Bytes
/
sense_improved.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "headers/sense_improved.h"
using namespace std;
// passing grid and belief by reference
vector< vector <float> > sense_improved(char color,
vector< vector <char> > &grid,
vector< vector <float> > &beliefs,
float p_hit,
float p_miss)
{
int height, width;
height = grid.size();
width = grid[0].size();
for (int i=0; i < height; ++i) {
for (int j=0; j < width; ++j) {
// remove the cell variable since not needed
if (grid[i][j] == color) {
// update the belief vector instead of creating new variable
beliefs[i][j] = beliefs[i][j] * p_hit;
}
// remove the extra if statement since not needed
else {
// update the belief vector instead of creating new variable
beliefs[i][j] = beliefs[i][j] * p_miss;
}
}
}
return beliefs;
}