comp.lang.ada
 help / color / mirror / Atom feed
* I need advice please on this Ada95 hangman game
@ 2000-12-30 16:30 Mark Pagdin
  2000-12-30 17:12 ` Bruce or Tracy
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Mark Pagdin @ 2000-12-30 16:30 UTC (permalink / raw)


Hi

I hope you had a nice Christmas! I am looking for your help and advice. I am
a student at university in England and have just started learning to use Ada
95. This is my first programming language and obviously I am finding it hard
to learn it. However I have been set a project to create a program to play
hangman (a word game).

I have been working hard to create this and am slowly getting there. However
I am stuck on the main procedure which searches for the letter in the hidden
word and then display any correct letters.

Here is the output I get when i run the program (the word is revealed at the
moment for testing purposes):

Enter a word to test the Hangman game
mark2
Enter a Leter
m
m_ _ _ _ Enter a Leter
a
_ a_ _ _ Enter a Leter
r
_ _ r_ _ Enter a Leter
k
_ _ _ k_ Enter a Leter
2
_ _ _ _ 2Enter a Leter

Please would it be possible for anyone to point out a way of storing each
attempt so that when the player attempts to guess again the program is able
to store the result from the previous guess.


Please I don't want to cheat i.e. I only want you to give me hints not do it
for me.

Thank you,

Mark Pagdin





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: I need advice please on this Ada95 hangman game
  2000-12-30 16:30 I need advice please on this Ada95 hangman game Mark Pagdin
@ 2000-12-30 17:12 ` Bruce or Tracy
  2000-12-30 17:53   ` Ted Dennison
  2000-12-30 17:27 ` Robert Dewar
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Bruce or Tracy @ 2000-12-30 17:12 UTC (permalink / raw)


Done similar things in the past by keeping each keyboard entry in a
linked
list or an array.  Hangman only allows only a certain number of "tries"
before
the man is hanged.  So, that will tell you at what size to constrain
your
array.  After each guess, loop through and up to the number of guess
thus 
far and output it all to the same line (or different line, doesn't
matter).  

The implementation of things like this is easy, but can be tricky if you
aren't on your toes.  

Something even more fun would be to figure out how to make your Ada
program
do some nifty pixel-type graphics.  Here is a good place to start for
that:  

Windex:
   http://users.erols.com/leakstan/Stephe/Ada/windex.html

Have fun,
Bruce

Mark Pagdin wrote:
> 
> Hi
> 
> I hope you had a nice Christmas! I am looking for your help and advice. I am
> a student at university in England and have just started learning to use Ada
> 95. This is my first programming language and obviously I am finding it hard
> to learn it. However I have been set a project to create a program to play
> hangman (a word game).
> 
> I have been working hard to create this and am slowly getting there. However
> I am stuck on the main procedure which searches for the letter in the hidden
> word and then display any correct letters.
> 
> Here is the output I get when i run the program (the word is revealed at the
> moment for testing purposes):
> 
> Enter a word to test the Hangman game
> mark2
> Enter a Leter
> m
> m_ _ _ _ Enter a Leter
> a
> _ a_ _ _ Enter a Leter
> r
> _ _ r_ _ Enter a Leter
> k
> _ _ _ k_ Enter a Leter
> 2
> _ _ _ _ 2Enter a Leter
> 
> Please would it be possible for anyone to point out a way of storing each
> attempt so that when the player attempts to guess again the program is able
> to store the result from the previous guess.
> 
> Please I don't want to cheat i.e. I only want you to give me hints not do it
> for me.
> 
> Thank you,
> 
> Mark Pagdin



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: I need advice please on this Ada95 hangman game
  2000-12-30 16:30 I need advice please on this Ada95 hangman game Mark Pagdin
  2000-12-30 17:12 ` Bruce or Tracy
@ 2000-12-30 17:27 ` Robert Dewar
  2000-12-30 17:31 ` Robert Dewar
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Robert Dewar @ 2000-12-30 17:27 UTC (permalink / raw)


In article <t4s3dn60cip62b@corp.supernews.co.uk>,
  "Mark Pagdin" <mark_pagdin@lineone.net> wrote:
> I only want you to give me hints not do it
> for me.
>
An array and a counter should do this. The answer would be
the same for any language, so there is nothing special about
Ada here.


Sent via Deja.com
http://www.deja.com/



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: I need advice please on this Ada95 hangman game
  2000-12-30 16:30 I need advice please on this Ada95 hangman game Mark Pagdin
  2000-12-30 17:12 ` Bruce or Tracy
  2000-12-30 17:27 ` Robert Dewar
@ 2000-12-30 17:31 ` Robert Dewar
  2000-12-30 17:38 ` Ted Dennison
  2001-01-07  1:16 ` John English
  4 siblings, 0 replies; 8+ messages in thread
From: Robert Dewar @ 2000-12-30 17:31 UTC (permalink / raw)


In article <t4s3dn60cip62b@corp.supernews.co.uk>,
  "Mark Pagdin" <mark_pagdin@lineone.net> wrote:
> Hi
>
> I hope you had a nice Christmas! I am looking for your help
and advice. I am
> a student at university in England and have just started
learning to use Ada
> 95. This is my first programming language and obviously I am
finding it hard
> to learn it.

Well it is not so obvious that you should find it hard :-)
Here is my advice. I think you may be trying to start coding
too early, before you have a real understanding of what
a program is all about. I would recommend spending more
time studying some existing examples, and make sure that
you really really understand them well. You may also find
it helpful to go through one of the online tutorials at
www.adapower.com.

Make sure you study some examples of the use of arrays and
subscripts.

The point here is that you should try to get to the point
where the assignment seems reasonably straightforward. It
is just too difficult for anyone to write any program if
they do not understand things well enough :-)

Good luck!


Sent via Deja.com
http://www.deja.com/



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: I need advice please on this Ada95 hangman game
  2000-12-30 16:30 I need advice please on this Ada95 hangman game Mark Pagdin
                   ` (2 preceding siblings ...)
  2000-12-30 17:31 ` Robert Dewar
@ 2000-12-30 17:38 ` Ted Dennison
  2000-12-31 15:48   ` Marin David Condic
  2001-01-07  1:16 ` John English
  4 siblings, 1 reply; 8+ messages in thread
From: Ted Dennison @ 2000-12-30 17:38 UTC (permalink / raw)


In article <t4s3dn60cip62b@corp.supernews.co.uk>,
  "Mark Pagdin" <mark_pagdin@lineone.net> wrote:

> This is my first programming language and obviously I am finding it
> hard to learn it. However I have been set a project to create a
> program to play hangman (a word game).
...
> Please would it be possible for anyone to point out a way of storing
> each attempt so that when the player attempts to guess again the
> program is able to store the result from the previous guess.
>
> Please I don't want to cheat i.e. I only want you to give me hints not
> do it for me.

I can see several ways of accomplishing that task. Which approach you
take boils down to how you want to encode a "guess", and what data
structure you use to store them all.

Your Ada textbook should have some kind of section listing the data
types that the language makes available (Integers, Enumerations, Record,
Arrays, etc.). My advice is to look through that section, think about
the capabilities of each type, and try to see if any of them would be
helpful to you in the task of storing a series of your users' past
guesses. If you haven't covered them all yet, it would be a pretty good
assumption that your instructor intended you to solve the problem with
the ones you *have* covered, so concentrate on those.

If you get stumped, you should *really* ask your teacher for help.
They'd be the best judge of how big of a hint it would be kosher to give
you. Anyway, that's what you're paying the school all that money for...

--
T.E.D.

http://www.telepath.com/~dennison/Ted/TED.html


Sent via Deja.com
http://www.deja.com/



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: I need advice please on this Ada95 hangman game
  2000-12-30 17:12 ` Bruce or Tracy
@ 2000-12-30 17:53   ` Ted Dennison
  0 siblings, 0 replies; 8+ messages in thread
From: Ted Dennison @ 2000-12-30 17:53 UTC (permalink / raw)


In article <3A4E1799.60B0D126@hiwaay.net>,
  Bruce or Tracy <bljacobs@hiwaay.net> wrote:
> Hangman only allows only a certain number of "tries" before
> the man is hanged.  So, that will tell you at what size to constrain

Hmmm. That's right. Usually it also keeps track of wrong guesses
(separately I assume), so that if the user enters the same wrong guess
twice, that isn't counted against them twice. But there's no sense in
making the poor student put in all these extra features if they aren't
in the actual assignment (execpt perhaps for extra credit).

> Something even more fun would be to figure out how to make your Ada
> program do some nifty pixel-type graphics.  Here is a good place to
> start for that:

Errr...let's let the poor guy get used to simple data structures before
we throw him into Win32 GUI programming, huh? :-)

--
T.E.D.

http://www.telepath.com/~dennison/Ted/TED.html


Sent via Deja.com
http://www.deja.com/



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: I need advice please on this Ada95 hangman game
  2000-12-30 17:38 ` Ted Dennison
@ 2000-12-31 15:48   ` Marin David Condic
  0 siblings, 0 replies; 8+ messages in thread
From: Marin David Condic @ 2000-12-31 15:48 UTC (permalink / raw)


Ted Dennison wrote:

> In article <t4s3dn60cip62b@corp.supernews.co.uk>,
>   "Mark Pagdin" <mark_pagdin@lineone.net> wrote:
>
> > This is my first programming language and obviously I am finding it
> > hard to learn it. However I have been set a project to create a
> > program to play hangman (a word game).
> ...

> I can see several ways of accomplishing that task. Which approach you
> take boils down to how you want to encode a "guess", and what data
> structure you use to store them all.
>

It might help to sort of "visualize" the problem. Picture the game show
"Wheel Of Fortune" (Essentially "hangman" with lots of flashing lights and
prizes.) We have Vanna White turning around letters displayed on a board. On
the screen below are a list of letters that were incorrect guesses. The
board that Ms. White is working at is essentially a blank string that she
fills in with characters if they match some position in the non-visible
string that holds the phrase being guessed. There is yet another string that
is holding characters that were guessed, but didn't match anything in the
invisible phrase.

So basically, what you need is a string that holds the phrase to be guessed.
Then you need a string of identical size that is initially blank to hold the
characters that were correct guesses and is filled in with the guessed
character in the matching position from the key phrase. Finally, you need a
string that holds incorrect guesses where the size of the string is the
maximum number of allowed wrong guesses.

From there, its just a matter of collecting up the guess from the user,
scanning to see if it is in the key phrase and if it is, you put it in the
displayed partial phrase. Otherwise, you put it in the incorrect guess
string. After that - just display the whole mess for the user.

This should be helpful without actually doing the assignment for you. What
you're trying to learn here is how to clearly understand the real world
problem and figure out a way to model that in a computer program. At the
intro-programming course level, you have to first struggle to understand the
mechanics of the programming language and that can be hard enough. But the
ultimate goal is to understand problem solving.

Hope you get it running from here.

MDC
--
======================================================================
Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/
Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m
Visit my web site at:  http://www.mcondic.com/

    "Giving money and power to Government is like giving whiskey
    and car keys to teenage boys."

        --   P. J. O'Rourke
======================================================================





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: I need advice please on this Ada95 hangman game
  2000-12-30 16:30 I need advice please on this Ada95 hangman game Mark Pagdin
                   ` (3 preceding siblings ...)
  2000-12-30 17:38 ` Ted Dennison
@ 2001-01-07  1:16 ` John English
  4 siblings, 0 replies; 8+ messages in thread
From: John English @ 2001-01-07  1:16 UTC (permalink / raw)


Mark Pagdin wrote:
> I hope you had a nice Christmas! I am looking for your help and advice. I am
> a student at university in England

... Brighton possibly? :-)

> and have just started learning to use Ada
> 95. This is my first programming language and obviously I am finding it hard
> to learn it. However I have been set a project to create a program to play
> hangman (a word game).
> 
> I have been working hard to create this and am slowly getting there. However
> I am stuck on the main procedure which searches for the letter in the hidden
> word and then display any correct letters.
> 
> Here is the output I get when i run the program (the word is revealed at the
> moment for testing purposes):
> 
> Enter a word to test the Hangman game
> mark2
> Enter a Leter
> m
> m_ _ _ _ Enter a Leter
> a
> _ a_ _ _ Enter a Leter
> r
> _ _ r_ _ Enter a Leter
> k
> _ _ _ k_ Enter a Leter
> 2
> _ _ _ _ 2Enter a Leter
> 
> Please would it be possible for anyone to point out a way of storing each
> attempt so that when the player attempts to guess again the program is able
> to store the result from the previous guess.

You'll need to post your code (or drop in to my office next week) to
be able to figure this out; you're obviously close to a working
solution,
if that's any consolation...

-----------------------------------------------------------------
 John English              | mailto:je@brighton.ac.uk
 Senior Lecturer           | http://www.comp.it.bton.ac.uk/je
 Dept. of Computing        | ** NON-PROFIT CD FOR CS STUDENTS **
 University of Brighton    |    -- see http://burks.bton.ac.uk
-----------------------------------------------------------------



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2001-01-07  1:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-12-30 16:30 I need advice please on this Ada95 hangman game Mark Pagdin
2000-12-30 17:12 ` Bruce or Tracy
2000-12-30 17:53   ` Ted Dennison
2000-12-30 17:27 ` Robert Dewar
2000-12-30 17:31 ` Robert Dewar
2000-12-30 17:38 ` Ted Dennison
2000-12-31 15:48   ` Marin David Condic
2001-01-07  1:16 ` John English

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox