My second project: VGdb - The Videogame Database and Recommendation Software
Tags: beginners, python, showdev
Published: 2022-07-03 21:39:19

# VGdb
Hello! I'm back to show you guys my second project for Computer Science. This time it's a terminal based videogame database and recommendation software.

You can check it out [here](https://github.com/orchidb0y/VGdb).

## Data structures
The program can return recommendations based on 5 different search methods:
1. Search by name
2. Search by rating
3. Search by release year
4. Search by genre
5. Search by platform

### Each search category uses a different data structure.

#### Search by name used a hash map.

That makes it fetching a game from it super quick. When calling this search method, the program will quickly build the hash map with the game's names as keys. The user then passes a string that is supposed to be matched with the name of a game or franchise they are looking for.

Say I'm looking for God of War games. I'll enter 'god' and the program will pass it over a search algorithm (*I'll talk about the algorithms next*) that returns a list of games that match with the search pattern. That list contains the full name of the matched games, and each of these names will be passed over to the hash map retrieving method to get the full information of the game.

#### Search by rating uses a map simpler than a hash map tied with linked lists
I called it a rating map. It's composed of an array 100 linked lists long. Each index of the array corresponds to a rating, so that's one index for each rating from 1 to 100. Games with the same rating are stored in the same array using linked lists.

When calling this method, the program will build this rating map, and then fetch games with the desired rating from the appropriate array index.

#### Search by release year uses a map much like the rating map

This date map's array has an index for each year from 1980 to 2022. It works exactly the same as the above: games from the same year are stored in the same array index at a linked list.

#### Search by genre and by platform use a dictionary with linked lists

When calling these searches, the program will build a dictionary with genres/platforms as keys and linked lists as values.  The dictionary's keys are genres/platforms of the games in the database. The values are the games themselves.

## Search algorithms

### Search by name

This one uses the most complex search algorithm. The project asked for a simple matching algorithm that would match the beggining of the names with the search pattern. However, that would make it hard for the user to search for games that have 'The' in the name.

Instead, I built an algorithm that will search for the search pattern in the whole name. A bit harder to code, but a better experience overall.

### The other four

The thing about this programs database is that it is 100 games long (and I might add more soon, just for the heck of it). Returning a list dozens of games long wouldn't be the best user experience. However, simply restricting the return list of games to the first N games also wouldn't do.

That's because that means that the same search would give the same results over and over. That means the user might not see all games that are in the database.

To counteract that, I simply made it so that the algorithms would fetch a list with **all** the games that match the search. It will shuffle this list, and only then grab the first 10 results and show them to the user.

The result of that is that the same search will return different results, and that will be even more important as the database grows to 200, 300, 500 or more games.

## That's it!

I'm as proud of this one as I was of my previous project, the [Terminal Blackjack Game](https://github.com/orchidb0y/Blackjack).

Like the previous assignment. I decided to go beyond what the project asked from the student, knowing that it would be a great learning experience as well as an even better project for my portfolio.

I hope you guys enjoy looking at my code. I think it's cleaner and better than my previous project's code. I felt like I've quite improved since then.

Cheers!