Hints and Discussion

One of the differences for this version of the hangman game is that we have chosen a fairly small dictionary of words from the world of Computing compared to the Oxford English dictionary and we have listed this Dictionary for you to use. We shall be adding Computing words and their meanings to it as we go.

First, we are looking for a stragegy for playing hangman as a human being, and to find ways to express this as an algorithm.(see Human Solutions, Hints below).

Then, perhaps, we may look to see if the computer can help us in different ways to play more effectively.

Our final goal is to devise algorithms in which the computer plays the game! We may be able to build a program in which the computer is more successful than humans at playing hangman. We are taking a meaningful look here at Artificial Intelligence. In all these tasks there are plenty of different solutions.

We can test how well we are playing the game as a human by using the Test Hangman program over 5 games.

We might then improve our rating in the Test Hangman program by playing Hangman using some computer tools that are available: 'Scanner' and 'Reduce Dictionary' buttons. See Hints 6,7 below.

The challenge that we are making is:

  1. to find a good human solution for a strategy to play the game
  2. perhaps to enlist the help of the computer in our algorithm
  3. test out our expertise at playing hangman
  4. use our human strategy to guide us (or not) in developing an algorithm to build a program so that the Computer can play the game to guess the word with a human choosing a word from the Computing dictionary. We then try to find ways to improve the computer's performance by making it more 'intelligent'.

1. Human Solutions

There are different ways to approach this problem. You can create your own solution. The hints below are offered as aids on your journey.

Hint 1: Number of letters in the random word

At the start of the game the computer, which hosts the game, chooses a word randomly from the Computing dictionary, which is a small dictionary compared to the English dictionary and you are able to scan through it in minutes should you wish. The computer then prints a set of underlines in a template, which tells us how many letters are in the word, say it is 7. So when we go looking through the dictionary we only have to consider the words with 7 letters. We will come back to this later...

Hint 2: Guessing a letter

Remember only 5 incorrect guesses and you are out on the sixth wrong guess. A correct guess and the letter is entered in the template (the random word pattern) as many times as it occurs in the word. Which letter(s) do we start with? Why would we consider the vowels


And why y? And in what order? ('insubordinately' has all 6.) It is rare in English to have 4 or more consecutive consonants in a word. Would that figure in your strategy?

Hint 3: Letter frequency in the Oxford dictionary

The eight most frequently occurring letters in the English Oxford dictionary in order are:

e a r i o t n s

Would you make use of this information in your strategy?

Hint 4: Pattern matching

When we have guessed a number of the letters in the word (but not exceeded 5 incorrect guesses) and our template looks like


say, we look at the combination of letters and underlines and rack our brains to see if we know words that would fit the word template/pattern, or letter combinations that would fit and go together in the word. For example, if the word ended


and we had already guessed e and a, what letter would you guess to go in between i and n? If you get to 4 or 5 guesses down and you have racked your brains and can't see a pattern and you don't recognise a potential word, what do you do? Hazard another guess? Or use the 'Scanner' button!

Hint 5: Scrolling through the Computing dictionary

Because our dictionary is relatively small we could compare our template against each word in the dictionary to see if we could find a word that matches. On the hangman page, when we scroll down we have enlisted the help of the computer by arranging for our template to scroll down with us to make the comparison easier. In our example, we would be looking for the 7 letter words in the dictionary, which fitted the template. But we can do more:

2. Human and Computer-aided Solutions

Hint 6: Using the Scanner

Press the 'Scannner' button to enlist the help of the computer to transform the dictionary words into a format similar to the template. Scroll down the page when you want to find a match of your incomplete template with a word in the Computing dictionary. What do you do now, when you find a match?

Hint 7: Reducing the size of the Computing Dictionary

(a) Press the 'Reduce dictionary' button to get the computer to remove all the words that are not the same length as the random word you are trying to guess to form a current dictionary of words of the right length. Then you can scroll down and compare your template against a much smaller list of dictionary words of the right length. Again what's your next move when you find a match? There may be more matches... (b) when your guess of a letter is wrong: Reduce the dictionary by removing all the words in the current dictionary, which include that letter (c) when you guess of a letter is right: Reduce the dictionary by removing all words from the current dictionary that do not have that letter, and if there is more than one occurrence of that letter in the word, remove all words from the current dictionary that do not have that letter in all the positions it occupies in the word.

Hint 8: How do you measure the success of your computer aided strategy/algorithm?

Not being hanged? Yes, but we think you can do better than that. As it stands, with the help of the scanner and dictionary reducer buttons you should be seeking a solution with the least number of incorrect guesses. We guess that if your strategy is good enough you should be able to guess any word with no more than 3/4 incorrect guesses. Let us know if you have a human computer-aided strategy/algorithm that you think does better.

1. Computer Solutions

Hint 9: Your algorithm

Make your human computer-aided algorithm explicit in pseudocode or a flow diagram.

Hint 10: Artificial Intelligence: The Computer starts to learn how to play Hangman

See if you can use your your own 'human' algorithm, together with how the computer helped you, as a basis for developing an algorithm which describes how the computer might play the game. There are many solutions to this problem. Can you make one happen in Python 3?

Hint 11: Here is a bare bones possible starting Algorithm for the Computer to play Hangman.

This algorithm incorporates the idea of the scanner. When we get to pattern matching, it is the computer that has to recognise the pattern match between the incomplete word template and a word in the dictionary, not your eyes and brain. How does it do it? Can you program it? Remember the Computer here sees a word as a linear pattern: as an ordered string of characters and that is how, in this instance, we will program it. The computer's name in our version is 'Ruby'.

  1. Ruby asks the user to pick a word from the Computing dictionary on the hangman page and to enter the number of letters in the chosen word. Ruby then displays on screen the word template/pattern with underlines, a record of the number of incorrect guesses she has made, (none to start with), and a record display of the letters she has used in her guesses. (We don't need to include drawings at the barebones stage).
  2. While the number of incorrect guesses is less than 6 and the template is not an exact word in the dictionary:
    do loop:
    • Ruby guesses a letter taken from her computer frequency list after taking stock of the current position and asks the user to verify Ruby's guess with a yes/no response; to give the position(s) of the letter in the word if the guess is correct;
      Ruby adds the letter to the displayed list of letters she has used and updates the template if the guess is correct;
      if the template is full (and therefore equal to a word in the dictionary), Ruby exits the while loop;
      If the guess was incorrect, Ruby increments the count of incorrect guesses;
      adds the letter to the record of letters used;
      if the count of incorrect guesses is 6, Ruby exits the while loop;
      Otherwise, Ruby continues in the loop, guessing the next letter...
  3. If the template is full, Ruby checks that the full template is indeed a word in the dictionary and declares success! -- Game over.
  4. If incorrect guesses is 6, Ruby asks the user to type in the solution, checks that it is in the dictionary, before acknowledging she has failed!
  5. Ruby offers to play another game/or to check out.
We can develop this algorithm to make the computer act more intelligently and therefore more successfully We will have an 'intelligent' computer, Ruby, playing the game available on site in the near future. We will see what rating Ruby is able to achieve with our Hangman test program. Watch this space.
Words in Computing
Random Word Description and Meaning
heuristic (2) heuristic (technique), (Ancient Greek: find or discover, often called simply a heuristic, is any approach to problem solving, learning, or discovery that employs a practical method, not guaranteed to be perfect, but instead sufficient for reaching an immediate goal. Examples that employ heuristics include using a rule of thumb, an educated guess, an intuitive judgment, a guesstimate, or common sense.See more here in Wikipedia
algorithm In mathematics and computer science, an algorithm is an unambiguous specification of a design or how to solve a problem. Algorithms can perform calculations, data processing and automated reasoning tasks. and in 'computational thinking' and programming See more here in ispython.com
template something that establishes or serves as a pattern
pseudo-code is an informal high-level description in common English of an algorithm computer program. It uses the structural conventions of a normal programming language, but is intended for human reading rather than machine reading.More here in Wikipedia
artificial (intelligence)(AI), sometimes called machine intelligence, is intelligence demonstrated by machines, in contrast to the natural intelligence displayed by humans and other animals. In computer science AI research is defined as the study of 'intelligent agents': any device that perceives its environment and takes actions that maximize its chance of successfully achieving its goals. Colloquially, the term 'artificial intelligence' is applied when a machine mimics 'cognitive' functions that humans associate with other human minds, such as 'learning' and 'problem solving'.
flow-chart a diagram of an algorithm with arrows, like pseudocode but with drawings, which shows visually how something will work
ethics deciding what is morally right and wrong in computing -- and in life
media mobiles, ipads, laptops, television, newspapers, facebook, instagram...
privacy keeping yourself and your personal information data safe when off and online
teamwork working together cooperatively, pulling together, turning a group into a team
pairs working in pairs to learn and practice programming is a practical way to get through that initial slog of learning to work on problem solving and programming
perseverance sticking at it, hanging in there; important for programming -- and for living
resilience bouncing back, (from failure), important for programming especially when dealing with mistakes in programming -- and for living
Google when your stuck with an error in programming, throw it to Google. Information needed Google it.
resource in computing try Computing at School website
sequence one of the 5 control structures in programming, which illustrates the importance of the order in which a set of operations is performed
repetition one of the 5 control structures in programming, an essential tool variously described as looping where a sequence of operations in a program needs to be repeated
function one of the 5 control structures in programming, where a useful set of operations is given a name, which is used to call the set of operations into action, wherever it is required. Returns a value.
selection one of the 5 control structures in programming, which helps to implement choices and decisions in a program, usually involving if statements
procedure like a function, that can be used again and again but doesn't return a value.
communication one of the 5 control structures in programming, where a program requires to exchange information with the outside world, sometimes called input/output (I/O)
integer a data type in programming languages, representing a whole number positive or negative
floating or floating point number, a type of number, with a decimal point
boolean a simple data type having just two possible values: true and false
field name for a single element of data in a record in a file
syntax refers to the spelling and grammar of a programming language. Computers are inflexible machines that understand what you type only if you type it in the exact form that the computer expects. The expected form is called the syntax.
binary numbers expressed in the base of two, using 0 and 1 only;
ternary numbers expressed in the base of three, instead of 10, using 0, 1 and 2 only;
octal numbers expressed in the base of eight, instead of 10, using 0, 1, 2,3 4, 5, 6 and 7 only;
decimal numbers expressed in the base of 10, using 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9 only;
hexadecimal numbers expressed in the base of sixteen, instead of 10, using 0, 1, 2,3 4, 5, 6, 7, 8, 9, a, b, c, d, e ond f
debug find and eliminate errors in a computer program whether they are syntax errors like spelling mistakes in the writing of the program, or logical errors of faulty thinking discovered during run-time.
source (code) a program written in a high-level language before being compiled
equation in mathematics, a statement that the values of two mathematical expressions, the left hand side and the right hand side are equal; equation is a word with all the vowels.
rhythm (from Greek ῥυθμός, rhythmos, 'any regular recurring motion, symmetry' generally means a 'movement marked by the regulated succession of strong and weak elements, or of opposite or different conditions. It's also a 6 letter word without a vowel!
matching patterns, in computer science, pattern matching is the act of checking a given sequence of tokens for the presence of the constituents of some pattern
symmetry (from Greek συμμετρία: symmetria) in nature, science, mathematics, agreement in dimensions, due proportion, arrangement. In everyday language refers to a sense of harmonious and beautiful proportion and balance.
cipher tb
byte a group of binary digits or bits (usually eight) operated on as a unit: computer data A byte is considered as a unit of computer memory size.
kilobyte (KB), 1KB is 1,024 bytes of information.
megabyte (MB), 1MB is 1,024 kilobytes of information. See here
gigabyte (GB), 1GB is 1,024 megabytes of information.
terabyte (TB), 1TB is 1,024 gigabytes of information.
petabyte (PB), 1PB is 1,024 terabytes of information.
deductive Deductive reasoning, also deductive logic, logical deduction is the process of reasoning from one or more statements (premises) to reach a logically certain conclusion.See more here in Wikipedia
inductive inductive reasoning is a method of reasoning in which the premises are viewed as supplying some evidence for the truth of the conclusion (in contrast to deductive reasoning and abductive reasoning). While the conclusion of a deductive argument is certain, the truth of the conclusion of an inductive argument may be probable, based upon the evidence given. See more here in Wikipedia
logistics is generally the detailed organization and implementation of a complex operation. In a general business sense, logistics is the management of the flow of things between the point of origin and the point of consumption in order to meet requirements of customers or corporations. See more here in Wikipedia
algorithmic (thinking); in the context of computational thinking, is trying to organise a design or solution to a problem as an ordered set of rules or processes to be followed, particularly by a computer See more here in ispython.com
decomposition in the context of 'computational thinking', describes the process of breaking a larger problem down into smaller modular components. See more here in ispython.com
abstraction in the context of 'computational thinking', describes the process of reducing complexity by using and creating tools, which hide the details of their operations.See more here in ispython.com
generalisation in the context of 'computational thinking', adapting solutions so that they can be used to solve a wider range of problems.See more here in ispython.com
evaluation in the context of 'computational thinking', assessing whether a program or technique works correctly and efficiently.See more here in ispython.com
creativity in the context of 'computational thinking, devising alternative designs or solutions'
computational computational thinking. 'Why' and 'How to' are the the essential foci of computational thinking, followed closely by other'solution-seeking' questions like 'With Whom', 'With What', 'When', 'Where' … engaging a myriad of allied thought processes.See more here in ispython.com
education is the process of facilitating learning, thinking, problem solving, creativity, and the acquisition of knowledge, skills, values, beliefs, and habits. It's also a word that has all 5 vowels.
pedagogy a model of teaching and learning; for Computer Science and programming see See more here in ispython.com/tao
enquiry enquiry-based learning is a form of active learning that starts by posing questions, problems or scenarios—rather than simply presenting established facts or portraying a smooth path to knowledge.
discovery learning is a technique of enquiry-based learning and is considered a constructivist based approach to education. It is also referred to as problem-based learning, experiential learning and 21st century learning. It is supported by the work of learning theorists and psychologists Jean Piaget and Seymour Papert. Although this form of instruction has great popularity, there is some debate in the literature concerning its efficacySee more here in Wikipedia
intuitive discovery, using or based on what a human feels to be the case even without conscious reasoning; instinctive. Unlikely to be part of a computer's repertoire of articial intelligence
machine (language) or machine code is the lowest-level programming language (except for computers that utilize programmable microcode). Machine languages are the only languages understood by computers.
hardware Computer hardware includes the physical, tangible parts or components of a computer, such as the central processing unit, monitor, keyboard, computer data storage, graphic card, sound card, speakers and motherboard.
central (processing unit)(CPU) is the electronic circuitry within a computer that carries out the instructions of a computer program by performing the basic arithmetic, logic, controlling and input/output (I/O) operations specified by the instructions. The computer industry has used the term 'central processing unit' at least since the early 1960s. Traditionally, the term 'CPU' refers to a processor, more specifically to its processing unit and control unit (CU).
digital tb
analog in computing, relating to or using signals or information represented by a continuously variable physical quantity such as spatial position, voltage, etc.
analogue in computing, relating to or using signals or information represented by a continuously variable physical quantity such as spatial position, voltage, etc.
top-down tb
variable tb
constant tb
mutable tb
network tb
online tb
offline tb
editor tb
iterate tb
pixels tb
software is a collection of data or computer instructions that tell the computer how to work. This is in contrast to physical hardware, from which the system is built and actually performs the work. See more here in Wikipedia
python an interpreted, high-level, general-purpose programming language. and has a design philosophy that emphasizes code readability, notably using significant whitespace. Python features a dynamic type system and automatic memory management. It supports multiple programming paradigms, including object-oriented, imperative, functional and procedural, and has a large and comprehensive standard library.
assembler a low-level mnemonic programming language in 1-1 correspondence with a computer's instructions
argument in computer programming, a value provided to a function when the function is called; this value is assigned to the corresponding parameter in the function
graphics (computer) are pictures and films created using computers. Usually, the term refers to computer-generated image data created with the help of specialized graphical hardware and software. It is a vast and recently developed area of computer scienceSee more here in Wikipedia
callback also known as a 'call-after' function, is any executable code that is passed as an argument to other code that is expected to call back (execute) the argument at a given time. This execution may be immediate as in a synchronous callback, or it might happen at a later time as in an asynchronous callback.
array is a data structure consisting of a collection of elements (values or variables), each identified by at least one array index or key. An array is stored such that the position of each element can be computed from its index tuple by a mathematical formula. The simplest type of data structure is a linear array, also called one-dimensional array.
database is a collection of information organized in such a way that a computer program can quickly select desired pieces of data. You can think of a traditional database as an electronic filing system, organized by fields, records, and files.
interpreter is a program that executes a high-level language program, usually a script language, an instruction at a time.
compiler is a program that translates source code into object code. more here in Wikipedia
bandwidth In computing, bandwidth is the maximum rate of data transfer across a given path.See more here in Wikipedia
YouTube the world of video See more here in Wikipedia