Hello everyone. Thank you again for all the help... At this point, my eyes are bleeding on this project.....My code runs and does everything this card memory matching game is supposed to do, except I've tried to no avail to "shuffle" the cards between iterations (i suspect). I have read many posts, tutorials etc. on rand functions, and even had an example from someone(which is not working for me- ALL COMMENTED OUT) and still don't quite get it.... My text offers several random generators, a random(n), which will ostensibly return a "pseudorandom integer >=0 & <= n-1. Then the int rand(), and a void srand(unsigned int?)
Anyway, I'm lost again, thanks for any help on this last leg of my project::::::::::::
#include <iostream>
#include <cstdlib>
using namespace std;
void player_input(int card_value[][4], int &choice1x, int &choice1y, int &choice2x, int &choice2y);
int card_face[4][4];
int card_value[4][4];
int fill_values();
int card_defacer();
int show_grid(int card_value[][4], bool card[][4]);
//int disarray(int card_value[][4]);
//int locum(int card_value[][4]);
char Continue = 1;
int main(){
int choice1x, choice1y, choice2x, choice2y;
fill_values();
player_input(card_value, choice1x, choice1y, choice2x, choice2y);
//card_defacer();
}
int fill_values() //Defining Function establishes 16 cards with paired numbers from 1-8
{
card_value[0][0]=1;
card_value[0][1]=2;
card_value[0][2]=3;
card_value[0][3]=4;
card_value[1][0]=5;
card_value[1][1]=6;
card_value[1][2]=7;
card_value[1][3]=8;
card_value[2][0]=1;
card_value[2][1]=2;
card_value[2][2]=3;
card_value[2][3]=4;
card_value[3][0]=5;
card_value[3][1]=6;
card_value[3][2]=7;
card_value[3][3]=8;
return 0;
}
int show_grid(int card_value[][4], bool card[][4]) // Function that will show the "playing table" and output values of only "pairs" other values will be "*******"
{
cout<<" " << "1 2 3 4 " << endl; //Header for (y) coordinates
cout <<" " <<"----------------------------------"<< endl;
cout <<endl;
for(int x = 0; x < 4; x++)
{
cout <<" "<<x+1<<"|";
for (int y = 0; y < 4; y++){
if (card[x][y] == true)
cout << " "<< card_value[x][y]<< " ";
else
cout << " "<< "*"<< " ";
}
cout << endl;
cout << endl;
}
return 0;
}
void player_input(int card_value[][4], int &choice1x, int &choice1y, int &choice2x, int &choice2y)
{
do{
bool card[4][4];
show_grid(card_value, card);
cout << "Player, enter a coordinate choice for your first card: " << endl;
cin >> choice1x >> choice1y;
cout << "Player, enter your second choice: " << endl;
cin >> choice2x >> choice2y;
choice1x = choice1x - 1;
choice1y = choice1y - 1;
choice2x = choice2x - 1;
choice2y = choice2y - 1;
if (card_value[choice1x][choice1y] == card_value[choice2x][choice2y]){
card[choice1x][choice1y] = true;
card[choice2x][choice2y] = true;
}
else{
card[choice1x][choice1y] = true;
card[choice2x][choice2y] = true;
show_grid(card_value, card);
system("PAUSE");
system("cls");
card[choice1x][choice1y] = false;
card[choice2x][choice2y] = false;
}show_grid(card_value, card);
cout << "Do you want to continue, enter 1 for yes: "<< endl;
cin >> Continue;
}while(Continue == '1');
return;
}
//int locum(int card_value[][4])
//{
// int locumizer2, locumizer3, locumizer4, momentarily;
//int locumizer1 =(rand()%3 + 1, locumizer2 = (rand()%3 + 1, locumizer3 = (rand()%3 + 1, locumizer4 = (rand()%3 + 1, momentarily[4][4];
//momentarily[locumizer1][locumizer2] = momentarily[locumizer2][locumizer1];
//card_value[locumizer1][locumizer2] = card_value[locumizer3][locumizer4];
//card_value[locumizer3][locumizer4] = momentarily[locumizer1][locumizer2];
//return 0;
//}
//int disarray(int card_value[][4])
//{
// locum(card_value);
// locum(card_value);
// locum(card_value);
// locum(card_value);
// locum(card_value);
// locum(card_value);
// locum(card_value);
//return 0;
//}
int random = rand()%3;
{
printf("%s", card_value[][4]);
return;
}