Page 1 of 1

fill in the missing spaces of the C++ programming code follow the given structure and write the needed code parts on the

Posted: Thu May 26, 2022 9:37 am
by answerhappygod
fill in the missing spaces of the C++ programming code follow
the given structure and write the needed code parts on the comment
spaces.
///
///////////////////////////////////////////////////////
/// SAMPLE RUN OF PROGRAM:

///
///

///
/// Threads = 8

///
/// Iterations = 3650

///
/// Start Wallet = R 1000

///
/// Bet Amount = R 5

///
/// Wallet = R
-6710
///
/// Percentage of Wins = 28.9589 %
///
/// Percentage of Losses = 71.0411 %
///
///

///
/// Process returned 0 (0x0) execution time : 0.235 s
///
/// Press any key to continue.
///
/// ///////////////////////////////////////////////////////
/// Source code of the main.cpp file for the Batota Project
/// Task 1.1: Include additional libraries [3]
/// Include additional libraries that are required to:
/// • Print messages on the command line
/// • Allow the use of random number in your source code
/// • Provide the ability to create code that is executed on
multiple processors.
using namespace std;
/// Task 1.2: Declare publically available card_type class
specified as follows: [30]
/// • A member variable card_suit represented by a positive
number
/// • A member variable card_rank represented by a positive
number
/// • A member variable used_flag representing whether a card is
used or not
/// • A constructor taking no arguments
/// • A constructor taking a card_suit and a card_rank as
arguments
/// • A boolean compare member method taking an unchanged
input_card reference
/// • A void print method taking no arguments to print out a
card
card_type::card_type(void) {
this->card_suit=0;
this->card_rank=0;
used_flag=0;
}
/// Task 1.3: Develop a constructor for the card_type structure
[15]
/// This constructor should take as input the suit and rank of a
card
/// and initialize the card_type structure using the provided card
information.
/// Task 1.4: Complete the compare member function [15]
/// The compare member function should compare the information of
the input card
/// and the current card and determine if they are the same.
/// If the input and current card are the same,
/// then the compare function should return true, otherwise it
should return false.
bool card_type::compare(const card_type &input_card) {
}
void card_type::print() {
cout << "Suit: " << card_suit << ",
Rank:" << card_rank << endl;
}
/// Task 1.5: Complete the generate_card_deck non-member
[20]
/// The generate_card_deck function should generate and return
a
/// full deck of cards, without jokers.
/// Remember that a traditional deck of cards has 4 suits:
/// Diamonds, Hearts, Spades and Clubs and each of these suits
has
/// an Ace, 2, 3, 4, 5, 6, 7, 8, 9, Jack, Queen and a King
card.
/// Make use of the card_type structure to represent the deck of
cards.
vector<card_type> generate_card_deck(void) {
}
/// Task 1.6: Complete the draw_hand_of_cards non-member
function [20]
/// This function should draw or select several cards from the
provided deck
/// of cards and return the selected hand of cards in a
vector.
/// The number of cards that needs to be selected is specified by
the card_count parameter.
/// Each card in the deck can only be used once to build the hand
of cards.
vector<card_type> draw_hand_of_cards(unsigned int
card_count,vector<card_type> deck) {
//Reset the Usage of the cards in the deck
for(unsigned int
c_id=0;c_id<deck.size();c_id++)
deck[c_id].used_flag=false;
unsigned int n_cards=deck.size();
vector<card_type> hand;
for(unsigned int c_id=0;c_id<card_count;c_id++)
{
}
return hand;
}
int main() {
// Set seed for Random generator
srand(time(NULL));
// Generate deck of 52 cards
vector<card_type> deck=generate_card_deck();
// Experiments or trials data
unsigned int n_dealer_cards=14; // Since we count from
0
unsigned int n_wins=0; //
Haven't won anything yet
unsigned int n_threads=8; // Depends on
your mach but trying varying and see what happens ...
unsigned int n_iterations= 3650; // Try varying this and see the
results of the simulation ...
double wallet_amount=1000.0; // Try varying this and
see the results of the simulation ...
double bet_amount=5.0; // Try
varying this and see the results of the simulation ...
cout << "Threads
= " << n_threads <<
endl;
cout << "Iterations = "
<< n_iterations << endl;
cout << "Bet Amount = R
" << bet_amount << endl;
/// Task 2.1: Parallelize the Monte Carlo iterations [6]
/// Add compiler directives to parallelize the FOR loop
/// of the Monte Carlo simulation iterations.
/// Also, add code to force the compiler to make use of 8
processors or threads.
for(unsigned int iter=0;iter<n_iterations;iter++) {
/// Task 2.2: Generate player and dealer cards [13]
/// • Step 1: Draw a single card for the player and store the card
as the variable player_card
/// • Step 2: Draw 14 cards for the dealer and store them in a
vector of cards called dealer_cards
/// • Remember to make use of previously develop functions and
structures.
/// Task 2.3: Check if player wins [8]
/// Write code to determine if the player has won or lost.
/// Set the variable player_wins to true if the player wins and
false for all other conditions.
/// Make use of previously developed functions and ensure that no
unnecessary comparisons are performed.
/// Remember that the card of the player is stored in player_card
and the cards of the dealer is stored as dealer_cards.
bool player_wins=false;
/// Task 2.4: Place bet and calculate winnings [13]
/// The money that is available to the player is stored in the
wallet_amount variable.
/// If the player uses more money than what is available in the
wallet, a loan shark
/// will lend the player the outstanding amount, meaning that a
wallet amount can be negative.
/// Place a bet that is the value of bet_amount and add the winning
to his wallet if a winning condition was achieved.
} // for(unsigned int iter=0;iter<n_iterations;iter++)
/// Task 2.5: Calculate the probability of winning or losing
[20]
/// The Monte Carlo Simulation performed 3650 experiments,
/// which is roughly equivalent to playing the Botato game once
every day for 5 years.
/// Display the results of the simulation using the following
form.
return 0;
} // int main()
/// Task 3.0: Comment on the game and what your simulations
show? [37]
/// This means you should provide your answer in a comment block so
it can still compile.
/// Please give your OWN observations, comments and
conclusions.
/// If this section of your answer even remotely resembles someone
else's response,
/// then you will (BOTH || ALL) lose this marks for COPYING
(serious University infringement),
/// because your response must be individual and cannot be like
anyone else's.
/// END OF TEST PROGRAM