Ryusei GamesClassic games in 3D

Hit and Blow (Bulls and Cows)

Guess the 4-digit number your opponent has chosen, using the number of “hits” and “blows” returned after each guess. Play against the computer, or send a link to play a friend. You can also solve the computer’s number on your own.

Loading…

Rules and how to play

Each of the 2 players sets a secret number made of 4 digits from 0 to 9. The same digit cannot be used twice. Numbers that start with 0 (for example, 0123) are also allowed. Neither player shows their secret number to the other.[1]

Starting with the first player, the players take turns guessing the other player’s 4-digit number. A guess must also be 4 digits with no digit used twice.

When you make a guess, your opponent answers with the number of hits and blows. Of the 4 digits in the guess, a digit that is in the secret number in the same position is a “hit”, and a digit that is in the secret number but in a different position is a “blow”.

The result when the answer is 1234 and the guess is 1325. Digits joined by a solid line are hits, and digits joined by a dotted line are blows.

For example, if your opponent’s number is 1234 and your guess is 1325, the 1 is in the right position, so it is a hit; the 3 and the 2 are in the wrong positions, so they are blows; and the 5 is not in your opponent’s number, so it is not counted. The result is 1 hit, 2 blows. If 3 digits are hits and the remaining digit is also in your opponent’s number, that digit can only go in the one position left, so it is also a hit. For this reason, there is no result of 3 hits, 1 blow.

If you guess your opponent’s number exactly, the result is 4 hits. The player who solves it in fewer guesses wins, and if both players solve it in the same number of guesses, the game is a draw. For this reason, when the first player solves it, the second player still has 1 guess left in the same round, and if the second player also solves it, the game is a draw. On this page, the game is a draw if neither player has solved it after 20 guesses each.[2]

In Solo mode, you solve the number chosen by the computer within 30 guesses.

Controls on this page

Starting a game

Choose a mode with the buttons to the right of the board (below it on narrow screens). Press “Easy”, “Medium”, or “Hard” under “Play vs computer” to start as the first player. Press “Play second · Medium” to let the computer on Medium go first. In “Solo (guess the computer’s number)”, you solve a number chosen by the computer. In “2 players on this device”, 2 people take turns using one device.

Press “Play a friend (send a link)” to create a room and show a link. Send it to your opponent with “Copy link” (or “Share” on devices that support it). When your opponent opens the link and presses “Join”, they become the second player and the game starts. If your opponent does not join, you can switch to a game against the computer with “Play vs computer instead of waiting”. If your opponent stays disconnected for 2 minutes during a game, you can press “New game vs computer (ends this game)”. A room is deleted when no one has been connected to it for 30 minutes, or 24 hours after it was created.

Against the computer, with 2 players on this device, and in Solo, “Play again” starts a new game in the same mode from the beginning. When playing a friend, use “Rematch (swap sides)” to start the next game after a game ends. In every mode, “Change mode” returns you to the mode selection, and “Resign” (“Give up and show the answer” in Solo) ends the game. “Undo move” is available only against the computer and with 2 players on this device, and it can only take you back to setting the secret numbers. Once a guess has been made and its result shown, you cannot go back to before it.

Number entry

When setting your number and when guessing, enter the 4 digits one at a time and press “Submit”. To enter them, use the tiles lined up on the near side of the board (0–9, delete, and submit) or the buttons to the right of the board (below it on narrow screens). Digits entered with the tiles on the board also appear in the field above the buttons. “Delete” removes the last digit you entered. When setting your number, “Random” fills in a random number. While one of these buttons has keyboard focus, you can also use the number keys and Backspace on your keyboard.

With 2 players on this device, the first player sets a secret number, then the second player does. The digits you enter are hidden as ●, and the eye-shaped button switches between showing and hiding them. While one player is setting a number, the other player should not look at the screen. Once both numbers are set, the players take turns entering guesses, starting with the first player.

Reading the board

The left column of the board shows your guesses, and the right column shows your opponent’s guesses (with 2 players on this device, the left is the first player and the right is the second player). Guesses are placed one row at a time starting from the far side, and the board holds up to 8 of them. From guess 9 on, the oldest rows are removed, so check all guesses and results in the “Guesses and results” table below the buttons.

A guess row on the board (when the answer is 1234 and guess 1 was 1325). From the left: the round number, the guessed number, and the result tile.

The tile at the right of each row is the result. The number on the gold left part of the tile is the number of hits (H), and the number on the right part is the number of blows (B). A row that solved the number with 4 hits is framed in gold.

The stand above each column holds the tiles of the number to be solved in that column. Your opponent’s number is face down and is turned over when the game ends. The number you set is placed face up on the stand above your opponent’s column (with 2 players on this device, both numbers are face down). In Solo, there is only 1 column, and the number chosen by the computer lies face down on the stand above it.

Use the “Angled” and “Top-down” buttons at the top right of the board to switch the view. Drag to rotate the board. Zoom in and out with the mouse wheel or with 2 fingers.

Strategy tips

For the first guess, the number of candidates (numbers that could still be the answer) left after each result is the same whichever number you guess. For this reason, no first guess is better or worse than another. Of the 5,040 possible numbers, a result of 0 hits, 1 blow leaves the most candidates, 1,440. A result of 0 hits, 0 blows leaves 360.

If your second guess shares no digits with your first (for example, 4567 after 0123), the totals of hits and blows from the 2 guesses tell you how many of the answer’s digits are in 0–3, 4–7, and 8–9.

The total of hits and blows is the number of digits in the guess that are in the answer. Once you know which digits are in the answer, make guesses that swap their positions to find which position each one goes in.

If you choose each guess from among the candidates, every guess has a chance of being correct. For example, if a first guess of 0123 gets 0 hits, 0 blows, the digits 0–3 are not in the answer, so the candidates are the 360 numbers made from the 6 digits 4–9. The computer on Medium on this page uses this method of choosing at random from the candidates, and it solves the number in about 5.5 guesses on average.

While there are many candidates, guessing a number that is not a candidate can sometimes split the candidates more finely with the next result. Even in the strategy with the lowest average number of guesses, when a first guess of 0123 gets 0 hits, 3 blows, the second guess is 1435, which is not a candidate.[2]

In a 2-player game, when your opponent looks likely to solve it on their next guess, or when you are the second player making your last guess, choose from among the candidates. A number that is not a candidate can never be correct on that guess.

Origin and history of Hit and Blow

The rules of Hit and Blow are the same as those of a paper-and-pencil number guessing game called Bulls and Cows in English. Bulls and Cows has also been known by names such as Cows and Bulls, Hit & Blow, and Cow & Bull. In English, a hit is called a bull and a blow is called a cow. It is often played with 4 digits, but it can also be played with other numbers of digits.[1][6]

Versions played on early computers spread under the name MOO. At the University of Cambridge in the UK, MOO was already popular by the summer of 1970, and a leaderboard ranking the players’ results had been made. That summer, John Larmouth of the University of Cambridge visited the Massachusetts Institute of Technology (MIT) in the US and, with Jerrold Grochow of MIT, wrote a version of MOO that ran on Multics (an operating system used at MIT that let many users share a single computer at the same time). After Larmouth left MIT, Grochow made it available to every Multics user and set up a leaderboard, and within 2 months more than 75 people had played it, with about 1,000 games in total.[3][6]

At Bell Labs in the US, Ken Thompson, who created Unix, worked out procedures for solving MOO, which had come over from the University of Cambridge. According to Dennis Ritchie’s recollection, the results were collected in a large notebook. The first page told you to guess 1234, and depending on the result, you turned to the page with the next guess. The first Unix manual, dated November 1971, also lists moo as “a guessing game imported from England”.[4][5]

How many guesses it takes has been studied with computers. In 1996, Tetsuro Tanaka examined every case and found, among strategies in which each next guess is fixed by the results so far, the one with the lowest average number of guesses. Its average is 5.213 guesses (a total of 26,274 guesses over the 5,040 possible numbers), and with this strategy every number is solved within 7 guesses. The same study also found the fixed strategy that is strongest when 2 players compete. Its average is 5.221 guesses, which is not the lowest, but against the strategy with the lowest average it wins 50.2% of the time (counting a draw as half a win).[1][2]

Sources

  1. Tetsuro Tanaka, “数当てゲームMOOの最小質問戦略と最強戦略” [Minimum-guess and strongest strategies for the number guessing game MOO] (Proceedings of the 3rd Game Programming Workshop, 1996; in Japanese) (opens in a new tab)
  2. Tetsuro Tanaka, “An optimal MOO strategy” (arXiv, 2022; an English translation of the 1996 paper) (opens in a new tab)
  3. Jerrold M. Grochow, “MOO in Multics” (Software—Practice and Experience, vol. 2, 1972) (opens in a new tab)
  4. Dennis Ritchie, “Ken, Unix and Games” (ICGA Journal, vol. 24, no. 2, 2001) (opens in a new tab)
  5. The Unix Heritage Society, “V1/man/man6/moo.6” (the manual of the First Edition of Unix, 1971) (opens in a new tab)
  6. Wikipedia (English), “Bulls and cows” (accessed September 28, 2026) (opens in a new tab)

Frequently asked questions

How are hits and blows counted?

A hit is a digit in your guess that matches the answer in both digit and position, and a blow is a digit that is in the answer but in a different position. If the answer is 1234 and the guess is 1325, the 1 is a hit and the 3 and the 2 are blows, so the result is 1 hit, 2 blows. The 5 isn’t in the answer, so it isn’t counted.

How many guesses does it take on average to solve the number?

Among strategies in which each next guess is fixed by the results, the one with the lowest average takes 5.213 guesses on average and solves every number within 7 guesses (calculated by Tetsuro Tanaka in 1996). The computer on this page solves it in about 5.22 guesses on average on Hard, about 5.5 on Medium, and about 8.8 on Easy.

Can I play by myself?

Yes. Choose “Solo (guess the computer’s number)” to solve the computer’s number within 30 guesses. If you don’t solve it in 30 guesses, the answer is shown. If you press “Give up and show the answer” partway through, the answer is shown on the board.

Can I use a number with a repeated digit, or one that starts with 0?

Numbers that use the same digit twice aren’t allowed. This applies both when setting your number and when guessing. Numbers that start with 0 (for example, 0123) are allowed. The numbers you can use are the 5,040 arrangements of 4 different digits chosen from 0–9.

When I play a friend, can they see my number?

No. When you send a link to play a friend, the game server calculates the results, and your opponent’s screen receives only the game state with your number hidden. The numbers are revealed on both screens when the game ends. With 2 players on this device, the digits you enter are hidden as ● while you set your number. Against the computer, too, the computer guesses from the results alone without seeing your number.

Can I play with 3 or 5 digits?

This page supports 4 digits only. When you play with paper and pencil, you can play with other numbers of digits, such as 3 or 5, under the same rules.

Sending game statistics

Information such as the start and end of each game, whether connections in games with a friend succeeded, and 3D display failures is sent to this site’s servers. It is used to find out which games are played to the end and on which devices display or connection fails, so that bugs can be fixed and the games improved. To stop sending it, turn off the switch below.

What is sent

Game type, mode (vs computer, pass and play on one device, solo, or with a friend), computer level, game settings (the rules for Gomoku and Checkers, and the number of players for Ludo and Chinese Checkers), result, number of moves, game length range, whether connections in games with a friend succeeded and the number of reconnections, 3D display failures and rendering speed range, device type (whether it is a phone, and memory and CPU core ranges), and browser and OS type.

What is never sent

Room IDs, moves and board positions, Hit and Blow numbers, IP addresses, and GPU model names. Data is sent only to this site’s servers and is not passed to outside services. Records are deleted after 30 days.

How the records are handled, and what ads and analytics send to outside companies, is described in the privacy policy.