• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Anyone know an algorithm for the game of stones?

bigshooter

Platinum Member
I'm trying to come up with an algorithm to code for one of my classes. It is used to play a game of stones, wehre you start out with a number of stones between 1001 and 10001. There are two players. The first player takes between 1 and n (3<=n<=9 randomly generated at the beginning of each game) stones. The second player then does the same thing. This goes on until all the stones are taken, and the person with an odd number of stones wins.

I know there are modules in perl that play the game for you, and I have written one that just takes a random number between 1 and n stones based on how many are left. I need a better one though. Any math wizzes in here? I'm going to work on it saturday, but I'm not always the greatest at coming up with algorithms for things like this. There must be a forumula in there somewhere, but I don't see it right now. Thanks.

 
Back
Top