DEV Community

Cover image for Boardgame recommender
Sonja
Sonja

Posted on

Boardgame recommender

The next step has been taken, yay! I finished the Data Structures and Algorithms Course, which is part of the CS Career Path on www.codecademy.com.

This is a subject that didn't come too easily to me, I have to admit. But while there is certainly still a lot to master I am very confident at having thoroughly covered the basics now, finalizing the chapter with this recommendation software project coded in Python.

The aim of the project was to store the data in a data structure of our choice - a linkedlist in this case - write the recommendation functionality and implement an autocomplete feature.

What does the program do?

The program will recommend a boardgame to play matching the user input with an existing boardgame collection.

To do this the program first collects user input asking for the number of players, the age of the youngest player and the time they approximately want to spend playing. Then, the user is also asked to indicate what type or category of game they would like to play.

To narrow down the boardgame types for the user, the program features an autocomplete function. The user simply types the first (few) characters of the desired category to see all the options displayed that start with these letters. They will then be able to select the category by typing the number displayed next to it.

Finally, the program filters the boardgame collection against these criteria, displays the results and provides the user with the option to repeat the process if they are not happy with the games recommended.

How did I implement the recommendation software?

I coded the LinkedList and Node classes in a separate file. The boardgame data went into another file. Those two I imported into the main program file and stored the imported data in two LinkedLists, one for the boardgame collection, the other for the boardgame types.

The main body of the program consists of 4 main functions to

  • collect user input,
  • filter the LinkedLists,
  • display the results and
  • start the process over

... as well as several helper functions, including the required autocomplete feature.

By far the trickiest part of the whole process was figuring out what data structure to use. I opted for a Linked List mainly for two reasons. First, because Linked Lists can be easily traversed, which I needed to do, since checking the user input against all the criteria entered meant I needed to look at every entry in the data structure anyway. A Linked List does that very efficiently. And second, I find Linked Lists quite straight forward to implement.

Sample run of boardgame recommender

Above you can see a sample run through of the program in the terminal.

Conclusion

The implementation of this project did feel a little artificial. Without the given constraints I would have used a very different approach making use of more of Python's built-in properties. As this was aimed at applying the newly gained knowledge of data structures and algorithms, however, it was clearly good practice to do it this way.

What next?

I find it very useful to revisit projects after a while to see how I would solve the problem differently with the experience gained in the meantime. I might want to implement a different algorithm for filtering or break the project free from its constraints and implement a more Pythonic approach, concluding with comparing the speed of the different solutions.

Please, feel free to download the program and let me know what you think. You can find it on GitHub.

GitHub logo s-mehnert / boardgame_recommender

This little program helps you decide which boardgame to play based on input like time available, number of players, etc.


The game has been created using Python 3.9.7

Top comments (0)