This guide is copy and pasted from other threads.
The gambling guard "game" is a version of a game called "bulls and cows" or "master mind".
There are several solver programs available on the internet, but we can not have outside links in our forums.
So I suggest you search on your own.
An explanation of how the game works with out using a solver program:
The Gambler Guard's Galmble
When you go to jail, you have 3 options (ways to get out),
1) Sit and wait out your time: (Jail time must be spent online, it will not decrease if logged out of the game) (Just leave the computer on while you sleep, or go watch tv.)
2) try to kill rats for a tooth so you can escape, only to have to avoid bats in the tunnel, (you will still have notoriety and be wanted by the guards)
3) you can do the bet with the gambler guard located at the bottom of the stairs near the rats.
My guess as to what this rat infested room is I don't want to say. Asking the jailer the rules to the game, he responds with a "cryptyc" way of saying:
'Arrrr.. I be thinkin of 4 numbers mate, and each number is not used twice. None of the 4 numbers im thinkin will be 0. I will give you 6 chances at guessing these numbers with these (9999) chips.
If you get any numbers right and in the right spots, i will score you an "A". if you get any numbers right but in the wrong spot , I will score you a "B".
how to solve:
you need pad of paper, pen or pencil... i use crayon.
first we are going to guess with 9876 chips in our inventory. Using "split" on your inventory screen lower left, split off 123 chips of the 9999 you have and drop them on the ground leaving 9876 chips in your inventory.
write 9876 and talk to the jailer choosing "guess"
the jailer will now tell you how you scored lets say he says 0A 2B
This means we got 2 numbers right but in the wrong positions, it also indicates numbers that are not ones he is thinkin about.
write 0A 2B next to 9876 on your pad, close the screen, and pick up the 123 chips on the ground. you should have your 9999 chips again.
We now in this case choos 2 of the numbers to keep and 2 to replace for the next guess, its a little early to deduce anything yet, so I will choose 9854, 9999-9854=145 so i split off 145 chips to the ground and guess with 9854 chips.
0A2B he responds.
keep writing the numbers your trying and his responce, this way you will be able to deduce the correct numbers and their order.
9876 0A 2B
9854 0A 2B
at this point lets examine what we have, you have lots of time.
98 are used in both and in the same potions, if 76 and 54 were all numbers not used in the gamblers number then 7654 would score 0A 0B but if 98 were not used, 7654 would be the 4 numbers, and also as xx76 scored 0A 2B lets reverse their order same for the 54 so lets try 6745
in this case the gambler scores us 1A 1B
still not a lot to go on 2 out of the 4 numbers but now one is in the correct position, but because this combo of 6745 had 2 numbers it reveals the following:
with 9876 and 9854 having 0A 2B scores AND 6745 having 0A 2B as a score, that 6 or 7 is one of the numbers 4 or 5 is one of the numbers and 9 or 8 is one of the numbers and the forth number has not been revealed yet.
I will chose 6, 4, 9, and for my forth number one that hasn't been used yet 3
9999-6493=3506 i split off 3506 chips from the 9999 leaving 6493 chips for the guess
he scores my guess as 2A 0B
writing this down and retrieving my chips to 9999
9876 0A 2B
9854 0A 2B
6745 1A 1B
6493 2A 0B
i will now test my chart by writing squares around what numbers i think are in right position for and go up the chart examining if the scores match, in this case I'm going to assume 9 is not a number and that 64 are the 2 numbers indicated, and in analyzing the scores based on this theory that 6 and 4 are correct then 8 is a number and 2 or 1 is the other number.
based on this I form 6482 as my next guess (and second to last i might add)
1A 0B he states, to my dismay, now tho we must have enough data to define the actual number correctly
9876 0A 2B
9854 0A 2B
6745 1A 1B
6493 2A 0B
6482 1A 0B
the 6 is for sure one of the numbers as well as the 9. The 4 8 or 2 wasn't and because of our earlier discovery with the 4 or 5 bit this means 5 is one of the numbers. the forth and still un revealed number is the only number left un checked being 1.
in the chart we can see that 6 and 9 are in the correct positions in row 4
also that 5 is in wrong position in row 2 and 3
there for the number the jailer is thinking of is going to be:
4A 0B Correct! he will now say.
Dump the chips, ttyl the guy killing the rats, go to where the others are sitting their terms, exit via cell, but if your sentence is a long time, you may have to go bet that gambler guard again. once on other side talk to the guard in red to get out. You will now no doubt be offshore, dont venture back into the city, and if you do get that pad out you'll be needing it again.
Or you can use a solver program. Make sure the program is for a 4 number combination. I found some programs out there made for 8, 9 and 10 number combinations.
Here is how one player described how to use a (unnamed) program.
Go to the gambler guard and ask for 9999 chips, than hit "bet" and it will ask you to bet 1 day of imprisonment.
Now the program starts with 0123 so that means click the separate button and select your 9999 chips and remove 123 of them.
Now you have 9876. Go to the gambler guard and it will give u like A0 B2 or something whatever it says go to the solver program and type it in.
In one program you type in 0 2 (with a space between) than hit return it will automatically give u a new number.
Pick up the 123 chips again so your back at 9999 than whatever the number the BK program tells you subtract it from the 9999 and hit guess again.
The gambler guard will say like A1 B2 or something. Type in the 1 2 into the solver and it will tell you a new number.
Pick up the chips you threw down so your back at 9999 than remove the amount the solver tells you to.
Always have 9999 chips before you remove more.
Best of luck either way you choose to solve the puzzle.