// War Card Game! (Build 15w30)
// This is is a player vs. cpu simulatation.
// The player will press space to place the
// next card down. The side with the higher
// card of the two wins the round. First one
// to have a full deck wins! (2 low - A high)
#include <iostream>
#include <algorithm>
#include <array>
#include <random>
#include <chrono>
float cards[52];
float collectDeck(float) //finds full deck.
{
int i = 0; // Counter
int c = 1; // Number of Card
int s = .1;// Suit of the Card
while(i < 52) // Makes sure only 52 cards are ran.
{
if(c == 13) // If a full suit is counted.
{
c = 0;
s = s + .1;
}
cards[i] = (c+s);
c++;
i++;
}
return (cards);
}
float shuffleCards (float)
{
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
shuffle (cards.begin(), cards.end(), std::default_random_engine(seed));
std::cout << "Shuffled Cards:";
for (int& x: foo) std::cout << ' ' << x;
std::cout << '\n';
return (cards);
}
int main ()
{
collectDeck();
shuffleCards();
return 0;
}
I need help on two things.
1. Get this script to run.
2. Know, if any, simpler way to shuffle my array!
This is only the beginning of my game (script wise) so I may of course be back for help if I absolutely need it.
Please, describe the errors that you get. (All Forum users are naturally psychics, who already see all the details, but you have to learn to look at the error messages as they can actually help you solve the problems.)
I hope this will help you. I think this is the one you want to happen to your code. Just ask me whenever you have questions regarding my modifications to your code.