Stimulated Variation of the Card Game “War”

Stimulated Variation of the Card Game “War”
I need to create a simulation of the card game "war" except in this game it is called trump. The rules are:
1) two players (the computer will be playing against itself. The user just watches the game)
2) each player starts with an array of 100 slots, partially filled with 50 random numbers from 0 to 9.
3) Each player is assigned a trump number from 1 to 9. (This is how far I’ve gotten so far)

4) For every turn randomly compare one value in player 1's array to one value in player 2's.
5) For every turn the higher value wins and the player claims the losing value from the losing player's array
6) if on any turn the random value is trump the player automatically wins.
7) In the event of a tie or both players' values are trump, a playoff occurs where a second set of random values are compared and so on. But in this scenario rather than the winner claiming the other players' value the winner gains a new trump value added to their array
8) the ultimate winner is the player with more elements in their array after 250 head to head comparisons.
9) No global variables

the stimulation of trump has 250 comparisons. Post every value pulled from array to the screen as if it were a battle. Use time wasting loop to delay time between flips.

After the stimulation print each array to the screen and determine a winner

any help would be appreciated with this program.
It’s my first year in a computer programming class using c++.
I would prefer for the program to be as simple as possible.
im using microsoft visual c++ 2010 express.

What exactly do you want help with? We aren't going to write the code for you.
What exactly do you want help with? We aren't going to write the code for you.


I agree with Zhuge. I have better things to do with my time. Not many. But some.

However much I dislike doing people's work, I will help a little. Just create a loop for your main application, and (if possible) don't use arrays. If you know about, or can quickly learn about template classes, try using vectors and/or deques, they'd probably help a lot (especially deques), much more than arrays would.

If you're frustrated, just go on google. Someone's probably done almost the same thing, and you might be able to reuse their code.

If I feel like doing some work, I'll post my code on here whenever.
Last edited on
Well the best advice you can get when you're starting out. Write it down on paper, step by step, what would you do if you had to implement this.

Some things you may want to look into:
vectors
references

if you don't already know them:
classes

if you can use platform specific code:
Sleep()

I need help with how to compare player 1 and player 2s numbers. so far i have:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
using namespace std;

int main ()
{
int i;
srand (time(NULL));

cout<<"Welcome to Trump!"<<endl;

int player1[100];
int player2[100];


for (int x=0; x<50; x++)
{
player1[x]=rand() %9+1;
}
// i want to compare the value ^ here with the value \/
for (int y=0; y<50; y++)
{
player2[y]=rand() %9+1;
}


//Time Wasting Loop
for (i=0; i<=1500500; i++)
{
cout<<"";
}


int trump1=rand() %9+1;
int trump2=rand() %9+1;
cout<<"Player number 1's trump is "<<trump1<<"."<<endl;
cout<<"Player number 2's trump is "<<trump2<<"."<<endl;

cin>>i;
return 0;
}
i have no idea what vectors and/or deques. our instructor told us that we will be building on more functions and arrays and then some of our own programs. i don't think we will be getting to vectors or deques.

i believe i am familiar with references. Aren't they like this:
char variable [10];
variable [1]=1;
variable [2]=2; etc. ?

if that is correct how would i incorporate that into the program?
Last edited on
Topic archived. No new replies allowed.