Game Design - Multiplayer Games Part 1: Psychic
Games for friends
Games that you can play by yourself are great, but at GamePyong, we've always been fascinated by the ability to play against anyone, anywhere in the world. The very first version of All Fours Online was built shortly after we first learned how to send data across a network via sockets. Playing against a computer AI can be interesting but it in no way compares to a real, live human opponent. In this series, we'll be taking a look at a couple of the multiplayer games we've built in the past (excluding All Fours, which was covered in a previous post). The first one is a little-known card game called Psychic.
This is a recreation of the two-player card game known as Psychological Jujitsu. In the game, a normal deck of cards is separated into its suits, and each player is given one of the suits (not the diamonds). The diamond suit is shuffled and placed face-down in the middle of the players. The players can look at their cards. On each turn, a diamond card is flipped from the face-down pile and players must then bid on the diamond card. The players place their bid face-down in front of them and then reveal their chosen card. The player with the higher bid wins the diamond. Each card has a value from 1 (Ace) to 13 (King). If the bids are tied, the diamond card is simply discarded and nobody gets it. The goal of the game is to get the most points by winning the highest value cards. Players need to predict what their opponent is thinking and bid to suit. Below is a video of the actual game being played with two players:
Psychic is a simple turn-based game and therefore the networking behind it is fairly straightforward. It uses websockets on the client-side and a node.js server on the backend. When the game starts, the server generates a seed which is used to randomly shuffle the deck of cards. The server knows every card in the diamond pile as well as the cards in each player's hand. Each player's hand is then sent to the specific client who has the hand. The client only knows the cards in his hand. For every turn, the server sends the next diamond card to both clients. The clients then choose a card from their hands and send it to the server. The server broadcasts each player's choice and decides who wins the diamond card. This continues until a player has won the game or it ends in a tie.