aboutsummaryrefslogtreecommitdiffstats
path: root/ee1301/wk3/hw3_directory/strap012_HW3A.cpp
diff options
context:
space:
mode:
authorRossTheRoss <msattr@gmail.com>2019-02-26 14:00:34 -0600
committerRossTheRoss <msattr@gmail.com>2019-02-26 14:00:34 -0600
commit0cf7e0d3e1a3506533fa27ef712ee612e3fa8657 (patch)
tree040c783ca429a61e4d25b911c7603a71d52eb1bc /ee1301/wk3/hw3_directory/strap012_HW3A.cpp
parentMEANINGFUL C O M M E N T (diff)
downloadhomework-0cf7e0d3e1a3506533fa27ef712ee612e3fa8657.tar
homework-0cf7e0d3e1a3506533fa27ef712ee612e3fa8657.tar.gz
homework-0cf7e0d3e1a3506533fa27ef712ee612e3fa8657.tar.bz2
homework-0cf7e0d3e1a3506533fa27ef712ee612e3fa8657.tar.lz
homework-0cf7e0d3e1a3506533fa27ef712ee612e3fa8657.tar.xz
homework-0cf7e0d3e1a3506533fa27ef712ee612e3fa8657.tar.zst
homework-0cf7e0d3e1a3506533fa27ef712ee612e3fa8657.zip
MEANINGFUL CO M M EN TS
Also making 3B a function cause why not.
Diffstat (limited to 'ee1301/wk3/hw3_directory/strap012_HW3A.cpp')
-rw-r--r--ee1301/wk3/hw3_directory/strap012_HW3A.cpp13
1 files changed, 10 insertions, 3 deletions
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 <iomanip>
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++) {