Project Review: Holiday Roulette

Helping travellers choose their next luxury holiday destination

Summary

Introduction

A game centred on selecting a luxury holiday for the procrastinating traveller that cannot decide on their next destination.

There is a very small 'sleep' between each generated choice. This is a design decision to slow down the code so that the traveller can feel the suspense whilst the roulette wheel determines their fate.

Features

  • Uses a random generator to decide upon a choice for each spin of the roulette wheel where the best of 1000 spins determines the winning location.
  • Logs all of the choices to a log file on the server. This is not accessible to see by the visitor.
  • The visitor can click a link to see the logging, although they will not actually see the log file. Instead, a script runs to read all lines into the Django template. Some formatting is done with the text to give it a fixed width font and authentic feel.
  • The winning location screen includes an image of the actual location just to increase the wanderlust even more. I don't know whether this was a great design choice or not as whilst I was developing this, it just leaves me wanting to travel even more! :)

Objectives

The purpose of the project is to illustrate the implementation of randomised choices and the logging of them using Python's 'logging' module.

The Approach & Solution

The starting point was to consider the logic of the game by thinking of a list of luxury travel destinations. Thankfully, this is an easy task for anyone with travel aspirations, so I picked 12 places where I would personally love to travel to. These are all stored within a dictionary where their values (i.e. their choices counter) is set to zero.

The next part was to use 'choices' from the random module to select a random destination for each iteration of the game's loop.

The running of the code is slowed down in order to build a bit of suspense in the game. It is slowed down by 0.003 seconds for each of the 1,000 iterations, representing a slowing down of circa 3 seconds. In a real game, there could be a lot more suspense built in, however I do not want to keep hiring managers and recruiters waiting for the outcome of the game when its purpose is to demonstrate usage of the libraries used.

Each choice was logged in a log file within the app's directory.

Some polish was applied to the game by creating an image for each of the 12 destinations and using that image dynamically when the winner is revealed on the destination screen.

Finally, the user has the option of viewing the log file contents. They are not actually viewing the log file itself because that sits securely on the server. They are the viewing the contents of the file which is rendered out to the HTML template.

Evaluation

Overall, I am happy with the development of the project. A recent refactor say the game's logic, the logging components, and the views separated into separate modules.

As further polish, a progress bar could be added to the application to give the user a visual indication of when the code will finish running.

Languages, Technologies & Skills Used

In approximate order of frequency used...
Languages: Python, HTML, Sass
Frameworks / Services: Django, Bootstrap, Font Awesome
Software: VS Code
Libraries: logging, operator, random, time
Notable Packages: N/A
Infrastructure: GitHub, Docker, Poetry, Amazon S3