This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#26 2012-02-20 18:28:08

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: Cheating Hangman Game Help!

pdubu wrote:

Sorry about the curse. I'm a little stressed out from this program.

And scratch out part of my previous comment: I figured out how to delete words not in the list.

I'm still confused as to how I should approach the second letters and third, and so on. As well as how to rid myself of words that don't match the length criteria.

What length criteria?

Offline

 

#27 2012-02-20 18:39:18

pdubu
New Scratcher
Registered: 2012-01-29
Posts: 19

Re: Cheating Hangman Game Help!

So I have a list of 2000 words of various lengths...

If the player chooses to play with a 5 letter word, I'd like to delete the rest of the words that do not match the 5 letter length criteria.

Offline

 

#28 2012-02-20 19:38:27

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: Cheating Hangman Game Help!

pdubu wrote:

So I have a list of 2000 words of various lengths...

If the player chooses to play with a 5 letter word, I'd like to delete the rest of the words that do not match the 5 letter length criteria.

OK, I revised my script:

1.  Eliminates all words that do not match the length.
2.  Repeatedly asks the user for a letter.
3.  Deletes all of the words containing that letter.
4.  If only one word remains, it picks that one.  If no words remain, it picks a random one from the most recent available ones.  Otherwise, it cycles back to step 2.

Is there anything else it needs to do?

Offline

 

#29 2012-02-23 17:37:05

steaksauceyum
New Scratcher
Registered: 2012-02-23
Posts: 14

Re: Cheating Hangman Game Help!

Hi there. I have a scratch program that plays hangman, how would I implement your block into my file?  Is there anyway you could show the entire result?  (I don't know how to post my code on here, but if I figure it out, Ill do it).

Offline

 

#30 2012-02-23 17:43:17

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: Cheating Hangman Game Help!

steaksauceyum wrote:

Hi there. I have a scratch program that plays hangman, how would I implement your block into my file?  Is there anyway you could show the entire result?  (I don't know how to post my code on here, but if I figure it out, Ill do it).

First, let's make sure my script fits pdubu's needs (since he's the one who asked for it).  I have yet to hear a response...   hmm

Offline

 

#31 2012-02-24 02:24:23

steaksauceyum
New Scratcher
Registered: 2012-02-23
Posts: 14

Re: Cheating Hangman Game Help!

Here is a link to the flow chart of how it should work..
http://inst.eecs.berkeley.edu/~cs10/sp12/hw/evil-hangman-flowchart.pdf

this is basically what pdubu is trying to create. 

Im still trying to send you my code, but apparently I cant private message you  hmm

Offline

 

#32 2012-02-24 08:49:46

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: Cheating Hangman Game Help!

steaksauceyum wrote:

Here is a link to the flow chart of how it should work..
http://inst.eecs.berkeley.edu/~cs10/sp12/hw/evil-hangman-flowchart.pdf

this is basically what pdubu is trying to create. 

Im still trying to send you my code, but apparently I cant private message you  hmm

Alright, my code is saved on another computer, but I'll try to upload it by the end of the day.   smile

Offline

 

#33 2012-02-24 12:45:11

steaksauceyum
New Scratcher
Registered: 2012-02-23
Posts: 14

Re: Cheating Hangman Game Help!

How do you upload it? I would be more than glad to send you my version so that you would not need to do the actual hangman code, but simply show how to add in your tweaks.  Perhaps through email?

Offline

 

#34 2012-02-24 16:26:00

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: Cheating Hangman Game Help!

steaksauceyum wrote:

How do you upload it? I would be more than glad to send you my version so that you would not need to do the actual hangman code, but simply show how to add in your tweaks.  Perhaps through email?

Click 'Share', then 'Share this project online...'  smile

Offline

 

#35 2012-02-24 18:44:07

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: Cheating Hangman Game Help!

It's uploaded now!  You can find the script by downloading this project.   smile

Offline

 

#36 2012-02-24 19:05:29

Smozzick
Scratcher
Registered: 2011-10-23
Posts: 100+

Re: Cheating Hangman Game Help!

This is actually really hard. I'm trying it at the moment and while I've managed to get a script done it has errors at the moment >.>

Nice idea, though.


http://i50.tinypic.com/ded8m.png

Offline

 

#37 2012-02-24 20:14:03

steaksauceyum
New Scratcher
Registered: 2012-02-23
Posts: 14

Re: Cheating Hangman Game Help!

Here's a link to the BYOB file for my game.  This is not my game, but my code is very similar. 
http://inst.eecs.berkeley.edu/~cs10/sp12/hw/hw2-sol.ypr

I don't understand how I could implement your code into mine.. I get errors, the game wont even tell me if the word I chose was right or wrong (although I didnt exactly use your code, I used one similar to yours). Could you give any insight to how you I could edit my code to implement yours?

Note just in case you dont know what byob is, it's basically scratch but with a bit more options.  It has all of the same features as scratch, the blocks even look the same! So if you need to download byob, here's the site too..

http://snap.berkeley.edu/

Offline

 

#38 2012-02-24 20:33:01

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: Cheating Hangman Game Help!

I have BYOB.   smile

steaksauceyum wrote:

Here's a link to the BYOB file for my game.  This is not my game, but my code is very similar.

Huh?   tongue

Offline

 

#39 2012-02-24 20:41:47

steaksauceyum
New Scratcher
Registered: 2012-02-23
Posts: 14

Re: Cheating Hangman Game Help!

were you able to download the code?

And yeah im not making too much sense right now, just got out of a testing haha

I wrote code that is basically the same thing as what I provided in the first link. Mine is a bit different, but they both work the same way, so any alterations to that one, id understand and be able to make to my own version.

as I said before, I'm having trouble implementing your algorithm into the hangman game.  I think my lists arent matching up or something.  If you manage to do it, can you explain how?

Offline

 

#40 2012-02-24 20:58:28

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: Cheating Hangman Game Help!

steaksauceyum wrote:

were you able to download the code?

And yeah im not making too much sense right now, just got out of a testing haha

I wrote code that is basically the same thing as what I provided in the first link. Mine is a bit different, but they both work the same way, so any alterations to that one, id understand and be able to make to my own version.

as I said before, I'm having trouble implementing your algorithm into the hangman game.  I think my lists arent matching up or something.  If you manage to do it, can you explain how?

Could you upload your project and post a link?   smile

Offline

 

#41 2012-02-24 21:05:17

steaksauceyum
New Scratcher
Registered: 2012-02-23
Posts: 14

Re: Cheating Hangman Game Help!

I dont know how to upload from byob. That's why I sent you the generic version of hangman (which is basically what I have).  Can you upload to this site from byob?

Offline

 

#42 2012-02-24 21:08:15

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: Cheating Hangman Game Help!

steaksauceyum wrote:

I dont know how to upload from byob. That's why I sent you the generic version of hangman (which is basically what I have).  Can you upload to this site from byob?

Oh, it's a BYOB project.  Technically, you can, but you're not supposed to.  Let me see what I can do with that project you gave me...but I got a sudden onslaught of work this weekend, so it might be a while before I get a chance.   sad

Offline

 

#43 2012-02-24 21:10:40

steaksauceyum
New Scratcher
Registered: 2012-02-23
Posts: 14

Re: Cheating Hangman Game Help!

Oh man, I'd appreciate it if you could help before midnight tonight haha.

As I said before, the hard part is done, now I just need to know how to implement the algorithm into the code.

Offline

 

#44 2012-02-24 21:21:16

Haiming
Scratcher
Registered: 2011-08-20
Posts: 1000+

Re: Cheating Hangman Game Help!

You could make a list of words. You will need multiple lists and variables though...

Offline

 

#45 2012-02-24 21:45:48

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: Cheating Hangman Game Help!

steaksauceyum wrote:

Oh man, I'd appreciate it if you could help before midnight tonight haha.

As I said before, the hard part is done, now I just need to know how to implement the algorithm into the code.

I'm sorry, I won't be able to get to it tonight.   sad

You're getting conflicts because there are some variables/lists with the same name between the scripts.  Here's what I would recommend:

1.  Make a list called "usable words".
2.  Take the first block (set [c1  v] to (1) ) and the repeat loop right after it.  Put it into its own block.  Change all the references to "words" to "usable words".
3.  After the user selects the length, copy all the words from "words" to "usable words" (the 3rd repeat loop in my script contains code to do something similar--a loop and two blocks).  Then run the new block, leaving "usable words" with only words of that length.
4.  Put the rest of my script into another block.  Again, change all "words" references to "usable words".  The script variable "letter" should be set to (answer).  "Stop script" should be changed to "stop block" (appears twice).  Remove the "repeat until < (length of (letter) ) = (1) >" loop and its contents. 
5.  Run this block after the user guesses a letter successfully.  It should change the answer if possible.


I tried to address as much as I could in there; sorry if it was confusing.  I can't do any more tonight.   sad   Remember to create script variables for the variables in my script.

Last edited by Greenatic (2012-02-24 21:46:55)

Offline

 

#46 2012-02-25 09:50:51

gkc
Scratcher
Registered: 2009-09-17
Posts: 23

Re: Cheating Hangman Game Help!

http://scratch.mit.edu/projects/gkc/2355587 is my solution. It works quite well, all it needs now is a bigger list of words and better graphics!

Offline

 

#47 2012-02-25 10:24:22

rdococ
Scratcher
Registered: 2009-10-11
Posts: 1000+

Re: Cheating Hangman Game Help!

Greenatic wrote:

pdubu wrote:

I already have a list of words. So if my list were to contain 5 words:
apple
ant
bear
cheese
milk

And the first guess was "a", then apple, ant, and bear would be eliminated due to those three containing the letter "a" ... then depending on which letter is chosen first, either milk or cheese will be selected as the finalized secret word.

Does anybody have any idea how to approach this?

Give me a sec...

OK, I got it.

I'm assuming the letter is stored in a variable named "letter" and the possible words for use are in a list named "words".  Create three additional variables:  "c1", "c2", and "bool".

set [c1  v] to (1)
repeat (length of [words  v])
set [c2  v] to (1)
set [bool  v] to (0)
repeat (length of (item (c1) of [words  v]))
if < <(bool) = (0)> and <(letter (c2) of (item (c1) of [words  v])) = (letter)> >
delete (c1) of [words  v]
set [bool  v] to (1)
end
change [c2  v] by (1)
end 
if <(bool) = (0)>
change [c1  v] by (1)
end
end
The new word can then be accessed by:
(item (pick random (1) to (length of [words  v])) of [words  v])
Let me know if you have any problems.

Scratchblocks didn't create that error. It was a syntax error you made. I fixed it for you.

Offline

 

#48 2012-02-25 10:49:38

Smozzick
Scratcher
Registered: 2011-10-23
Posts: 100+

Re: Cheating Hangman Game Help!

Well my code is much longer than the above (Read: Badly written) but it's effectively the code for a cheating hangman game:

Link to Project


http://i50.tinypic.com/ded8m.png

Offline

 

#49 2012-02-26 20:00:57

steaksauceyum
New Scratcher
Registered: 2012-02-23
Posts: 14

Re: Cheating Hangman Game Help!

Greenatic wrote:

steaksauceyum wrote:

Oh man, I'd appreciate it if you could help before midnight tonight haha.

As I said before, the hard part is done, now I just need to know how to implement the algorithm into the code.

I'm sorry, I won't be able to get to it tonight.   sad

You're getting conflicts because there are some variables/lists with the same name between the scripts.  Here's what I would recommend:

1.  Make a list called "usable words".
2.  Take the first block (set [c1  v] to (1) ) and the repeat loop right after it.  Put it into its own block.  Change all the references to "words" to "usable words".
3.  After the user selects the length, copy all the words from "words" to "usable words" (the 3rd repeat loop in my script contains code to do something similar--a loop and two blocks).  Then run the new block, leaving "usable words" with only words of that length.
4.  Put the rest of my script into another block.  Again, change all "words" references to "usable words".  The script variable "letter" should be set to (answer).  "Stop script" should be changed to "stop block" (appears twice).  Remove the "repeat until < (length of (letter) ) = (1) >" loop and its contents. 
5.  Run this block after the user guesses a letter successfully.  It should change the answer if possible.


I tried to address as much as I could in there; sorry if it was confusing.  I can't do any more tonight.   sad   Remember to create script variables for the variables in my script.

This is a bit confusing haha.  I'll give it a go now.  If you could produce code using the one I sent you with the one you created, that would be appreciated too! I just want to see how to mix them together.  Text is harder to visualize haha

Offline

 

#50 2012-02-26 20:25:50

steaksauceyum
New Scratcher
Registered: 2012-02-23
Posts: 14

Re: Cheating Hangman Game Help!

Greenatic wrote:

steaksauceyum wrote:

Greenatic wrote:


I'm sorry, I won't be able to get to it tonight.   sad

You're getting conflicts because there are some variables/lists with the same name between the scripts.  Here's what I would recommend:

1.  Make a list called "usable words".
2.  Take the first block (set [c1  v] to (1) ) and the repeat loop right after it.  Put it into its own block.  Change all the references to "words" to "usable words".
3.  After the user selects the length, copy all the words from "words" to "usable words" (the 3rd repeat loop in my script contains code to do something similar--a loop and two blocks).  Then run the new block, leaving "usable words" with only words of that length.
4.  Put the rest of my script into another block.  Again, change all "words" references to "usable words".  The script variable "letter" should be set to (answer).  "Stop script" should be changed to "stop block" (appears twice).  Remove the "repeat until < (length of (letter) ) = (1) >" loop and its contents. 
5.  Run this block after the user guesses a letter successfully.  It should change the answer if possible.


I tried to address as much as I could in there; sorry if it was confusing.  I can't do any more tonight.   sad   Remember to create script variables for the variables in my script.

This is a bit confusing haha.  I'll give it a go now.  If you could produce code using the one I sent you with the one you created, that would be appreciated too! I just want to see how to mix them together.  Text is harder to visualize haha

Gkc's script seems to work pretty well.  You just need to add in the part that prevents the total number of possible words from going to 0, as well as what to do if it hits 1.

Yeah I took a look at his.  But it seems as though that the game never chooses another word.  It changes over and over again after the first guess and goes on and on.  Why does it do that?

Offline

 

Board footer