6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Nov 14, 2024 7:12 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Thu Apr 18, 2024 9:48 pm 
Offline

Joined: Fri Jan 21, 2022 8:57 pm
Posts: 4
Hi folks,

I've written a Hangman game in Forth for my Planck 65C02 system. It's written in Tali Forth 2 and also works in Tali running on py65mon and also in gforth. I think it's a fine example of beginner coding. :D Any feedback or suggestions for improvement or for writing more idiomatic Forth would be gratefully accepted.

It's on GitHub here: https://github.com/bjchapm/hangman/

Thanks again to all of you for creating these fantastic software and hardware tools.

Best wishes,

Ben


Top
 Profile  
Reply with quote  
PostPosted: Thu May 16, 2024 6:08 pm 
Offline

Joined: Sun May 13, 2018 5:49 pm
Posts: 255
Hi Ben,

This is an excellent little game. I enjoyed playing it. This should run on most forths that support AT-XY and ANSI escape sequences in the terminal for moving the cursor around.

I think Patrick (pdragon) is looking into adding support for KEY? in Tali2, which would let you get better random numbers by asking the user to press a key and use how long it took to seed your random number generator (rather than using HERE). KEY? is in an optional wordset, though, so your current version is probably a bit more portable.

This doesn't really look like beginner Forth. It just looks like regular Forth and is pretty easy to read and follow.

I see your license is compatible with Tali2's Public Domain license. I'd be happy to accept a pull request to add it to Tali2's forth_examples folder (probably in its own subfolder, so you can include your README.md and LICENSE files without having to worry about filename clashes), or I can add it myself with your permission.


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 29, 2024 11:12 am 
Offline

Joined: Tue Sep 26, 2023 11:09 am
Posts: 105
Yes KEY? was recently added. It needs a kernel_kbhit routine that flags when a key is available. More in the platform README.
As Sam suggested you can use it in a loop to time the keypress as a random seed, e.g. : foo 0 begin 1+ key? until key ;

You might also be interested in the bundled c65 monitor/debugger which is an alternative to py65mon which is about 100x faster and includes heatmap profiling.

BTW, it's a nice full circle moment since it was reading about Planck that originally led me to explore TaliForth!


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 29, 2024 1:08 pm 
Offline

Joined: Wed Jul 24, 2024 1:08 pm
Posts: 1
Hey Ben!
Awesome that you shared your Hangman game! Forth is really interesting language, though not very popular, so it’s nice to see something written in it. Maybe you could add more comments to the code so other beginners can understand your solutions more easily?
By the way, do you have other projects in Forth? :)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: