Jump to content
  • Advertisement
Sign in to follow this  
ErUs

random number guessage problems

This topic is 4306 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

here is the problem. I am making a (single digit) random number Guesser, it tries to guess the next number based on the preveous numbers and how many numbers have been entered since the start of the session. random numbers are entered one after the other, like 93659163. (when training) I store all the numbers in a format like this: typedef struct { char thenumber; //number entered int freq; //times this pattern has happened before int history; //count of guesses in the session before this arose char lastno; // the number before this char lastno2; // the number before that above char lastno3; // the number before that above } numentry; I need to devise a scoring system for the most likly next number based on a database of previous examples. at first i thought points = (for each matching param +=5) (+frequency), but a numentry with a high frequency will win even if it is totaly unrelated to the previous numbers. DO you have any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
This is basicly the same thing order n data compressors do. If you're not worried about speed, or you know there won't be a long list of numbers, an idea is:

create an array to hold all the numbers in the order they are added, we'll call it "num_list"

create an array to hold the temporary frequencies of numbers, we'll call it "freq"

when you want to find out the probability of a number, look at the last X numbers in num_list. Find out where those last numbers are seen elsewhere in num_list, when the numbers are found check what number comes after those and increment it in freq.

Sort freq so the number that occurs the most is the one you'll guess is the correct number.

(hope that wasn't too confusing)

edit: you might want to keep the amount of numbers you're searching for small until the list gets bigger, since in a small list it will probably be harder and less accurate to find long patterns that occur once or not at all.

Share this post


Link to post
Share on other sites
HERE is a version that works fairly well for me. After about 200 entries it gets %20 of my random numbers and it get 35-40% when spazzing out on the number keys.
[edit] fixed a silly counting problem :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!