Coding STEM

Word-Game: “Words Matter!” (Python)

Welcome back! Today, I share a new game idea (I thought of it myself but if there’s any such game out there, it’s a pure coincidence and I did NOT use those as a foundation). Disclaimer and (c): The idea cannot be recreated in any shape or form for any purpose (other than learning/education) without expressed written consent from me (tanman1129@hotmail.com).

Game Idea:

The idea is to offer users (you) a set of letters (scrambled) and so you can make English words out of them. However, the words (and letters presented) entered MUST be relevant to a given  situation. Each situation presents a unique problem, and the words you solve (type in) must address the situation.

Storyline: You’re stranded on a island. You must survive for at least 9 days. On 10th day (if you survived that long), you have a chance to get rescued…and you must guess the right word(s) for each day’s unique situation. If you get rescued, your health score will determine your next chapter in life. If you don’t get rescued, your health score will determine how long you’ll live on the island still…HOWEVER, there’s still a chance to be redeemed and find Utopia. This occurs only when you have guessed the words correctly at least N times (8)…in which case, you’ll find a perfect partner also stranded on the island and live a harmonius, long life together.

Scoring: There are penalties for not guessing in 3 tries, and smaller penalty for hints. There are 4 parameters that define your health/survivability: Hunger, thirst, body temperature, and mental health. After each “day” (virtual day loop), if your overall health is below par (which is a combination of the 4 params, which are independently tracked per situation), you will not survive to see the next day.

Because your fate depends on choosing the right words, I call it “Words Matter!“.

Implementation: 

I decided to write it first in Python just because I was tweaking with the language, and it has solid list manipulation functions. However, I could’ve written it in Scratch, JavaScript, HTML5, C/C++, or Construct (all of which I’ve implemented various apps), etc. The idea is to share the bare-bones code to get you going. If you’re interested in developing a full-fledged game with many levels and cool graphics, please contact me.

Game Play:

Here’s a sample output of a session (just a few days shown here ). Outcome will vary per game session and your inputs (that’s part of the fun).



and fast-forwarding...



The Code:

Since we’re not doing anything too fancy, only 2 libs are needed. Then declare the parameters for tracking health (score).

Then get the user input and display some basic instruction…

Then we enter day 1, day 2,…etc. until day 9. Each day’s logic is essentially same. Day 1’s code is below…

So, repeat same logic for each subsequent day for as long as you want…just change up the letters list, and validation of the correct answers.

On the last day (Day 10), it’s a little different logic than the daily logic. Here I offer you a chance to be rescued and end the game. If the right word is chosen, AND health is up to par, you’re rescued. If you’re NOT rescued, you may live X number of days on the island depending on your health, with another chance as explained in the Storyline section above.

Here’s the code for day 10:

You may notice that there are multiple calls to checkhealth(). This is a function I defined since it’s reused often and implemented as below:

Exercises:

Add engaging graphics and/or animations. Longer story lines. Create a better (but more complex but more scalable) data structure for a day (containing its list of letters, correct answer(s), actions, etc.). Verify against a list of a words database instead of hard-coded checks.

Disclaimer and (c): The idea cannot be recreated in any shape or form for any purpose (other than learning/education) without expressed written consent my me (tanman1129@hotmail.com).

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back To Top