#### How Does Hacking Work In Alias for PS2?

As you can see from the image above, in addition to the 'RESET' and 'QUIT' buttons, the main input comes from the L and R buttons which place the letters A, B, C, and D into the entry line. After the specific number of letters have been entered, the computer will tell me how many characters are in the right position. (The number of characters required to be entered depends on the in-game terminal; this terminal, the one I will explain is like most terminals and requires three characters, a few require two characters, and one requires four) This process is similar to the Mastermind game, where players place colored pegs into four slots on a board and the only feedback is how many are in the right position as well as how many exist somewhere else in the solution. The puzzle in Alias differs because I cannot place a letter onto the entry line twice; I cannot place two As. The puzzle also differs because I don't receive feedback if a letter appears elsewhere in the solution.

#### How To Get A Solution

A quick recap of what we know about the Alias hacking puzzle:
• There are only four letters: A, B, C, and D.
• A letter cannot be placed into the entry line twice.
• Once the entry line is full, the computer will tell us the number of letters in the right location.
• We will explore three-letter terminals, but there are two-letter and four-letter terminals in the game.
In the case of three-letter terminals, since I cannot repeat any letters, I know that there are only 24 possible solutions:
 ABC ABD ACB ACD ADB ADC BAC BAD BCA BCD BDA BDC CAB CAD CBA CBD CDA CDB DAB DAC DBA DBC DCA DCB
Each solution has roughly an equivalent chance of appearing (probably not exact because computers don't like 3s, but as far as I've been able to tell, the probability has been about the same for each answer; generally, it's not the password that would make it easy for me), so any of the above 24 options would be a decent guess. For simplicity's sake, I start with ABC because it's in alphabetical order.
Now, there is, of course, only a 1/24 chance of ABC being correct. More than likely, the correct answer is one of the other 23. Fortunately, the remote modem will indicate how many letters are in the correct position

If ABC is not correct, the number of letters (as returned by the terminal) can be either '0 correct', '1 correct', or '2 correct'. The number correct will help me eliminate certain possibilities, as indicated below.
 2 correct, possible answers: (3/23 entries) ABD ADC DBC 1 correct, possible answers: (9/23 entries) ACB ACD ADB BAC BDC CBA CBD DAC DBA 0 correct, possible answers: (11/23 entries) BAD BCA BCD BDA CAB CAD CDA CDB DAB DCA DCB
Notice the case where 2 are correct. In this case, the solution is either ABD, ADC, or DBC, and I can pick either one with a 1/3 chance of it being correct. However, if I don't pick the correct one, I will always get a result of '1 correct' (if DBC is the correct answer, ABD has '1 correct' with the B and ADC has '1 correct' with the C; the same applies to the other choices if either ABD or ADC is the right answer). So, in this case, I can pick at random among the three until I get the correct answer.

If I get a result of 1, then I can pick from either of the 9 entries with a 1/9 chance of it being correct. If I pick the wrong combination, the number correct will depend on the result that I pick: Selecting DBA and getting '2 correct' (keep in mind that we know that the correct answer is one of the blue entries because we've already tried ABC) means that the correct answer is CBA (you can check the other blue entries and verify that there is only one with two entries that match DBA). Selecting BAC and getting '2 correct' means that the correct answer is either BDC or DAC.
Furthermore, selecting BAC will never produce a result of '1 correct', but selecting DBA has two possibilites for '1 correct'. The nine possibilities fall into one of these two categories: ACB, BAC, and CBA (two '2 correct' entries with no '1 correct entries'); ACD, ADB, BDC, CBD, DAC, and DBA (one '2 correct' entry and two '1 correct' entries).
Which one am I interested in? Since I want to solve the puzzle as quickly as possible, I am interested in the one with the most balanced sets of entries (the latter list of six). The distribution of resultant entries are equivalent, so I can pick either one. ACD is the first in the list, so I will pick this one.

The top result, '2 correct', after ACD (if ACD is not the correct answer) is ACB. If '1 correct' then, the result is either ADB or CBD. If I had to pick one and it is wrong, then I simply pick the other one (for clarity's sake, the result will be '0 correct' if I pick the wrong one). The decision branches further with the five remaining entries:
 0 correct, possible answers: (5 entries) BAC BDC CBA DAC DBA
To note: there are still no '1 correct' answers after selecting BAC at this point either; there are two '2 correct' results and two '0 correct' results (the same applies to CBA). Among the other, more successful entries, we have BDC and DBA which produce one '2 correct' entry and one '1 correct' entry (DAC in both cases). DAC is similar but has one '0 correct' entry instead of one '1 correct' entry. Either BDC, DAC, or DAC is preferable to BAC and CBA since their entry lists are similar in size. I will pick BDC because it's first in alphabetical order. The result '2 correct' indicates that BAC is the correct answer, the result '1 correct' is DAC, and '0 correct' is either CBA or DBA; if the wrong one is picked, pick the other one.

Now, to work on the initial '0 correct' entries from ABC.
 0 correct, possible answers: (11/23 entries) BAD BCA BCD BDA CAB CAD CDA CDB DAB DCA DCB
Out of these 11 entries, two of them (BCA and CAB) produce three '2 correct' entries in addition to three '1 correct' entries; the other only produce two '2 correct' and either three or four '1 correct' entries. Since I'm interested in keeping the number of entries similar on each guess, I will pick BCA. I wanted to pick CAD because it produces two readable '2 correct' entries, 'BAD CAB'.

 2 correct, possible answers: (3/10 entries) BCD BDA DCA 1 correct, possible answers: (3/10 entries) BAD CDA DCB 0 correct, possible answers: (4/10 entries) CAB CAD CDB DAB

Of course, the possibilities for '2 correct' are the same as that of the initial guess ABC (with all options being related to each other by '1 correct', I just pick until I get the correct answer), so I've already filled them into the table. The entries for '1 correct', however, are also related to each other only by '0 correct', so I will also have to pick them similar to how I pick from the results of '2 correct' entries. The only part that requires effort is the four '0 correct' entries: CAB, CAD, CDB, and DAB. A cursory look at the four entry possibilities shows that there are no possible '0 correct' entries at this point; each entry has at least one letter in common with the other three. CAB produces '2 correct' entries with all of the other entries, so it would not speed up the decision making process greatly. The other three entries match each other as a '1 correct' entry, so either one will be a suitable starting point (and I will start with CAD). Note that a '2 correct' entry indicates that CAB is the right answer; otherwise, I will then try either CDB or DAB until I get the right answer. This will allow me to fill out the flow chart.

All of the possible combinations of four letters in three slots appear somewhere in this flowchart, and from each, you can trace how I would have figured out this as the correct answer. For instance, if the correct answer is BAD, starting with ABC would give me the result of '0 correct'. I would then move to BCA and get '1 correct'; I would try BAD, CDA, or DCB until I get the correct answer.
I previously had a less optimized solution to this puzzle with ACB in place of ACD; this was a worse solution because ACB produces no '1 correct' entries and requires me to guess if I get '2 correct', but moreso because there were six possibilities if ACB returns '0 correct' and here there are only five. This gives me an expected number of guesses for the solution at 3.5 moves (it was 3.58).
Update: August 30, 2014

On a whim, while waiting for a class to start, I took a closer look at the branch of '0 correct' at ABC and decided that there may be, by some longshot, a way to get the right answer with only four layers, so I decided to try changing the result from BCA to CAD (if you recall, CAD has two '2 correct' and four of both '1 correct' and '0 correct') in hopes that I can get one entry on each sub-entry's possible outcomes. The results are as follows:
 2 correct, possible answers: (2/10 entries) BAD CAB 1 correct, possible answers: (4/10 entries) BCD CDA CDB DAB 0 correct, possible answers: (4/10 entries) BCA BDA DCA DCB

There's no optimization possible for any '2 correct' entries, as it has been for the entirety of this flowchart, but I need to pick an entry in both '1 correct' and '0 correct' that has one possible outcome for each result. I drew the results for each entry and found that the following results work well: CDB for '1 correct' and BDA for '0 correct'. The chart now looks like this:

This new chart now gives an expected number of guesses at 3.375, which means that this chart is a great improvement over the previous chart (as you can tell, because there is now only one path left that requires five guesses). I don't see any method for improving the '1 correct' from ABC path, because all of the results produce 5-7 entries for '0 correct', which is *just* large enough to prevent me from having any possibility of making the clump of four like I just did.