top of page

Week 6: Day before The Trial...

First thing we wanted to do was test the light sensors, but it turns out that the extra weight from the different orientation of light sensors made the movement off once again. After guessing and checking values for amount of rotation and forward/backward movement to get things just right, Daedalus is functioning once again with the addition of the light sensors in the new orientation. Behold!

The final thing to do is to create the logic code to make little Daedalus a little smarter. For the explanation of this part of the code, I'll hand things over to Samm.

There is a helper function "updateMightBe" that takes in the current grid space and a character that signifies whether the square might be a breeze, wumpus, or gold.

It then updates all the surrounding squares as "mightBeBreeze", "mightBeWumpus" or "mightBeGold" respectively.

For each of the cases, they feed this information to the helper function and it then updates the square values.

 

void updateMightBe(my_grid[cur_x][cur_y], char x){

char mightBeX[20];

if (x == 'g'){ // mightBeGold

mightBeX = "mightBeGold";

}

if (x == 's'){

mightBeX = "mightBeWumpus";

}

if (x == 'b'){

mightBeX = "mightBeBreeze";

}

if (!isOutOfBounds(my_grid[cur_x+1][cur_y] && (my_grid[cur_x+1][cur_y].isUnknown)){

my_grid[cur_x+1][cur_y].mightBeX = true;

}

if (!isOutOfBounds(my_grid[cur_x-1][cur_y] && (my_grid[cur_x-1][cur_y].isUnknown)){

my_grid[cur_x-1][cur_y].mightBeX = true;

}

if (!isOutOfBounds(my_grid[cur_x][cur_y+1] && (my_grid[cur_x][cur_y+1].isUnknown)){

my_grid[cur_x][cur_y+1].mightBeX = true;

}

if (!isOutOfBounds(my_grid[cur_x][cur_y-1] && (my_grid[cur_x][cur_y-1].isUnknown)){

my_grid[cur_x][cur_y-1].mightBeX = true;

}

}

void foundGold(my_grid[cur_x][cur_y]){

// do what you're supposed to do when you find gold

my_grid[cur_x][cur_y].isGold = true;

printf("Found gold!\n");

}

void foundGlimmer(my_grid[cur_x][cur_y]){

//do what you're supposed to do when you find glimmer

printf("Found glimmer!\n");

// move safely around in glimmer squares until you find the gold

// for each surrounding square except the ones you've visited, change mightBeGold to True

updateMightBe(my_grid[cur_x][cur_y], 'g');

// Figure out where to move next, probably to one of these spots

}

void foundStench(my_grid[cur_x][cur_y]){

//do what you're supposed to do when you find a stench

// mark the squares around as potential wumpus

//go back and try a different something

printf("Found stench!\n");

updateMightBe(my_grid[cur_x][cur_y], 's');

}

void foundBreeze(my_grid[cur_x][cur_y]){

//do what you're supposed to do when you find a breeze

// mark the squares around as potential pit

//go back and try a different something

printf("Found breeze!\n");

updateMightBe(my_grid[cur_x][cur_y], 'b');

}

 

We'll be meeting again tomorrow to focus down on the code.


 
bottom of page