A simple multiplayer word game in Node.js

Back in our childhood while still at primary school, we used to play a very simple yet funny and addictive word game that we used to call “Name, Animal, Plant”.

The rules are pretty simple: in each round two or more players try to find as quick as possible a Name, an Animal and a Plant starting from a specific random letter.
The first one who finds them all can stop the round and then each player gets 0, 5 or 10 points for each one required field based on two factors:

1) If he found the required field gets 5, otherwise 0 points and

2) if anyone else did not find the same required field then he gets 20 points instead of 5.

You can check it and play it directly from here  or even via Facebook. [Greek language only]

The whole application seems pretty simple although the technologies behind it are very diverse but also interesting, so lets take a look.

I decided to build this little game with Node.js and to make real-time multiplayer I chose the integration of websockets and the socket.io library. This way all players are in the same websocket “Room” and all listen simultaneously to the events published to it by each other without the need of “Long Polling” or other type of mechanisms that could make it a lot heavier in resource manner.

The database behind is a simple MongoDB that fits perfectly with the purposes of the application and is as fast and simple as needed.

Moreover the Porter stemming NLP algorithm written in pure JavaScript lies behind to make sure that the words such as “Potato” and “Potatoes” are considered as the same.

Index page of the game

Index page of the game

Inside a game room

Inside a game room

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill the math equation *