Link to home
Start Free TrialLog in
Avatar of Paul Tomasi
Paul TomasiFlag for United Kingdom of Great Britain and Northern Ireland

asked on

One for the Experts...

Okay, so it feels great to come up with a solution to a problem. It's even greater when it's a challenging problem. And greater still when your solution is "ACCEPTED" and you bag points.

So, I'd like to think Experts such as: paultomasi (that's me by the way), Qlemo, billprew, dragon-it, ReneGe, KnightEknight, oBdA, leew, BillDL (and whatever happened to AmazingTech?) infact, anyone who wants to participate, could take it in turn to think of a challenging question to be solved by us all.

It shouldn't be seen as a race and the aim is to share problem solving ideas and knowledge.

So, on that note, there are 500 points up for grabs for this first question....


QUESTION

Create a text-based hangman game

CPU randomly chooses a word from a 10-letter word-pool (seperate text file).

CPU initially displays 10 underscore characters and prompts user for letter.

At each turn, CPU displays:
   number of turns so far ie, Turn #1 or whatever...
   10-letter string containing mix of correctly guessed letters and underscores
   number of lives remaining
   A-Z list of available letters with underscores showing used letters
   list of letters used so far

When entering letters (for each guess),
   if a letter is entered it's treated as a letter
   an incorrect letter costs a life
   if a word is entered it's treated as a guess
   an incorrect guess costs a life and play continues
   a correct guess wins the game early

Play continues until either:
   word is guessed (by entering whole word at any time)
   all letters of word found (in which case word is guessed)
   all lives lost

Socre for each round:
   correctly guessed word:
      lives remaining:
         0: 1pt
         1: 2pts
         2: 3pts
         3: 5pts
         4: 8pts
         5: 13pts
         ::
         10: 89pts (unlikely unless you're psychic or VERY lucky!!)

         points progress by adding previous number ie: 1, 2, 3, 5, 8, 13, 21, 34, 55 and 89.

   otherwise, unguessed word = 0

Loop for 10 rounds of play showing 'Round number' or 'Game number' ... 1-10

At the end of each round, display correct word and score for that round.
Output word and score to file.

After 10 rounds (or when user quits play), read data from file and display following stats:
   number of rounds played
   display list of words played and score by side
   average score

Notes:
   when entering letters, will accept either case.
   if letter already chosen - ignore it - do not lose a life
   when displaying word - use uppercase letters/underscores
   use lowercase when displaying A-Z available letter and letters used lists
   display minimum short appropriate messages during game play

   user can quit anytime if entering blank when required to enter letter however, user MUST be asked to confirm (Y/N) and either continue or end.

   if user quits early, stats must still be displayed - what is displayed depends on what has been played.

10 letter words can be downloaded from http://www.morewords.com/wordsbylength/ (will require 26 individual downloads of words beginning with A throught to Z)

Experts will submit their programs for other participating experts to run and to comment on / judge. Details to follow in a later comment - Ideas are welcome.

Code and comments can be posted any time.

The deadline for submitting programs is THREE days before the end of the month (to allow for judging). For this month, the deadline is midnight of 28 October.

The expert judged to have submitted the best program will receive points AND will set the next question. The deadline for setting the next quetion is midnight on the SEVENTH day of each month.

If an expert fails to set a question by this time, or decides to pass then it will be open for experts to decide who submits the next question. (Details will follow in a later post. Ideas are welcome).

RUles and conditions may well be fine-tuned as time goes on. Ideas are welcome.

Questions about this task can be posted in this thread at any time... for all or anyone to comment on.

FINALLY

To make it easy for all experts to run your code, confine your batch file AND any external files to a single directory. For example:

   C:\EE\########\author\

where:

   '########' is the EE ID question number.
   'author' is your EE username (ie, paultomasi, billprew, dragon-it etc...)

Sub-directories may exist below (inside) this directory if required. Suggestions for naming conventions are:

   C:\EE\########\author\TEMP
   C:\EE\########\author\SOURCE
   C:\EE\########\author\DESTINATION
   etc...

All sub-directories must be created by your program.

Your batch file will reside in 'C:\EE\########\author\' and calls to sub-directories and files will be relative to this location.

Dummy files can be created using:

   COPY NUL filename.extension >NUL

Any files needed to make your batch file run must also be submitted by you.

ALL FILES TO BE PLACED INSIDE A .ZIP FILE.

Basically, it should be as simple as just opening your .ZIP file and dragging your program etc into the 'C:\EE\########\author\ folder' and running the main batch file.  Please keep names short ie, for this assignment: HANGMAM.BAT will do.

Other details will be posted as and when. All ideas are welcome.

These instructions are bound to be fine-tuned as we progress.... It's early days, this is our FIRST challenge and there's bound to be teethig problems...

Good luck.

Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

hmm, i wonder when a question gets triggered as 'neglected' = 2800 points :-)

You must have way too much time on you hands Paul!!  Sounds like quite a challenge there to do in bitch, but I bet there will be several appearing any how.

I couldnt work out your puzzle question either!

steve
Avatar of Paul Tomasi

ASKER

Steve

The puzzle question is pure genius...!! Believe me, when the solution is revealed you will be ABSOLUTELY amazed....

Too much time on my hands?.... No, not enough questions in this zone....

Also, think about it.... what better way of bumping up our points than to set each other questions....

But that's not the real reason.... It's mostly for fun and for a way to be creative and to express our ideas.

Anyway, I haven't started mine yet.... Will post back tonight....
hmm.. i will wait for the answer, i think Renge will come up with something for sure. All the best RenGee.
So this is a good challenge... I THINK I could do it... and eventually, I may well try... unfortunately, right now, I think this will take at least 30 - 90 minutes and I'm not sure when I'll get to it... (I've had limited time and haven't been on EE much lately) I'm going to stay subscribed and if I can dig up the time, I'll see what I can do.
leew

30-90 minutes sounds really optimistic....

I find breaking it down into modules and concentrating on just one aspect of the task I can focus more clearly. If I'm on the bus, a train, the loo, in the park or just about anywhere, I can whip out a small notebook and work on an algorithm....

It would be very courageous of anyone to attempt to complete the task in a single sitting or even a single day. That's NOT what this task is about.
Maybe I underestimate it... or missed a key part or two... reading it, I could generally picture how everything would work... so I thought a "beta" would be done in 30-45 minutes and then 45-60 of debugging.

With your subsequent comment, I now feel I'm in the reverse position of what my friend and colleague once told our boss - Our boss wanted a calendaring system for our company... my friend John said "Lee and I can build it in a day"... (using ASP and SQL).  Well, that was at 2pm or so in the afternoon.  By 6am we walked out of the office - past our boss coming in for the day - and had the basic system in place... it needed weeks of tweaks and adjustments as a more defined set of requirements became more detailed... but it was basically functional in a day.

(And when we were done, it remained in use for about 6-7 years with no further modification from us (one of those things I'm most proud of, programmatically speaking).
TECHNICAL BITS

I downloaded all 20,405 10-letter words from http://www.morewords.com/wordsbylength/ - 26 seperate downloads (see attached file).

No additional processing was required. All words are saved in a single flat file named 10LETTERWORDS.TXT.



10LETTERWORDS.TXT
TECHNICAL BITS

Pulling a random 10-letter word from 10LETTERWORDS.TXT is not as straight forward as one might first think it is....

Speed could be a problem...
are you saying you are required to use the 10letterwords.txt?
TECHNICAL BITS

Just noticed there are 20,404 words not 20,405. There was a blank line at line 12718.

See attached updated file.

Apologies!

10LETTERWORDS.TXT
Paul,

Speed seems OK to me.... why would it be slow?  Method I used was fractions of a second to return a specific line.

Steve
5g6tdcv4

You can if you want to or you can pre-process the file in any way you think will help your program.

The only proviso is is that the FULL list of 20404 words must be available to your program.

The challenge here is:

   1) how do you select a word at random
   2) how do you address the issue of speed (or delay) or is this not a worry
   3) how do you organise or pre-process your files (ie, a single flat text file etc...)

to name just a few early concerns....
 
So are we supposed to share code as we go along or come up with a solution ll in one?
Selecting a word at random is easy.  Speed... not sure...
23:32:12.83
25620 is too big, redoing
The word to find is nonlegumes from line 11751
23:32:12.88
Steve (dragon-it)

There could be a small delay generating a random word due to the number of words in the word-pool (20,404).

Fractions of a second, eh?.... Sounds like we might be using the same method...
A fairly obvious one I'd say Paul!
Steve (dragon-it)

Sharing code is good....


Leew

What method are you using leew?...


Steve (dragon-it)

That's pretty fast. What's inside your box? Mine's only a AMD 2-core Athlon 250
 
Steve (dragon-it)

I take it you're using %RANDOM%....
i3-2100 3.1GHz, 6Gb, Win 7 64-bit .... bit better than the 10 year old P4 2.4Ghz, 1Gb RAM Win2000 I've been using until eventually got fed up with it!

roughly.... %Random%, find /n, find.
which considering it was £280 quid I thought pretty good spec!
Well this is as far as I've got.... and likely to get for the time being.  Postman Pat ringing away in my ears as #3 refuses to sleep and early wake up in the morn.  Interested to see what else anyone comes up with.
@echo off
setlocal enabledelayedexpansion

call :configure
call :setupwordlist

call :getrandom
call :getword "%linenum%"
  echo The word to find is %Word% from line %linenum%



exit /b

REM **************************
REM Returns random no. 1-20405
REM into variable LineNum
REM **************************

:getrandom
  set linenum=%random%
  if %linenum% GTR 20405 (
    echo %linenum% is too big, redoing
    goto :getrandom
  )
exit /b

REM **************************
REM Returns word from the line
REM specified on call to Word
REM **************************

:getword
  set Word=
  for /f "tokens=2 delims=]" %%A in ('find "[%~1]" %NumWords%') do set word=%%A
exit /b


REM **************************
REM General subs and functions
REM **************************

:configure
  set FullWords="10letterwords.txt"
  set NumWords="10letters.txt"
exit /b

:setupwordlist
  find /n /v "###" %FullWords% > %NumWords%
exit /b

Open in new window

Anyone seen how many there are on a google btw :-)

e.g. http://screwthelotofyou.webs.com/files/Hangman2
This is what I mean... conceptually, I see what I'd be doing - even played around a bit...

yes, I'd be using %RANDOM% to get random numbers and then they would correspond to the word number.

But I'm getting some odd behavior that's me probably just doing something stupid and I don't have any more time to debug.
Wow!! Didn't even stop to think this might already have been done in batch language...

Well, let's hope we submit SOME original code....
TECHNICAL BITS

The obvious choice is to use %RANDOM%.

It would be neater to generate a number from 1 to 20404 say, something like this:
set /a rnd=%random% %% 20404 +1

Open in new window


Then, use that number to grab your word from your word list
Haven't actually looked at the code....but the guy has done all sorts :-)
TECHNICAL BITS

Steve

I note you're using a pre-processed (ie, pre-inexed) file... Just what I had in mind too.

In my case I have:

   n:w

where n is the index number (1 - 20404) and w is a 10-letter word

My word extraction looks like this:
for /f "tokens=2 delims=:" %%a in ('findstr /b "%index%:" 10letterwords.txt') do (

Open in new window

The file is (slightly) smaller than using 2 delimeters and a space. Using just 1 delimeter saves 40KB.


Steve, I'm not going to look at his code (yet)... I'm sure it's the dog's bollox (or should that be the mutt's nuts?).

At the moment, I'm more interested in OUR code.

We'll all favour different ways of tackling this I'm sure...

BTW, personally I'm NOT concerned about fancy screen presentation - the focus should be on logic, fucntionality, validation, clarity, design, style, ingenuity, use of DOS and the filesystem etc...
Well I've got this running so far.... on account of being up still at 3am :-(
Hangman by Stephen Knight (dragon-it) for EE question 27387453

Round 1

Press letter keys, or 9 to have a full guess

[1] ___a______    (already tried _ A)
[2] ___a______    (already tried _ A E)
[3] _o_a______    (already tried _ A E O)
[4] _o_a_i_i__    (already tried _ A E O I)
You already tried A
[4] _o_a_i_i__    (already tried _ A E O I)
[5] _o_a_isi__    (already tried _ A E O I S)
[6] _o_a_isi__    (already tried _ A E O I S R)
[7] _o_a_isi__    (already tried _ A E O I S R B)
[8] _o_a_isi__    (already tried _ A E O I S R B P)
[9] _o_a_isi_g    (already tried _ A E O I S R B P G)
[10] _o_a_isi_g    (already tried _ A E O I S R B P G C)
[11] _o_alisi_g    (already tried _ A E O I S R B P G C L)
[12] _o_alising    (already tried _ A E O I S R B P G C L N)
You already tried C
[12] _o_alising    (already tried _ A E O I S R B P G C L N)
[13] _o_alising    (already tried _ A E O I S R B P G C L N D)
[14] _o_alising    (already tried _ A E O I S R B P G C L N D F)
You already tried G
[14] _o_alising    (already tried _ A E O I S R B P G C L N D F)
[15] _o_alising    (already tried _ A E O I S R B P G C L N D F J)

Time up.  Only 15 allowed.  The word was totalising

Press any key to continue . . .

Open in new window

Steve

Nice to see you've got the 'letters used' thing working.

By the way, the criteria called for 10 lives... A life is lost if you incorrectly guess a letter or a word.

If you duplicate a guess (letter or word) you don't lose another life - but a short polite message might serve to handle this event.

The game ends when:

   1) entered a letter which completes the word
   2) last life left, entered a letter & word still NOT completed
   3) entered a 10-letter word which correctly guesses the word
   4) last life left, entered a 10-letter word & word not guessed
   5) enter nothing - confirm user wants to quit (Y/N) & quit

Anything else you enter is ignored or output short polite message.

Hope that makes it clearer.
Yes, some of the criteria are a bit of a pain... not least the fact that the words in the file are in lower case and the "requirement" is for upper case ones... and the requirement to have the guesses etc. in lower case.

Could easily solve this by processing the file etc. but I don't think it loses anything by being the other way around.

15 lives was just my testing... to give me slight chance of finding the word... have you actually tried guessing some of those obscure 10 letter words!?

#1, #2, #3, #4, #5 working, though not exactly as your plan...
Would you prefer it if case was not a criteria? Only, case imposes the use of a couple of functions.

I haven't tried guessing any myself (I haven't got a working program yet) but I see some words I've never heared of.
Well after a rough night of little sleep it gave me something to try and keep me awake.... so I've got one built here.... not strictly correct since it doesn't show the selected letters in lower case... but I thought that looked a bit messy?

It just needs the words file which is included in the zip.

Steve         ExampleRun1.txt ExampleRun2.txt 27387453.zip
Oops, sorry Steve....

Just run your code and got a continuous scrolling error:

[0] __________ [Lives:10. Tried:  ]
'choice' is not recognized as an internal or external command,
operable program or batch file.
You already tried


FYI, I'm running XP Pro.

'VER'='Microsoft Windows XP [Version 5.1.2600]'

'HELP /?' doen't list 'CHOICE' as one of DOS' commands.
Arse... is there on Windows Vista, 7 machines natively.... and the Server 2003 I normally end up scripting for... and think it is in the resource kits on XP but forgot wasn't native :-(

Can soon copy from another OS if that is acceptable?

e.g. this is the one from Server 2003:
www.dragon-it.co.uk/files/2003-choice.exe

Drop it in the path or in the same dir as the batch and call it choice.exe

Steve
Avatar of Bill Prew
Bill Prew

Here's the basic shell I got working yesterday afternoon.  Was going to wait until it was more polished to post, but since we seem to be in open source collaboration mode, here it is.

 hangman.bat.txt words.txt
billprew

'Guesses reamining' should not count down if user chooses corrent letter in word.

Also, I guess displaying NEWWORD is for debug purposes (?)

Hmmm... 'Letters guessed' appends EVERY guess - even if duplicate or different case.

NOTE: Do you think it would be better to declare the use of uppercase letters throughout? It might add clarity to the program's logic... What's your opinion and is it too late to specify that at this stage?
Steve

like your layout eg...

  [8] S__TI_I_E_ [Lives:2. Tried:  EAITSNRV]

however, 'Lives' should NOT decrease if a correct letter is guessed. Lives ONLY deplete for wrong guesses (letters or words).

Ahh OK.  I see so it is not that you have 10 guesses then altogether, just 10 wrong guesses.... of course, durgh! hangman.1.21.cmd
Hangman by Stephen Knight (dragon-it) for EE question 27387453        ______
Version 1.21                                                          |    |
                                                                      |    O
Round 02                                                              |   \|/
                                                                      |    |
Press letter keys, 1 to quit, or 9 to have a full guess               |   / \
                                                                      |_______
[1] ______A___ [Lives:10. Tried:  A]
[2] __E___A_E_ [Lives:10. Tried:  AE]
[3] __E___A_E_ [Lives:9. Tried:  AEO]
[4] __E___A_E_ [Lives:8. Tried:  AEOU]
[5] __E___A_E_ [Lives:7. Tried:  AEOUS]
[6] __E___ATE_ [Lives:7. Tried:  AEOUST]
[7] __E_R_ATE_ [Lives:7. Tried:  AEOUSTR]
[8] __EBR_ATE_ [Lives:7. Tried:  AEOUSTRB]
[9] __EBR_ATE_ [Lives:6. Tried:  AEOUSTRBC]
You already tried E
[9] __EBR_ATE_ [Lives:6. Tried:  AEOUSTRBC]
[10] __EBR_ATE_ [Lives:5. Tried:  AEOUSTRBCL]
You already tried O
[10] __EBR_ATE_ [Lives:5. Tried:  AEOUSTRBCL]
[11] __EBR_ATE_ [Lives:4. Tried:  AEOUSTRBCLV]
[12] __EBR_ATE_ [Lives:3. Tried:  AEOUSTRBCLVM]
[13] _NEBR_ATE_ [Lives:3. Tried:  AEOUSTRBCLVMN]
You already tried A
[13] _NEBR_ATE_ [Lives:3. Tried:  AEOUSTRBCLVMN]
[14] INEBRIATE_ [Lives:3. Tried:  AEOUSTRBCLVMNI]
[15] INEBRIATED [Lives:3. Tried:  AEOUSTRBCLVMNID]

===========================================================================

You got it  The word was INEBRIATED

Overall score: 0.  This game: 0

===========================================================================


Continue to the next round? [Y/N]

Open in new window

Oops, that broke the scoring since it relied on "turns" rather than "lives".....  hangman.1.22.cmd
@paultomasi

==> 'Guesses reamining' should not count down if user chooses corrent letter in word.

Ah, guess I should have known that (don't play hangman much :-) )

==> Also, I guess displaying NEWWORD is for debug purposes (?)

Correct, purely for testing.

==> Hmmm... 'Letters guessed' appends EVERY guess - even if duplicate or different case.

Yes, I figure since we're showing prior guesses each time then if the player is stupid enough to try the same letter they should lose a turn.

==> NOTE: Do you think it would be better to declare the use of uppercase letters throughout? It might ==> add clarity to the program's logic... What's your opinion and is it too late to specify that at this
==> stage?

Might not hurt I guess.

~bp
TECHNICAL BITS

Case-sensitivity requirement is trivial. I would suggest keeping everything in just one case (uppercase or lowercase - whichever you decide for your program).

If you decide to use uppercase, then you may convert the contents of 10LETTERWORDS.TXT to uppercase too if you so wish to do so.

The ONLY proviso here is that when a player enters a letter or text, it is validated, and if necessary, converted to your chosen case before moving on.
Steve, I actually had fun playing 3 rounds of your game...
Okay, I've given this a little thought (not actually started coding yet)...

I'm going to incorporate (in my own program) the ability to continue from where a user quits with the option of starting from new.

My game is going to be file-based.

I haven't sketched a flowchart yet so I'm unsure about how I'm going to tackle each process at this early stage.

Steve (dragon-it) and billprew, you're way ahead of me at the moment...

Also, it would be nice to see something from subhashchy, ReneGe, leew and 5g6tdcv4.
SOLUTION
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hey guys, I just ran into Paul's journey.
Working lots of hours. Will look at it soon!!

Cheers to you all,
Rene
Just to let you guys know I've looked at both dragon-it's and billprew's code so far.

I'm hoping there will be other submissions, including my own (when I can get around to focus on this). This is why I allowed a month to tackle this question.

Some of the areas I will be paying close attention to when judging submissions are:

   Presentation of code

   Style of code

   Modularity

   Use of variables

   Use of DOS

   Clarity (easy to follow through code and understand what's going on)

   Program logic / program flow

   How each step of the program is approached and solved

   Data flow

   Validation

   How closely it meets the criteria set out in the question

   Functionality

   Optimisation (code and execution)

   User-friendliness

As this is a DOS text-based program I am not expecting any fancy graphics as this might impede the clarity of your code however, you should aim for 'neatness' and 'consistency'.

The aim of this task is to demonstrate your EXPERTISE as an all-round developer (analysis, design and implementation and skills in coding).

This task provides us the opportunity to be 'creative' and 'technically expressive'. It also provides us with an opportunity to show off our best efforts as craftspeople.

The question I will be asking myself throughout is, "[i]Am I satisfied this is the best[/i] I can do?"

Time remaining: 14 days.

Happy coding, Experts !!
So where is yours Paul :-)
Good question....

I started putting some ideas together ie, decided to make it file-based and how I'd implement generating a random word.

I'm aware in the back of my mind there's still over a week to go...

Will look at it after gym (tis my first session today)...
2 days Paul :-)
I know... and I've got NOTHING to offer.

The kids are off school and I'm struggling to snatch a momemt or two on the PC.

Will try to post a few ideas tomorrow when my kid's in bed.

:)
BTW dragon just looking at your script has taught me much.......very nice work. I will not be submitting anything due to time constraints and the fact that Dragon has already won the points....IMHO.
Unless Paul can pull the rabbit out of the hat.....:-)
I know the feeling.... snatched two days working this week, son's 2nd birthday too....  what you need is a rubbish night being stuck up all night and bored for something to do like I was!
I'm not after the points... I'm giving them!

What I'm after is an opportunity for us experts to show off our skills...

Give me a moment and I'll provide you with a relevent example... but I don't think there'll be any rabbits on this occasion though!

Very nice work Steve !!
Currently working on an other approch. I dont expect it to be as complete as Steve, but will do my current best.
Here is my displaying strategy.

Will continue another time.

Cheers,
Rene
@ECHO OFF

SETLOCAL EnableDelayedExpansion

CALL :Header
CALL :Footer
SET Body.1=Here is where the game logic will be displayed
CALL :Man0
CALL :Display
PAUSE
EXIT

:Display
FOR /F "tokens=2 delims==" %%A IN ('SET Header.') DO IF %%A EQU crlf (ECHO.) ELSE (ECHO %%A)
FOR /F "tokens=1,2 delims==" %%A IN ('SET Body.') DO (
	IF %%B EQU crlf (ECHO.) ELSE (ECHO %%B)
	SET %%A=
)
FOR /F "tokens=2 delims==" %%A IN ('SET Hangman.') DO IF %%A EQU crlf (ECHO.) ELSE (ECHO %%A)
FOR /F "tokens=2 delims==" %%A IN ('SET Footer.') DO IF %%A EQU crlf (ECHO.) ELSE (ECHO %%A)


EXIT /b

:Header
SET Header.01=Hangman By ReneGe v1.01
SET Header.02=For EE question 27387453
SET Header.03=-------------------------
SET Header.04=crlf
EXIT /b

:Footer
SET Footer.01=crlf
SET Footer.02=Please enter a letter
EXIT /b

:Man0
SET HangMan.1=______
SET HangMan.2=^|    ^|
SET HangMan.3=^|    O
SET HangMan.4=^|   \^|/
SET HangMan.5=^|    ^|
SET HangMan.6=^|   / \
SET HangMan.7=^|_______
EXIT /b

:Man1
SET HangMan.1=______
SET HangMan.2=^|    ^|
SET HangMan.3=^|    O
SET HangMan.4=^|   \^|/
SET HangMan.5=^|    ^|
SET HangMan.6=^|   /
SET HangMan.7=^|_______
exit /b

:Man2
SET HangMan.1=______
SET HangMan.2=^|    ^|
SET HangMan.3=^|    O
SET HangMan.4=^|   \^|/
SET HangMan.5=^|    ^|
SET HangMan.6=^|   
SET HangMan.7=^|_______
exit /b

:Man3
SET HangMan.1=______
SET HangMan.2=^|    ^|
SET HangMan.3=^|    O
SET HangMan.4=^|   \^|
SET HangMan.5=^|    ^|
SET HangMan.6=^|   
SET HangMan.7=^|_______
exit /b

:Man4
SET HangMan.1=______
SET HangMan.2=^|    ^|
SET HangMan.3=^|    O
SET HangMan.4=^|    ^|
SET HangMan.5=^|    ^|
SET HangMan.6=^|   
SET HangMan.7=^|_______
exit /b

:Man5
SET HangMan.1=______
SET HangMan.2=^|    ^|
SET HangMan.3=^|    O
SET HangMan.4=^|
SET HangMan.5=^|
SET HangMan.6=^|   
SET HangMan.7=^|_______
exit /b

:Man6
SET HangMan.1=______
SET HangMan.2=^|    ^|
SET HangMan.3=^|
SET HangMan.4=^|
SET HangMan.5=^|
SET HangMan.6=^|   
SET HangMan.7=^|_______
exit /b

:Man7
SET HangMan.1=______
SET HangMan.2=^|
SET HangMan.3=^|
SET HangMan.4=^|
SET HangMan.5=^|
SET HangMan.6=^|   
SET HangMan.7=^|_______
exit /b

:Man8
SET HangMan.1=crlf
SET HangMan.2=^|
SET HangMan.3=^|
SET HangMan.4=^|
SET HangMan.5=^|
SET HangMan.6=^|   
SET HangMan.7=^|_______
exit /b

:Man9
SET HangMan.1=crlf
SET HangMan.2=crlf
SET HangMan.3=crlf
SET HangMan.4=crlf
SET HangMan.5=crlf
SET HangMan.6=crlf
SET HangMan.7=_______
exit /b

:Man10
SET HangMan.1=crlf
SET HangMan.2=crlf
SET HangMan.3=crlf
SET HangMan.4=crlf
SET HangMan.5=crlf
SET HangMan.6=crlf
SET HangMan.7=crlf
exit /b

Open in new window

@paul

In the header for this question it says:

Socre for each round:
   correctly guessed word:
      lives remaining:
         0: 1pt
         1: 2pts
         2: 3pts
         3: 5pts
         4: 8pts
         5: 13pts
         ::
         10: 89pts (unlikely unless you're psychic or VERY lucky!!)

but shouldn't that actually be:

         0: 1pt
         1: 2pts
         2: 3pts
         3: 5pts
         4: 8pts
         5: 13pts
         6: 21
         7: 34
         8: 55
         9: 89
         10: 144

~bp
Actually I guess it's maybe more accurately represented as this:

         1: 1pt
         2: 2pts
         3: 3pts
         4: 5pts
         5: 8pts
         6: 13pts
         7: 21
         8: 34
         9: 55
        10: 89

~bp
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
billprew, and all...

You're absolutely right. It is meant to be:

         1: 1pt
         2: 2pts
         3: 3pts
         4: 5pts
         5: 8pts
         6: 13pts
         7: 21
         8: 34
         9: 55
        10: 89

(Obviously, if there are no lives left ie, lives=0, then the game is clearly over).

Has anyone actually found a word come up in that list that you can guess before about 7 letters have come up.... some are so obscure I've had 9 letters and still not known what it was!

Steve
Me, but I was purely lucky!! On all the letters, I failed only 3 and guess what, I had no clue what that word ment!!
So, when does this question "close", wondering if I have time for another enhancement...

~bp
bp

Go for it...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great to see another hat in the ring QCubed, will take a look at that more tomorrow, getting late here.  Travel safe, be happy.

My approach also should handle various length words, I though like you did that was useful.

I was going to try and add a bit more to mine but at this point I think I'll let it stand where it is.

Like a good drive, the joy is in the journey, not the destination.

~bp
Just an FYI:  I was pretty tired when I wrote my batch, and the last thing I did was the part where it stops the used letters from displaying.

I was obviously not thinking strait, and it kept pecking at the back of my brain while I was going over the Tappan See Bridge!


Stupidly I used A FOR Loop to set the list of Available Letters to show Used ones as an underscore!

The Offending code goes something like this:

FOR %%A IN (%LetterList%) DO ECHO %%A|FIND /I "%TGuess:~0,1%"  >NIL && (SET G%%A=_"&GOTO :EOF )

Obviously this can be greatly simplified to this command instead:

SET "G%TGuess:~0,1%=_"

Not only is that code far more simple, it will save the long delay caused by the FOR Loop at that spot.

(My apologies for undoubted errors and omissions in the code of this post, I'm still in the midst of my Trek to Maryland, and it's taken two hours to post this via the phone due to needing to manually rout around traffic snarls on the other phone using google maps traffic view..

-Q
Hey Bill,

  Good to hear from you!  Thanks for the kind words, I figure you would also write the more general-use code which would allow for the words of any length as well!

  I look forward to reading through your code for this as well when I get the chance, I know from experience you write some pretty elegant stuff!!

  However I don't expect I'm in the running considering I wrote the script. In a four (4) hour quick run, after skimming the requirements.

  For Example, these are the deficiencies I Already know are present in the code after reskimming before conceding and posting:

A) I do not explicitly list the letters used, I only explicitly list the letters unused and replace the used ones with an underscore.

B) I did not abide by the requirements for different cases for different parts of the output.

C) I did not count guesses against the user.

D) I did count correct letter guesses against the user.

E) I did not notice the requirement to do 10 rounds and give statistics to the user.  (The script let's you play 1 to infinite Games, with stats displaying furring gameplay only.)

F) I did not have time to implement the scoring element, its strictly a pass/fail approach. (I was going to implement scoring and realized that there was at least a couple more hours work left because of the other items, and that It was 10:45 is and was very late to get on the road!"

G?) I'm not sure if this last one was strictly nessessary:  I do all my work without writing any files what so ever..  I'm sure that there was a legitimate reason for requesting the file writes, but, I have a strong habit of avoiding filewrites at all..

Still it does do a fair bit though it most certainly could be tightened up quite a bit  (I've already thought of a few other improvements to my code while writing this response)

What it DOES Do is:

1) Select 1 word at random from the file.

2) Print out a status & guess accepting screen.

3) Tracks and diUsed verses Max guesses of letters

4) Tracks and displays # of guesses

5) Updates the Underscores to reveal the letters of the word as they are guessed

6) Updates the Alphabet list to change unused letters into underscores.

7) Displays status messagesto the user regarding their guesses (Without changing the size of the display area).

8) Ends the game with Win or Lose Dialog which let's the user know what the word actually was

9) Asks the user if they would like to play another round, and resets picking a new word if they do.

10)  Care was given to avoid storing the word or the random number used to find the word, in a system variable longer than nessessary to minimize the chances of cheating.

I do hope that is enough at least to get it looked at.

I should note, per my usual practices, I avoided using delayed expansion; which likely makes some of the code a bit archaic.

-Q

Another late runner then....sounds good and will pick through and nick bits of code for future ;)

Have you got there yet or still on the road, I'm not very good with the geography of the US and distances involved.... i know we (well I with Jo in the car...) drove back from the south of France to the English midlands in one go which was a little tiring shall we say... But then at the moment I can't drive until May after diagnosis of epilepsy so driving to Cornwall (250 miles) with my wife driving and 3 kids in the back took us about 8 hours...

Steve

Steve
Hey Steve,

  I'm nearly to Maryland, combing From New York, right now I'm at a rest-stop in Delaware that is about an hour from my destination.  It's about 250 miles from NY to MD.  But only takes about 5 hours give or take an your depending on pit stops and/or traffic.

All this posting on here has really helped the time fly by though!  =)

-Ben
Ben... I get this... like it can't find the words.dat file, but it IS there and renaming it then it complains with your check for the file being there OK.

Haven't checked through the logic yet so might be something silly Win7 related but would give you something to ponder in the final bit of journey!!

Wouldn't advise booting up laptop onto EE as soon as you get see GF though...

Steve


angMan: By QCubed

===============================================================================


ou Have Tried 0 of  Letters.
ou Have Made 0 Guesses.

etters Which Remain:
-------------------------------------------------------------------------------

 - A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -
-------------------------------------------------------------------------------


he Word you are trying to Match is 1 Long: "_"

===============================================================================





lease Input a Letter or a Guess:

Open in new window

OK, is spaces in path issue.... I always do my EE stuff from a root folder path with spaces in so I don't get caught (when I actually test and not just type in...) by that bit!

FOR /F "Skip=%WordLine% Tokens=*" %%W IN (%~dp0Words.dat) DO Call :Start-Main "%%W"&GOTO :Start-End-Game

FOR /F "usebackq Skip=%WordLine% Tokens=*" %%W IN ("%~dp0Words.dat") DO Call :Start-Main "%%W"&GOTO :Start-End-Game

Has run through OK after that by the looks, was able to guess a word etc. though when I completed all the letters I got this:

Steve
HangMan: By QCubed

================================================================================


You Have Tried 8 of  Letters.
You Have Made 2 Guesses.

Letters Which Remain:
--------------------------------------------------------------------------------

  - _ B C D _ _ G H _ J K L _ _ O P Q _ S _ U V W X Y Z -
--------------------------------------------------------------------------------


The Word you are trying to Match is 11 Long: "freemartin"

================================================================================


 Your Guess Was Incorrect! Try again!


Please Input a Letter or a Guess:

Open in new window

QCubed

Nice to see a late addition.

You fear you didn't implementing much however, I'm confident there's enough there to be considered for points...


billprew

I was hoping to see your 'other enhancement'...
@paultomasi

Ran out of time Paul, been a hectic week in the office.  I had fun working up what I submitted, I think I'll be happy with that for now and let the chips fall where they may.  Still need to make time to go through some of the other submissions more closely, always things to be learned I'm sure.

~bp
UPDATE

Just a note to let you all know I'll be looking at your submissions over the next 2 days or so.
billprew

I'm having problems with the CHOICE command in your program.

I'm running XP Pro 5.1.2600
@paultomasi

==> I'm having problems with the CHOICE command in your program.

This seems to have been in and out of MS-DOS on and off, starting in DOS 6.22.  Are you having trouble because the command does not exist on your system, in which case you can download a copy from a few places online, for example in prior post 36942035 in this thread, or http://www.dynawell.com/download/reskit/microsoft/win2000/choice.zip). Or do you have the command and some options not working properly?

Since no Windows version was specified I developed and tested on the current version, Windows 7, where Choice is a native command.

~bp
With regard to choice.exe, I am using the newer (current) syntax of the command, so this link is a version that supports that.

www.dragon-it.co.uk/files/2003-choice.exe


~bp
Yep, that's the one!
So, what's the verdict here Paul?

~bp
billprew & ALL

Please note I am currently looking at your code(s) (bits on a daily basis), analysing each line, each module, each program.

Admittedly, I didn't realise this process would take this long.

And, unfortunately, I'm hampered by personal problems on the home-front which will settle towards the end of the week. I will provide positive feedback soon afterwards.

All I ask is that you all bear with me in the meantime.

Thank you.
No problem Paul, honestly, I too still want to spend more time in some of the contributed code.

~bp
That's not a real chalenge, (less then 5 minutes) you should had limit it to use BAT files only :-)
@murphey2 - It took me much longer than 5 mins just to read and digest Paul's question :-)

Anyway they do, no VBScript, no nothing.  OK mine uses choice.exe (which available on Windows 7 I was using it on and various other windows / resource kits), and find - standard command since early MS-DOS but that's it: http:#36947012  Don't think the other's use anything either.

Steve
Murphey2

>> That's not a real chalenge...

What do you mean, not a real challenge? Are you refering to the task?...
Merry Christmas and all that.... maybe some time to close this off over Christmas break (well I am told SOME people get to have a break!)

Steve
Just to let you all know, I'm still looking at this question from time-to-time and as time permits...

I have lots of other 'fun' challenges but I'll need to focus more c;osely next time around so that it doesn't get dragged out as long as this one has been.

Paul,

Are you ever going to close this question?  If you don't have time to digest it fully just award some points and lets move on, no point letting it sit out here...

~bp
yes.... what's that 10 days short of a year?

Steve
agreed, we all get busy, but the question will be catagorized as abandoned and there is some good code here.
Gonna be closing this real soon now.

2 seperate hard drive failures and one total system failure (taking 3 months to recover from) has put me behind on everything...

I'm gradually inching my way to bringing this to a conclusion.
Just seen the hangman shortcut in my EE directory.... Had any time to look back at this recently Paul?
I comment, can i get points?
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
Personally I'd stay to split them..... obviously I like my solution but the only other two I think were.... Paul has been away from EE for a while I think but maybe can come back and comment now!

Billprew - http:#aa37040222
QCubed - http:#a37048575
dragon-it - http:#a36947012 

Steve

[Edit]: It said in my comment question was to be deleted but now it like might have just been closed with 0 points, don't mind about the points just don't delete it!
I agree with Steve.
I will review this question during the next 36 hours....
I've kept thinking about this question off and on over the years.

Part of me would really like to ask this Q again to see what we'd all create, but I actually want to finish and submit new code for it if it were asked again, so perhaps that's what keeps me from posting it as a Q I'd have to moderate ^^.

I remember seeing the notices coming in over the years and even though it was sort of frustrating it was nice to see others thought on this Q as much as I did.

 If a similar Q ever gets asked please PM me about it as I really enjoyed being part of this one. :)
Careful what you wish for, Paul might hear you :-).

This question was a lot of fun, remember it well, and the folks that participated...


»bp
It's been a while guys!  I'm also up for a new one as well!
Cheers :)
Well I'll have a go....