Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / require even more hangman help in dbpro

Author
Message
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 20th Jan 2006 05:15
I stepped away from programming for a while and came back today and it has helped me. Anyways, I am still working on my hangman program and I am now trying to make it so guessing the wrong letter more than once will not count against you. I tried making a blank string, and then making a switch and setting it to 0, then check if the blank string has the wrong guess in it and if it does then it switches the switch to 1. then it checks if the switch is at zero and if it is then it adds the wrong guess to the blank string. i set it up like this so that you would have to make two guesses before it checks if your guess is in the string or else it would "think" you guessed the wrong letter twice when you only guessed it once. I hope i did not confuse you. so, after you guess two different wrong letters, you can keep guessing those same two and it will be counted as a strike, and it will print the same letter over and over again in the wrong word bank. please help.


Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 20th Jan 2006 07:54
You're on the right track. You just need to make the string 26 spaces and use the same method used to replace the *'s with letters.


Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 23rd Jan 2006 21:58
for some reason, i think the right$() parameter isn't increasing properly because your wrong answer variable is always the first wrong answer and that one alone.

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 24th Jan 2006 03:07
It's always going to be the first letter because "check$" equals nothing.

It easier to make "check$" all the letters from a to z... not just the letters that are wrong but every letter that the user has tried.

"x" needs to be a number (not from 1 to the length of the string) but a number based on the ascii chart of the letter the user picks. You can make a little routine that uses the ascii chart numbers (A = 65 , Z = 90) to determine what place in check$ to change the blank space to the letter tried.

Be sure to make "guess$" highercase right after the user hits enter.

Ascii Chart:
http://www.unipg.it/carlo/Ascii.png


Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 26th Jan 2006 03:55
thanks, i'll try it now
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 26th Jan 2006 06:10
Quote: "You can make a little routine that uses the ascii chart numbers (A = 65 , Z = 90) to determine what place in check$ to change the blank space to the letter tried."


Do you mean the blank space as in the correct or incorrect answer or both?

Any psuedo-code to illustrate this perhaps?

Quote: "Be sure to make "guess$" highercase right after the user hits enter."


Do you mean because 65 - 90 are the uppercase forms, because cant' I just used 97 to 122?
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 26th Jan 2006 22:49
Quote: "Do you mean the blank space as in the correct or incorrect answer or both?

Any psuedo-code to illustrate this perhaps?"


It's hard for me to make psuedo-code... i'll try to explain better.

It needs to be both correct and incorrect letters. The string will start out as a blank string (with 26 spaces). When the user guesses B it'll add B to the string (as the second character).

Like:


If the user guesses L next it'll add L to the string where L should be:


It'll keep adding letters in the appropriate spot until (if all letters are guessed) it looks like:


Using this method you can use that string to quickly show the user what letters have been guessed (printing that string to the screen) and an easy way to quickly find out if a letter has been tried already (with a for/next loop to check every letter in the string vs the guessed letter).

Quote: "Do you mean because 65 - 90 are the uppercase forms, because cant' I just used 97 to 122?"


Yeah. You can use either highercase or lowercase... it's best to just change the user input to a specific case so you don't have to check for both a highercase letter and a lowercase letter. If you want to use lowercase make sure that the letters in the string that represent the guessed letters all use lowercase too (because checking the user unput of "a" to "A" won't be seen as the same letter). I mentioned the ascii chart so you can figure out how to convert the ascii number of a letter to it's proper place in check$.


Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 27th Jan 2006 00:39
Quote: "If the user guesses L next it'll add L to the string where L should be:"
i see what u mean now
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 28th Jan 2006 19:54
it's just not workin out for me chief, mind cheating and fixing it for me just this once please???!!!
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 28th Jan 2006 21:43 Edited at: 28th Jan 2006 21:52
I'll give you a code example.

This picks a new letter (that isn't in check$) and waits for a keypress (to show you what it's doing slowly).




Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 31st Jan 2006 00:09
ok, i see how that works, but there's one difference... your code has one condition (whehter or not the letter has been used before). In my code, there's two: (1) whether or not the letter has been used before (2) if the letter is the correct one.

you had me make a right varible equal 0 and then make a for/next loop to see if the letter guess was in the hidden word and if it was then make that variable equal 1. then, make an if/then statement to see whether or not that variable was still 0, and if it was, then increase the strikes variable. So, i tried to apply this same thing with a used variable to determine whether or not the letter had been used (regardless of whether it was right or wrong) and if it had, then ignore the if/then statement that checks whether the variable was still 0 altogether. I am not sure how to do it. I tired making the used and right variables equal true or false excessively, but it seems like darkbasic doesn't give a crap.


Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 31st Jan 2006 04:00
That code snip was not meant to do everything just show you an example of how to record what letters have been picked already.

The steps should be like this:

1. Get the letter from the user.
2. Check if the letter has been used before
----If it has been used before tell the user and go back to step 1
3. Check if the letter is in the word string
----If it is change the * string to add the letter
----If not add to the variable that tracks wrong answers
4. Check if the * string = the word string.
5. Go back to step 1


Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 3rd Feb 2006 02:59
wghat's the reasoning behind defining the variable as 1 ignored?
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 3rd Feb 2006 05:04
Which variable?


Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 7th Feb 2006 02:47
Quote: "Which variable?"

the right variable. Why is it ignored when the code says....



if the guess is in the word, then right = 1?
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 7th Feb 2006 02:54
Quote: "----If it has been used before tell the user and go back to step 1"


the only way I know to do this is with subprocedures. Is that what I will need to use?
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 7th Feb 2006 05:04 Edited at: 7th Feb 2006 05:05
Ah. In the check for the letters that have been picked already you don't want the line "right=1" because if a letter has been used does not mean that it's a right answer (because that string has both right and wrong letters). You only want "right=1" in the check of the word.

The way to do that line is the way I did in the example. This loops until the letter picked is not already in the string that holds all the letters picked. Step 1 and 2.



Would you like me to give you a complete code snip with all the steps in one snip?


Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 8th Feb 2006 23:22
Quote: "Would you like me to give you a complete code snip with all the steps in one snip?"


sure would
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 9th Feb 2006 00:42
Np.




Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 9th Feb 2006 21:50
you're a friggin genius man, thanks!!
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 9th Feb 2006 22:10
Thanks and np.


Login to post a reply

Server time is: 2024-09-24 15:38:31
Your offset time is: 2024-09-24 15:38:31