1. my first application in euphoria: a simple hangman

hi all,
please see http://openeuphoria.org/pastey/117.wc

my first application in euphoria - all suggestions are welcomed!

  • clearer code,
  • library functions i should know about,
  • ways to make it more concise,
  • or other language idioms to learn from

Thanks, Kobi

new topic     » topic index » view message » categorize

2. Re: my first application in euphoria: a simple hangman

kobi said...

hi all,
please see http://openeuphoria.org/pastey/117.wc

my first application in euphoria - all suggestions are welcomed!

  • library functions i should know about,

Hi Kobi,
I must say it's a very good code for being your first program, great work!
One function that you should use there is wait_key http://openeuphoria.org/docs/std_console.html#_942_wait_key , it stops execution until you press something so you can wait for input instead of refreshing constantly.

        keypress = wait_key()  
        -- You can remove the -1 check when using this :) 

Cheers,
Guillermo

new topic     » goto parent     » topic index » view message » categorize

3. Re: my first application in euphoria: a simple hangman

gbonvehi said...
kobi said...

hi all,
please see http://openeuphoria.org/pastey/117.wc

my first application in euphoria - all suggestions are welcomed!

  • library functions i should know about,

Hi Kobi,
I must say it's a very good code for being your first program, great work!
One function that you should use there is wait_key http://openeuphoria.org/docs/std_console.html#_942_wait_key , it stops execution until you press something so you can wait for input instead of refreshing constantly.

        keypress = wait_key()  
        -- You can remove the -1 check when using this :) 

Cheers,
Guillermo

What about maybe_any_key() ?

http://openeuphoria.org/docs/std_console.html#_953_maybe_any_key

new topic     » goto parent     » topic index » view message » categorize

4. Re: my first application in euphoria: a simple hangman

jimcbrown said...

What about maybe_any_key() ?

I think he's getting user input (letters for the hangman game), not just wanting a keypress, so maybe_any_key() wouldn't work.

new topic     » goto parent     » topic index » view message » categorize

5. Re: my first application in euphoria: a simple hangman

euphoric said...
jimcbrown said...

What about maybe_any_key() ?

I think he's getting user input (letters for the hangman game), not just wanting a keypress, so maybe_any_key() wouldn't work.

Ah, you're right.

new topic     » goto parent     » topic index » view message » categorize

6. Re: my first application in euphoria: a simple hangman

Hi Kobi,

Your program is pretty nice. There are a few nitpicks I have:

  • Most hangman games I have seen give 7 to 11 bad guesses. The player is not penalized for correct guesses.
  • Yours gives 20 total (bad and good). Unless one of the letters is in the last 6 of the alphabet (uvwxyz) it is possible to win just by going through the alphabet in order.
  • There is only one puzzle available. It would be better to have a list of words and pick randomly from them.

All in all, it's a good first effort.

Lonny

new topic     » goto parent     » topic index » view message » categorize

7. Re: my first application in euphoria: a simple hangman

gbonvehi said...
kobi said...

hi all,
please see http://openeuphoria.org/pastey/117.wc

my first application in euphoria - all suggestions are welcomed!

  • library functions i should know about,

Hi Kobi,
I must say it's a very good code for being your first program, great work!
One function that you should use there is wait_key http://openeuphoria.org/docs/std_console.html#_942_wait_key , it stops execution until you press something so you can wait for input instead of refreshing constantly.

        keypress = wait_key()  
        -- You can remove the -1 check when using this :) 

Cheers,
Guillermo

Thank you!

your suggestion now removes the flicker, and I only had to move a few lines, for some logic to be evaluated sooner.

I have programmed for a few years in C# and Factor. I find euphoria refreshing and challenging. some languages have such a large surface area, so many libraries and complexity of implementation. Euphoria is so simple and transparent, offering one tool instead of many. (atoms, sequences, and seq manipulations) I enjoy solving/creating with primitives instead of huge libraries. (the basic constructs though are advanced and smart) so I try to become proficient in Euphoria.

Factor is a very good programming language that encourages refactoring, and I may port some functions over to euphoria, the ones that I'll find missing.

new topic     » goto parent     » topic index » view message » categorize

8. Re: my first application in euphoria: a simple hangman

Lnettnay said...

Hi Kobi,

Your program is pretty nice. There are a few nitpicks I have:

  • Most hangman games I have seen give 7 to 11 bad guesses. The player is not penalized for correct guesses.
  • Yours gives 20 total (bad and good). Unless one of the letters is in the last 6 of the alphabet (uvwxyz) it is possible to win just by going through the alphabet in order.
  • There is only one puzzle available. It would be better to have a list of words and pick randomly from them.

All in all, it's a good first effort.

Lonny

Hi, nitpicks are also welcomed :))
thank you - you're absolutely right, I didn't think of good guesses vs. bad guesses.
the program was mainly to evaluate and see how euphoria feels. I was reading and reading, but had to start coding something, too.
Thank you. perhaps a followup will ensue

new topic     » goto parent     » topic index » view message » categorize

9. Re: my first application in euphoria: a simple hangman

kobi said...

nitpicks are also welcomed :))

One tiny thing I spotted:

            65 <= normalized and normalized <= 90 -- within A..Z  

could equally be written as

            normalized >= 'A' and normalized <= 'Z' 

Pete

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu