Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]Implement exercise hangman #1160

Closed
wants to merge 13 commits into from

Conversation

khoa102
Copy link

@khoa102 khoa102 commented Jan 10, 2018

Fixes #745

Ported from csharp track

@khoa102 khoa102 changed the title Implement exercise hangman [WIP]Implement exercise hangman Jan 10, 2018
@cmccandless
Copy link
Contributor

Exercise description for convenience.

@khoa102
Copy link
Author

khoa102 commented Jan 10, 2018

The way I make the exercise is a little bit different from the description. I look at the pull request #905 and it seems from that conversation that I do not need to make it with FRP. I also adapt the tests from the c-sharp tracks.

- Add the text about exception and submition to README
Copy link
Contributor

@cmccandless cmccandless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In response to your comment:
difficulty: I would rate this at a medium-ish difficulty (~4-6).
unlocked_by/core: For now, all exercises in this track are unlocked_by: null, core: false
topics: Take a look at the global topics list and determine which are relevant to this exercise. To start, you may look at the topics used in the C# track, but keep in mind that some topics may be more specific to one language than another.

@@ -0,0 +1,32 @@
# Need edit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be the title of the exercise

@@ -0,0 +1,82 @@
import unittest

from example import Hangman
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import from hangman.

from example import Hangman


# Adapt from c-sharp track
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to the following:
# Tests adapted from csharp//hangman/HangmanTest.cs

Normally, we would have a comment here citing the version of the canonical data that these tests were based on. In this case, there is no canonical data for this exercise, so this is fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@khoa102 Please apply this fix.

config.json Outdated
"difficulty": 5,
"topics":[
"events",
"reactive_programming"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest adding strings to this list, as there is inherently some string manipulation involved with this exercise.

@cmccandless cmccandless requested a review from N-Parsons January 23, 2018 15:47
Copy link
Contributor

@N-Parsons N-Parsons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description needs some work, and I think Hangman.status needs to be reworked.

@@ -0,0 +1,33 @@
Hangman
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a title: # Hangman

Functional Reactive Programming is a way to write interactive programs. It differs from the usual perspective in that instead of saying "when the button is pressed increment the counter", you write "the value of the counter is the sum of the number of times the button is pressed."

Implement the basic logic behind hangman using functional reactive programming. You'll need to install an FRP library for this, this will be described in the language/track specific files of the exercise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this exercise isn't about functional reactive programming now, then references to it need to be removed. This needs a track-specific description, which should be put into description.md so that it doesn't get lost.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, do you have any suggestion on how the description should be? And the file description.md that you mention is in the problem specification right?

For example, if you're submitting `bob.py` for the Bob exercise, the submit command would be something like `exercism submit <path_to_exercism_dir>/python/bob/bob.py`.

For more detailed information about running tests, code style and linting,
please see the [help page](http://exercism.io/languages/python).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a section at the bottom about submitting incomplete solutions. It's best to generate these using the configlet.

You can install it by running bin/fetch-configlet and then run bin/configlet generate --spec-path <path/to/problem-specifications> --only hangman.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that you will have to clone exercism/problem-specifications to generate README files.

from hangman import Hangman


# Tests adapted from csharp//hangman/HangmanTest.cs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a blank line after this version comment?

class Hangman:
def __init__(self, word):
self.remainingGuesses = 9
self.status = 'busy'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "busy" is a little confusing as a status - it makes me think that the class is currently doing something and can't respond. "in progress" might be better?

A better approach to handling status would be to declare some constants at the start of the class (WIN, LOSE, UNFINISHED). The class would then set with self.status = self.WIN and tested with self.assertEqual(game.status, game.WIN). This approach frees up the learner to chose whatever values they find most appropriate/convenient for handling game status.

I also think that we need a test to check that a game that has been lost refuses further interaction. Currently, your example would fail this test, since if I just guess every letter in the alphabet, the status would go to "lose" and then back to "win" once I have guessed all of the letters in the word.

Copy link
Author

@khoa102 khoa102 Jan 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do want me to stop the game after it is finished (either win or lose)? Should I raise an Exception or Error? or should i just use an if statement and stop it from updating everything in guess()?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@khoa102 Can you clarify what you mean by "stop the game"? Since this is not an interactive program, "stop" loses its meaning.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cmccandless N-Parson mentions earlier that "a game that has been lost refuses further interaction." And that is what I mean by stopping the game after it's finished (win or lose)

@cmccandless
Copy link
Contributor

@khoa102 Are you still interested in completing this?

@stale
Copy link

stale bot commented May 18, 2018

This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the abandoned label May 18, 2018
@stale stale bot closed this May 25, 2018
cmccandless pushed a commit that referenced this pull request Mar 4, 2019
Fixes #745 

Solution based on the work of #1160

Config file lint with tool `configlet`, shall I keep all the changes in the config?

Ready for review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants