"Random" Hot Potato with Queues



Now this is an old proyect I made for my Data Structures class in college like around a year ago-ish.

The goal is to simulate a random game of Hot Potato utilizing queues (in my opinion this would've been better with a circular link list, but whatever). This was coded in C++.

While simple, there was a bit of a problem I had noticed where using random() didn't really produce a random outcome. In fact everytime it was excecuted it generated basically the same results. This is because the random function is actually pseudo-random. To overcome this hurdle, I found that using the timer() function from the ctime library (this will give you the actual time),  in conjuction with random() reduced the likelyness of repeat  patterns (I say this so I don't claim it's completely random)

I might have gone overboard with creating a seperate time and subtracting it with the current time, which in hindsite wasn't necessary. (The important thing is that I know that now!)

The code's output is in Spanish, but don't worry as the code's comments are written in English and Spanish and it's pretty easy to understand.


Heres a link to the code if your intereseted:
Hot Potato Queues

Just don't plagiarize it, that's no bueno.

Comments

Popular posts from this blog

JavaFX Snake Game (WIP)

Software Engineering: Documents

Where have I been?