Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Gaming > Development Programming Algorithms > Re: cows and bu...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 4 Topic 614 of 675
Post > Topic >>

Re: cows and bulls

by "Geoffrey Summerhayes" <sumrnot@[EMAIL PROTECTED] > Feb 14, 2007 at 12:47 PM

On Feb 13, 10:43 pm, "ramu" <ramu....@[EMAIL PROTECTED]
> wrote:
> Hi,
>  can anyone give me the algorithm for cows and bulls game which takes
> minimum number of passes to guess a 4-digit number?
>

This isn't optimal but does almost as well.

Each turn:

Get the list of all possibles remaining.
clear container for candidate move
For x from list.start to list.finish
  zero out score counts
  For y from list.start to list.finish
    calculate score for list[x] if answer is list[y]
    count[score]++;
  end for
  if the max in count is less than the current candidate's
    set x as the new candidate
  end if
end for
return candidate

Basically it looks for a guess that will minimize
the number of remaining possibles whatever the
results of the guess are.

The optimal strategy sometimes makes a guess that
can not be a solution and sometimes leaves larger
than minimum possibles behind. Classic paper on
the subject was by Knuth on mastermind.

---
Geoff
 




 4 Posts in Topic:
cows and bulls
"ramu" <ramu  2007-02-13 19:43:10 
Re: cows and bulls
"Jimmy" <one  2007-02-14 02:15:25 
Re: cows and bulls
"Jimmy" <one  2007-02-14 02:18:47 
Re: cows and bulls
"Geoffrey Summerhaye  2007-02-14 12:47:18 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 9 4:36:04 CDT 2008.