Clever Hangman. CompSci 101. April 16, 2013

Similar documents
Codebreaker Lesson Plan

CPSC 217 Assignment 3

CSE231 Spring Updated 04/09/2019 Project 10: Basra - A Fishing Card Game

CPSC 217 Assignment 3 Due Date: Friday March 30, 2018 at 11:59pm

G52CPP Lab Exercise: Hangman Requirements (v1.0)

Girls Programming Network. Scissors Paper Rock!

SEEM3460/ESTR3504 (2017) Project

Checkpoint Questions Due Monday, October 7 at 2:15 PM Remaining Questions Due Friday, October 11 at 2:15 PM

How to Make the Perfect Fireworks Display: Two Strategies for Hanabi

Math Games Ideas. For School or Home Education. by Teresa Evans. Copyright 2005 Teresa Evans. All rights reserved.

Assignment 6 Play A Game: Minesweeper or Battleship!!! Due: Sunday, December 3rd, :59pm

HW4: The Game of Pig Due date: Tuesday, Mar 15 th at 9pm. Late turn-in deadline is Thursday, Mar 17th at 9pm.

Spring 06 Assignment 2: Constraint Satisfaction Problems

Spring 06 Assignment 2: Constraint Satisfaction Problems

LESSON ACTIVITY TOOLKIT 2.0

A Mathematical Analysis of Oregon Lottery Keno

LESSON 7. Interfering with Declarer. General Concepts. General Introduction. Group Activities. Sample Deals

2048: An Autonomous Solver

CS 210 Fundamentals of Programming I Fall 2015 Programming Project 8

CSC C85 Embedded Systems Project # 1 Robot Localization

2: Turning the Tables

Probability Paradoxes

Let s Make. Math Fun. Volume 19 January/February Dice Challenges. Telling the Time. Printable Games. Mastering Multiplication.

by Teresa Evans Copyright 2005 Teresa Evans. All rights reserved.

CS Programming Project 1

HW4: The Game of Pig Due date: Thursday, Oct. 29 th at 9pm. Late turn-in deadline is Tuesday, Nov. 3 rd at 9pm.

Homework 5 Due April 28, 2017

CS 210 Fundamentals of Programming I Spring 2015 Programming Assignment 8

READING STRATEGIES. Thinking About How You Read

Dragon Canyon. Solo / 2-player Variant with AI Revision

Competition Handbook

Warm ups PLACE VALUE How many different ways can you make the number 365?

Setup. These rules are for three, four, or five players. A two-player variant is described at the end of this rulebook.

Lab Exercise #10. Assignment Overview

For this assignment, your job is to create a program that plays (a simplified version of) blackjack. Name your program blackjack.py.

Assignment II: Set. Objective. Materials

PROBLEM SET Explain the difference between mutual knowledge and common knowledge.

CMPT 310 Assignment 1

Solution: Alice tosses a coin and conveys the result to Bob. Problem: Alice can choose any result.

WHO AM I? K. Duncan-- English II Cary High School

Searching Lesson Plan

CS 371M. Homework 2: Risk. All submissions should be done via git. Refer to the git setup, and submission documents for the correct procedure.

CSE 231 Spring 2013 Programming Project 03

In this project, you ll learn how to create 2 random teams from a list of players. Start by adding a list of players to your program.

Student Ability Success Center (SASC) Procedures for Receiving Test Accommodations. effective 8/9/18

Official Rules For Bid Whist Tournaments

Problem 4.R1: Best Range

MITOCW R3. Document Distance, Insertion and Merge Sort

CS 1410 Final Project: TRON-41

PROBLEM SET 2 Due: Friday, September 28. Reading: CLRS Chapter 5 & Appendix C; CLR Sections 6.1, 6.2, 6.3, & 6.6;

Number Bases. Ideally this should lead to discussions on polynomials see Polynomials Question Sheet.

Inventor: 2009 manuela&wiesl

Maths Is Fun! Activity Pack Year 4

MODULE: DESIGNING AND DEVELOPING OBJECT-ORIENTED COMPUTER PROGRAMS ASSIGNMENT TITLE: WORDSEARCH MARCH 2014

Ovals and Diamonds and Squiggles, Oh My! (The Game of SET)

ICONIP 2009 Intelligent Liar Competition: Liar Dice (Individual Hand)

Seaman Risk List. Seaman Risk Mitigation. Miles Von Schriltz. Risk # 2: We may not be able to get the game to recognize voice commands accurately.

Trial version. Resistor Production. How can the outcomes be analysed to optimise the process? Student. Contents. Resistor Production page: 1 of 15

CMSC 201 Fall 2018 Project 3 Sudoku

For more information on how you can download and purchase Clickteam Fusion 2.5, check out the website

Assignment 3: Fortress Defense

League of Legends: Dynamic Team Builder

Sample pages. Skip Counting. Until we know the pattern of numbers, we can count on from the last answer. Skip count and write the numbers as you go.

Term 1 Assignment. Dates etc. project brief set: 20/11/2006 project tutorials: Assignment Weighting: 30% of coursework mark (15% of overall ES mark)

Make God Your Senior Business Partner

Lecture 13 Register Allocation: Coalescing

Arranging Rectangles. Problem of the Week Teacher Packet. Answer Check

Lecture 20: Combinatorial Search (1997) Steven Skiena. skiena

2018 Battle for Salvation Grand Tournament Pack- Draft

Assignment 1, Part A: Cityscapes

The Sorcerer s Chamber

Lotto! Online Product Guide

Kenken For Teachers. Tom Davis January 8, Abstract

Stat 155: solutions to midterm exam

Solutions for the Practice Final

If event A is more likely than event B, then the probability of event A is higher than the probability of event B.

Cardfight!! Vanguard Comprehensive Rules ver Last Updated: June 19, Rules

FREQUENTLY ASKED QUESTIONS

CS 251 Intermediate Programming Space Invaders Project: Part 3 Complete Game

ALGEBRA 2 HONORS QUADRATIC FUNCTIONS TOURNAMENT REVIEW

This assignment is worth 75 points and is due on the crashwhite.polytechnic.org server at 23:59:59 on the date given in class.

Mathematical Talk. Fun and Games! COUNT ON US MATHS CLUB ACTIVITIES SESSION. Key Stage 2. Resources. Hints and Tips

Programming Languages and Techniques Homework 3

Concentration Literacy Skills / Word Recognition

Special Notice. Rules. Weiss Schwarz Comprehensive Rules ver Last updated: September 3, Outline of the Game

CS1301 Individual Homework 5 Olympics Due Monday March 7 th, 2016 before 11:55pm Out of 100 Points

1. Partner has described your agreement correctly, but you don t have that hand. Correct response. 1. You have no responsibility to say anything

Instant Engagement Pair Structures. User s Manual. Instant Engagement 2011 Kagan Publishing

D1.10 SECOND ETHICAL REPORT

Name: Checked: jack queen king ace

CUBES. 12 Pistols E F D B

National Travel Associates. Destination Weddings & Group Packages National Travel Associates TheDestinationExperts.com

Bagels, Pico, Fermi. Bob Albrecht & George Firedrake Copyright (c) 2004 by Bob Albrecht

LESSON 8. Putting It All Together. General Concepts. General Introduction. Group Activities. Sample Deals

Welcome to another episode of Getting the Most. Out of IBM U2. This is Michael Logue, and I'll be your host

Jamie Mulholland, Simon Fraser University

The Hexagon Puzzle Cut Out the 7 hexagons below

General Rules. 1. Game Outline DRAGON BALL SUPER CARD GAME OFFICIAL RULE The act of surrendering is not affected by any cards.

Final Project (Choose 1 of the following) Max Score: A

Objective: Investigate patterns in vertical and horizontal lines, and interpret points on the plane as distances from the axes.

Transcription:

Clever Hangman CompSci 101 April 16, 2013 1

1 Introduction/Goals The goal of this assignment is to write a program that implements a cheating variant of the well known Hangman game on the python terminal. Contrary to the normal Hangman game where the word is chosen at the beginning, in this variant we want the word to change with each guess that the player makes. The change should be done so that the pool of possible words remains as large as possible. More specifically, after each guess the player makes we want the program to change the secret word respecting the following two conditions: 1 The new word is harder to guess. How to do that will be explained later. 2 The new word must be consistent with all the previous guesses. The user/player isn t aware that the computer is changing the secret word, because each time the player guesses, the computer may change the secret word in a consistent way that s not apparent to the player. In order to do so, you can use the code from the previous honest Hangman game, the code can be found here: http://www.cs.duke.edu/courses/ spring13/compsci101/assign/hangman/code/hangdemo.py Using this code is optional. Among others you will need a text file, which contains all the various words which from your main program will choose from. In this url http:// www.cs.duke.edu/courses/spring13/compsci101/assign/hangman/code/ lowerwords.txt you will find the words with which the game will be played. 2

2 Specifications This section explains in detail how the computer changes the secret word into another, which is consistent with the past guesses, but is more difficult for the human player to find. In order to do so, first we present an example of how the computer changes the secret word as the game progresses. The output below shows how the computer plays a game of clever Hangman. The secret word is shown before each guess the human player makes, as well as the number of possible words that could be the secret word. In that sense, the secret word is not unique, but it is rather just one possibility out of the pool of consistent words. Welcome to ( Clever ) Hangman : Computer s s i d e : ( s e c r e t word : c u r r i e s ) words p o s s i b l e : 7359 l e t t e r s missed : guess a l e t t e r : i i not i n s e c r e t word Computer s s i d e : ( s e c r e t word : t r e s s e s ) words p o s s i b l e : 4048 l e t t e r s missed : i guess a l e t t e r : e you guessed a l e t t e r c o r r e c t l y! Computer s s i d e : ( s e c r e t word : w a f f l e s ) words p o s s i b l e : 969 e l e t t e r s missed : i guess a l e t t e r : a a not i n s e c r e t word Computer s s i d e : ( s e c r e t word : toppled ) words p o s s i b l e : 455 e l e t t e r s missed : i a guess a l e t t e r : o o not i n s e c r e t word Computer s s i d e : ( s e c r e t word : jumbled ) words p o s s i b l e : 159 e l e t t e r s missed : i a o guess a l e t t e r : u you guessed a l e t t e r c o r r e c t l y! 3

An analysis of this game follows: Initially the first hint is shown to the user: the secret word has 7 letters. This means that out of our lexicon s lowerwords.txt 45,356 words, all 7,359 with 7 letters are possibly our secret word. The computer randomly picks up curries as the secret word - this is not necessary but it will help illustrate the mechanism under which the computer changes the possible words. The first guess of the user is i. The computer checks out of all 7,359 words how many contain the letter i and it sees that only 3,311 contain it, whilst 4,048 do not contain it. Based on this observation the computer decides that the letter i is incorrect and thus changes its possible words to all the 7 letter words that do not contain the letter i. This changes the state of the game: the possible words are 4,048 and the new secret word is a randomly chosen word tresses. The user guesses e. The computer checks the possible words, either the word has no e or it has one or more e s in any position. After this check, the computer observes that the category with the most words is the one where e is the second to last letter, with a total of 969 words. This changes the state of the game: the possible words are now 969 and the new secret word is a randomly chosen word waffles. The user guesses a. The computer checks the possible words, either the word has no a or it has one or more a s in any position. After this check, the computer observes that the category with the most words is the one where there is no a. This changes the state of the game: the possible words are now 455 and the new secret word is a randomly chosen word toppled. The user guesses o. The computer checks the possible words, either the word has no o or it has one or more o s in any position. After this check, the computer observes that the category with the most words is the one where there are is no o. This changes the state of the game: the possible words are 159 and the new secret word randomly chosen is jumbled. Similarly in the last round shown, the user guesses u and the computer decides that the pool of words containing u at a certain position is bigger than all the other categories of words. 4

The important points that you need to implement are the following: Consistency Whenever the computer changes its pool of possible words (and thus the secret word), it does so in a fashion which all the previous guesses of the player (right or wrong) are consistent with the new choice. Categories As you saw in the example, after each guess the computer calculates the possibilities of the words and chooses the category with the most words. For example, when the user guesses e, the computer decides to show one single e on the 6 th position of the word, it does so because that s the largest category of seven letter words after the computer is enforced to reveal information about any e in the word. More precisely, after the user guesses e the computer divides the possible words in the following categories: Words with no e : 641 possible words Words of the form: e 849 possible words Words of the form: e 311 possible words Words of the form: e e 41 possible words Words of the form: e e 14 possible words Words of the form: e 210 possible words Words of the form: e e 172 possible words etc. As you can understand the number of possible categories depends on the pool of possible words at that time, and could potentially be very large. After splitting the pool of words into these categories, the computer checks the size of each category and chooses the largest one - in this case the second category. You must implement the algorithm so the computer decides if the guessed letter is in the word or not, depending on the categories.whenever the user makes a guess, the pool of possible words should shrink by the least possible amount. Moreover, if the computer decides that the guessed letter is in the word, then it must decide in which position(s) it is - like in the example above where it will choose that e is second to last letter. Ideally when the user has run out of guesses, the pool of possible words will contain more than one word, which essentially guarantees that the user lost the game. 5

3 Guidelines In this section general guidelines on how to implement the categories part are given. You are not required to follow these instructions, as they are here to just give you an idea on how to proceed with your implementations. The main idea in creating categories is to use a dictionary in which each possible template of words is a key and the corresponding value is a list of words that matches that template. For example, words matching: t t are: [ t i t a n, t i t h e, t i t l e, t i t u s, t o t a l, t u t o r ] To create this dictionary, you iterate over every possible word - initially this is all words, but the list of possible words changes after each guess made by the player. Then for each word, you either assign that word to an already existing template (or even increase a counter associated with that template), or you create a template with respect to the guessed letter where that word fits in the case that there was no template that the word fitted. This means that the first word will always create a template. An example is shown below: Assume that the pool of words is: [ oboe, noon, odor, room, s o l o, t r i o, goto, oath, oxen, pick, f r a t, hoop ] And the guessed letter is o. Then the following dictionary should be created: c a t e g o r i e s = { o o : [ oboe, odor ], o o : [ noon, room, hoop ], o o : [ s o l o, goto ], o : [ t r i o ], o : [ oath, oxen ], : [ pick, f r a t ] } In a game-playing program, the largest collection of values (most words) corresponds to key o o so the computer would pick a secret word at random from the list of three words: [ noon, room, hoop ] and the template for the game would be o o with three possibilities. The player may think she has hit the jackpot with two o s in the word, and that may be true, but there are more words to eliminate than with any other template! It is a clever hangman game. 6

4 Deliverables Feel free to form up teams 2 persons in order to complete this assignment. Students who form a team have to submit separately their code and must write down their coding partner in the README file. The following are expected: The python module that implements the clever hangman application. A README plain text file that contains valuable information like additional comments, the resources you used to finish the assignment etc. Working together is permitted, what is not permitted is working together without stating so in the README file. Plagiarism will not be tolerated and we expect everybody to comply with the Duke Community Standard. Important Dates Turn in by April 25: Full points Turn in by April 28: 50% down All deadlines are at 11:55pm on that day. 11:55 on April 28 will not be graded. Anything turned in after How to submit: Either via Eclipse Ambient or the web submit system. Links to these two methods can be found on the Large Assignment tab on the course website. 7