see thats what I thought. But then I did this in the public function bet_or_pass() in the class Player before I posted:
high_bidder = this;
and got this compile error:
game.cpp: In member...
Type: Posts; User: pjharris
see thats what I thought. But then I did this in the public function bet_or_pass() in the class Player before I posted:
high_bidder = this;
and got this compile error:
game.cpp: In member...
This is a call I have to a function in a class. Where player[0] is an instance of that class and bet_or_pass() is a public function in that class.
players[0].bet_or_pass();
So how would I set...
I tried something exactly like that example that Salem had me try and it worked fine.
Yeah but thats what I did I the code that I posted and it doesnt work.
Thats what the sleep does. Sleep 2 says wait two seconds then run it again And it's not the case about timing, because I ran it 10, 30, 60 mins after and I still got the same. I've been getting...
#include <iostream>
#include <algorithm> //random_shuffle()
#include <ctime> //time()
#include <cstdlib> //srand()
using namespace std;
int main() {
srand(time(0));
int arr[] =...
Salem your example works fine for me. It must be random_shuffle() then.
I don't know whats going on, I'm sure the example works as it's suppose to. time() is working fine. I even tried it on another machine. It seems to me that srand() is not working seeing as I get...
How would you like me to do that? Copy and paste? But then you could just say I copied it twice.
Salem:
I will investigate it to see if thats the case.
Don't try and insult me by saying I can't read. Granted I didn't type it correctly in my previous post, but in the code its right. I copied it straight from what he put.
well with the way he uses srand(0) what part of time is being used?. And the way I did it was:
$./a.out
$./a.out
and I did that 10 times and it was the same set of numbers. And I just did it...
That is all good and dandy. But I just ran your example and I got the same set of numbers each time a ran it, which was like 10 times. So, that basically convinced me not to use it unless someone...
This is true laserlight. I have learn the valuable lesson of keeping things in the smallest scope possible and when I do loops make sure I reset things that need to be reset.
Yeah I think I'll give it a try but I am still undecided about which I want to use. I might use random_shuffle, but it's so hard to just throw away that code I worked on for hours.
Yeah I was thinking about going with random_shuffle when I found out about it, even tried to use it as you saw in my code(all the other code was commented out when I tried), but that seemed harder...
I do allow for the variance in my code. Look at my explination of what I wanted it to do when i first posted. Then look at the code. I use rand() to get a number between 1-4, then use that number...
How would a dynamic array or vector be better for what I am doing? I guess because it isn't legal in C++ and I am using g++ as my compiler. So, I guess I don't understand the reason given. So,...
I get it. But like I said with the shuffle that I saw, and for the type of game that I am making it for(not poker or blackjack or any other casino card game game) the shuffle seemed a little off. I...
Thank you Daved, my shuffle works now. It was all about the indices to my arrays and resetting j in the loop. Your help is much appreciated.
Simmer down there buddy. I was wrong. It does shuffle. I just didn't see it because of the way it was written with everything on three lines.
I dont want to have to deal with getting duplicate cards in the deck. And I am trying to get a more realistic type of shuffle, seeing as I have seen some programs deal really weird when it comes to...
The random_shuffle was an attempt to do the shuffling a different way. But that didn't work because the array I pass isnt of type RandomAccessIterator or something. So just disregard that.
The...
What I want to do is shuffle the cards like a person does. Split the deck roughly in half, then shuffle the two halves together from the bottom up by alternating between the havles and placing 1-4...