Open JayCastro opened 4 years ago
I would search the document for changeDoor.
Note it is defined as change_door() in the chunk. It must be spelled differently in another chunk.
change_door <- function( stay=T, opened.door, a.pick )
{
# YOUR CODE HERE...
return( final.pick ) # number between 1 and 3
}
Is it change_door instead of changeDoor because thats how it is in the Lab work that was given to us so I decided not to change.
Okay i did that change and i think it works . Can i get it submitted early to have it checked cause i think i did it right?
Yeah, it was a typo in the test code for Step 05. The lab instructions have been updated.
https://ds4ps.org/cpp-527-fall-2020/labs/lab-01-instructions.html
Go ahead and paste the results from the test code section here. We can tell if your functions are working based upon the output:
What does this chunk return:
# your game "recipe"
this.game <- create_game()
my.initial.pick <- select_door()
opened.goat.door <- open_goat_door( this.game, my.initial.pick )
# save results for both strategies for the game
my.final.pick.stay <- change_door( stay=T,
opened.door=opened.goat.door,
a.pick=my.initial.pick )
my.final.pick.switch <- change_door( stay=F,
opened.door=opened.goat.door,
a.pick=my.initial.pick )
# print game details and if you won
# if you stayed:
paste0( "GAME SETUP" )
this.game
paste0( "My initial selection: ", my.initial.pick )
paste0( "The opened goat door: ", opened.goat.door )
paste0( "My final selection: ", my.final.pick.stay )
paste0( "GAME OUTCOME:" )
determine_winner( final.pick=my.final.pick.stay,
game=this.game )
# if you switched:
paste0( "GAME SETUP" )
this.game
paste0( "My initial selection: ", my.initial.pick )
paste0( "The opened goat door: ", opened.goat.door )
paste0( "My final selection: ", my.final.pick.switch )
paste0( "GAME OUTCOME:" )
determine_winner( final.pick=my.final.pick.switch,
game=this.game )
[1] "GAME SETUP" [1] "goat" "goat" "car" [1] "My initial selection: 3" [1] "The opened goat door: goat" [1] "My final selection: 3" [1] "GAME OUTCOME:" [1] "WIN" [1] "GAME SETUP" [1] "goat" "goat" "car" [1] "My initial selection: 3" [1] "The opened goat door: goat" [1] "My final selection: 1" [1] "GAME OUTCOME:" [1] "LOSE"
Looks fine to me. The only problem is the open_goat_door() function should return the door number, not the thing behind the door. If you are opening the goat door you know it's a goat already. There is no way to verify the door is correct, then, and it is also ambiguous moving to the next step because there are two goat doors.
[1] "The opened goat door: goat"
Try re-running that test code several times as well. It randomizes the order every time.
Hi for this lab I get this error
Error in changeDoor(stay = T, opened.door = opened.door, a.pick = my.initial.pick) : could not find function "changeDoor"
I dont know how much of my code I am allowed to send