Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# The puzzle game 'Wordle'! # Basic idea: # the game loads in a set of 'known words' from a file or an array. #

# The puzzle game 'Wordle'!

# Basic idea:

# the game loads in a set of 'known words' from a file or an array.

# All 'known words' must have the same length (e.g., 5 characters)

# When the game starts, a secret word is chosen from the list of known words.

# The player can then issue guesses.

# Each guess returns a Hint object instance that tells:

# - which characters in the guess are correct, and correctly located.

# - which characters in the guess are in the secret word, but not at the location guessed

# - which characters in the guess are not in the secret word

# If all characters in the guess are correctly located, the game is won ;)

import random

from Hint import Hint

class Wordle(object):

"""docstring for Wordle"""

def __init__(self, file=None, wordList=[], length=0, minFreq=-1, maxFreq=-1):

pass

def numberOfKnownWords(self):

pass

# _Part 2: Implement this method._

# Load words from a file. Each line of the file contains a word followed by one or more spaces followed

# by a number whose value is higher for words that are more 'frequently occurring' than others.

# Loaded words should have a frequency value in the range [minfreq, maxfreq]. However, at times, these

# limits should be ignored (see comments below). Note that the words in the file may be many lengths

# (e.g., 3-10 characters). Only words of the specified length should be loaded.

# Hint: use a Scanner instance to read in the file and look for the next String or Long value.

# the following pattern will be useful ;)

# Scanner scan = new Scanner(new File(filenm));

# The line above creates a Scanner from a File with the filename stored in the variable filenm

# Use the scanner's .hasNext() method to test if there are more lines to read.

# Use the scanner's .next() method to grab the next String token (word).

# The scanner's .nextLong() method will grab the next token as a number (use this to read the frequency).

# For each line, you will want to call scan.next() and scan.nextLong() to read the data

# identifying a word and its relative frequency.

# Words of the specified length should be added into the knownWords list if their frequencies

# are the in the range specified.

# Hint: somewhere around 10-20 lines is probably appropriate here unless you have a lot of comments

# @param filenm - the file name to load from

# @param length - the length of words we want to load (e.g., 5 to load 5 character words)

# @param minfreq - the minimum allowable frequency for a loaded word

# @param maxfreq - the maximum allowable frequenct for a loaded word; 0 indicates no maximum

def loadWords(self, file, length, minFreq, maxFreq):

pass

# _Part 3: Implement this method._

# Obtain a list of known words. This method creates a new copy of the known words list.

# Here, you simply need to copy the knownWords list and return that copy.

# @return a new copy of list of known words.

def getKnownWords(self):

pass

# Prepare the game for playing by choosing a new secret word.

def initGame(self):

pass

# Supply a guess and get a hint!

# Note that this implementation DOES NOT require that the guess be selected

# from the known words. Rather, this implementation allows one to guess arbitrary

# characters, so long as the guess is the same length as the secret word.

# @param g - the guess (a string which is the same length as the secret word)

# @return a hint indicating the letters guessed correctly/incorrectly

# @returns None if the guess is not the same length as the secret word

def guess(self, g):

pass

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 3 Lnai 8726

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448440, 978-3662448441

Students also viewed these Databases questions

Question

=+18-4 Describe the loca- tion and function of feature. detectors.

Answered: 1 week ago