From 0cf7e0d3e1a3506533fa27ef712ee612e3fa8657 Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Tue, 26 Feb 2019 14:00:34 -0600 Subject: MEANINGFUL CO M M EN TS Also making 3B a function cause why not. --- ee1301/wk3/hw3_directory/strap012_HW3A.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'ee1301/wk3/hw3_directory/strap012_HW3A.cpp') diff --git a/ee1301/wk3/hw3_directory/strap012_HW3A.cpp b/ee1301/wk3/hw3_directory/strap012_HW3A.cpp index 453af2d..9aacf63 100644 --- a/ee1301/wk3/hw3_directory/strap012_HW3A.cpp +++ b/ee1301/wk3/hw3_directory/strap012_HW3A.cpp @@ -14,6 +14,13 @@ One-armed Bandit Simulator #include using namespace std; +// Function: spin_the_wheel +// --------------------------- +// Simulates the one-armed bandit from the previous HW +// d: the number of options on the spinner +// w: the number of spinners +// returns: Either 1 for win or 0 for loss + int spin_the_wheel(int d, int w) { int spinOG=0, spinNew=0, win=0; spinOG = ( (rand() % d) + 1); //Original spin is always the same @@ -24,15 +31,15 @@ int spin_the_wheel(int d, int w) { } } if (win==w) { //The only win condition is if every wheel matches - return 1; //"win" + return 1; } else { - return 0; //"loss" + return 0; } } int main () { srand(88888888); //Seeds the RNG of the program to a constant of eight 8s - int w, d, m, winTest; //'w' is for spinner count, 'd' is the number of options on the spinner + int w, d, m, winTest; for (w=3; w<=6; w++) { m=0; for (d=9; d<=27; d++) { -- cgit v1.2.3