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

Random Sentence Generator is Insufficiently Random #25 solution #96

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

aanyasinghdhaka
Copy link

i am a first time contributer please check my pull request if its right

@mr-martian
Copy link
Collaborator

Could you explain your changes? I'm not sure what selected_rules is achieving since there's only ever at most one item in it.

@aanyasinghdhaka
Copy link
Author

I added selected_rules to stop using the same rule back-to-back when making sentences. It's like a memory that helps the program avoid picking the same rule right after it was just used. This change makes the sentences more different during one turn of the program. But, it doesn't change how rules are picked in different turns. Its job is to avoid doing the same thing again and add a little more variety just for one time the program runs.

@mr-martian
Copy link
Collaborator

My reading of the code is the following:

  1. to generate the next node of the tree, create an empty set
  2. choose a rule at random
  3. if the rule is already in the set, return to step 2.
  4. generate the chosen rule

Note that because the set is always empty after step 1, the rule chosen in step 2 will never be in it, and thus step 3 will never be relevant.

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.

2 participants