4digits Puzzle Game Manual

### Introduction

4digits is a guess-the-number puzzle game. It's called Bulls and Cows, and in China people simply call it Guess-the-Number. The game's objective is to guess a four-digit number in 8 times using as less time as possible. It is similar to Mastermind, but the four digits are different to each other. 4digits has a graphical user interface version 4digits and a textual user interface version 4digits-text. This manual documents the GUI version.

### Installation

#### Linux

4digits is distributed in Debian and Ubuntu, so you can install it from APT.

Python is usually already installed in your computer if your are a using a modern Linux distribution. You can install python-gtk2 and python-glade2 from the software repository of your distribution.

#### BSD's and Unix's

Install python, python-gtk2 and python-glade2 for your system.

#### Windows

From version 1.1 on, the CLI version no longer supports Windows, though it runs OK under Cygwin. The GUI version will always support Windows. The reason is that I do not want to spend time writing portable C code for Windows, but rather focusing on POSIX and Linux C programming. Also, people using Windows usually do not enjoy its command line interface.

First install Python version 2.7 or like, then install PyGTK. Click here to download the all-in-one PyGTK installer for Windows.

Extract 4digits tarball. Create a file called 4digits.bat containing the follow line:

> C:\Python27\python.exe 4digits

Substitute with your Python executable file path, and run 4digits.bat each time you want to play this game.

#### Mac OS X

Download PyGTK for OS X here. Now run 4digits, voilà.

#### Use Translations

To use the translations, please install GNU gettext and run the following command:

> make trans

### Playing 4digits

Figure 1 The main window. | When you start 4digits, the main window is like the one shown in Figure 1. You are given eight times to guess a four-digit number. You get one A if its value and position are both correct, and you get one B if only its value is correct. You win the game when you get 4A0B.

In Figure 2, you start with 1234. The answer is 5184, which is known somehow. The first guess is 1234, then you get 1A1B. Why? 1A because '4' in 1234 and 5184 has the same value and position, and 1B because '1' in 1234 and 5184 share the same value but different position. If you enter 3456 then, you get 0A2B, because the values of '4' and '5' are right but there positions are not correct. | Figure 2 You get 1A1B when the answer is 5184.

Figure 3 When you win a game. | A typical game in which the player wins is shown in Figure 3. The answer 7564 is guessed in 96.3 seconds.

If your time is in the top ten you will be shown the top ten scores, and the score you just get is highlighted. You can also view the scores later by choosing menu Game -> Scores. |

Figure 4 When you lose a game. | In Figure 4, the player fails to guess the answer in eight times.

### Hint table

This is an example on how to solve your game with the hint table. The hint table can be toggled from menu View -> Hint Table. All the check boxes of the left column are checked meaning all possibilities, all the check boxes of the right column are unchecked meaning no digit or place is confirmed. That is to say: Left side: - You uncheck a box if you are sure that this number cannot be at this position. - You uncheck a row if you are sure that this number is not in the answer. Right side: - You check a box if you are sure that this number is at this position if it is included at all. - You check a row if you are sure that this number must be in the answer. You can check menu View -> Auto Fill Hints to let the computer help you fill some obvious cases. |

## Step 1

| We don't have any information yet, so we start with a random number. There is not much we can conclude from this, but the information that one number is at the right place will be helpful later.

## Step 2

So let's try some more random numbers, but different ones than in the first try. Now this gives us some real hints. Because there are no correct numbers in the second try we can conclude that the first digit can't be 5, the second can't be 6, ... Add this to the first grid. Then there is another number which we always know something about: zero can't be the first digit (forbidden by game rule). Add this to the first grid. We have tried the numbers 1, 2, 3, 4, 5, 6, 7, 8 but only two of them are in the answer. As we need another two digits and only two are left, we are sure that 0 and 9 must be in the answer. Add this to the second grid. |

## Step 3

| I tried 3456 and the answer was 0A0B. So we can be sure that none of these digits is valid. Remove them from the first grid.

## Step 4

Next I tried 9027 and got 0A4B. So we have found all the valid digits! Mark them in both tables. |

| As in step 2 we can again exclude some places for the valid digits and mark them in the first table. I also tried 9072 which gave me the hint that 2 is not at the last place.

## Step 5

Now we have the situation that both 2 and 7 can only go to places 1 and 2. This implies that no other digit can go to these places. So we can exclude the digit 9 from place 2. |

## Step 6

| Now we use the information we got in step 1. The first result was that there is one digit in the right place. Obviously this can only be the 2. Mark this in both tables. Now 2 can't go to place 1, because it's already at place 2 and no duplicates are allowed. Therefore 7 must go to place 1. Mark this in both tables.

## Step 7

Only two possible solutions left: 7209 and 7290. I choose 7209.....and win! |

### Authors

4digits is written by Yongzhi Pan. Hermann Kraus added the hint table in 2007.

### License

4digits is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

4digits is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with 4digits; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

First update: 21 Mar 2007
Last update: