Last time (self-introduction, so you don't need to read it) 1st 2nd 3rd Final story
Let's first explain the flow of playing against Numeron AI. As I explained last time, I'm a beginner with 1 month of programming experience rather than python ... so there may be some deficiencies. We hope you will see it with warm eyes. Also, since I am a beginner myself, I would like to write it in an easy-to-understand manner for other beginners, so please refrain from redundant explanations.
At this time, the player inputs the 3 digits of the player, and the 3 digits of com are randomly determined.
Calls are made by input. After inputting, the following processing is required.
In other words, the process ends there.
It means that the turn changes with each call. (Hereafter, xEAT and yBITE are referred to as x-y)
The number to be called at this time should be the number that can narrow down the candidates even in the worst result (details will be described later).
Since it is the same process, the explanation is omitted
It will be the flow.
Then, I will explain "the number that can narrow down the most candidates even in the worst result"
What does "the number that can narrow down the most candidates even in the worst result" mean?
When the first call is 012 and 0-1 there are 252 candidates left.
If you call 345 on the second call There are results [2-0], [1-0], [0-2], [0-1], [1-1], [0-0], respectively. 6 ways for 2-0 48 ways for 1-0 18 ways for 0-2 96 ways for 0-1 1-1 is 12 ways 72 ways for 0-0 You can narrow down the number of candidates. In other words, if you call [345] in the second call, you can narrow down to 96 ways even in the worst result. If we call this kind of thing the worst number of candidates The worst candidate for 345 is 96.
If you call 314 on the second call 2-0, 2 ways 30 ways for 1-0 2-0, 2 ways 1-2 is 2 ways 12 ways for 1-1 30 ways for 1-0 80 ways for 0-0 And the worst candidate number is 80.
So if you call 345 and 314 314 has a smaller number of worst candidates ⇒ Excellent call The computer decides to call 314 preferentially. Also, if the worst number of candidates is the same, we will call at random.
Of course, the worst number of candidates is not optimal because we are only considering the situation of one minion. However, there are times when we do something that is not optimal without thinking about such difficult things. That is when there are only "123" and "132" remaining candidates I think most humans call one or the other. Lucky if you hit. Even if you miss it, you can get the next correct answer. However, the above AI may call 453. Because 123, 132 and 453 have the worst number of candidates of 1. Therefore, we will include the following processing
1: The number with the smallest number of worst candidates 2: If there are multiple such things, preferentially call the one that may be 3-0 3: Still random if more than one
I will select the numbers like this. The above is the flow of this program. When you write it in a sentence, you can see the bones of the program and it becomes easier to add meat.
From the next time, I will write the program concretely. I would like to know a lot more, so I would appreciate your guidance and encouragement.
Recommended Posts