Farkle

Engine: Unreal Engine 5

Intended Platform: PC

Approximate Date of Development: October 2024

Genre: Dice Game

What is it?

The first time I made a digital version of the dice game, Farkle, was when I took IT-312 Software Development with C++. In this course I was tasked with creating a console application where the player could play Farkle. Recently, I’ve decided to take that console game, and turn it into an Unreal Engine 5 game.

This was a bit of a challenge for me, since this format is quite different from the “typical” game. By that I mean, the game isn’t played from the perspective of one character, like there would be in a first-person shooter, or a third-person shooter. The player doesn’t use WASD or a joystick to move around, and there’s actually no character movement in the game at all!

Description of Gameplay

The game of Farkle is a multiplayer game meant for 2-8 players. My adaptation allows for 1-4 players. The player rolls 6 dice to start, and from the results can pick several combinations to start earning points.

  • 3-of-a-kind: 100 points x Dice face value (Except for 1, 3 1’s is 1,000 points)
  • 3 pairs: 1,500 points
  • Straight (1, 2, 3, 4, 5, 6): 3,000 points
  • 1: 100 points
  • 5: 50 points

The player can select as many or as few combinations as are available. Then, the player can choose to reroll the remaining dice to try and earn more points, but they run the risk of getting a FARKLE and losing all of their points. If the player doesn’t want to risk it, as long as there are dice remaining they can choose to end their turn and add the round score to their total score.

A FARKLE is when you roll any amount of dice and no scoring dice/combinations are found. Regardless of how many points you’ve collected in a turn, a FARKLE removes all of those points and begins the next players turn.

How to win: Collect 10,000 points! The first time a player reaches 10,000 points, the end game sequence begins. All players (excluding the player who reached 10,000 points) get one final turn to try and get the highest score. Once everyone has played their last turn, the player with the highest point value is crowned the winner!

Select Players
FARKLE!
Roll Dice
Select Dice and Reroll

Dice

Each dice has 6 arrow components attached to it to indicate which direction each face is facing. After being rolled, each dice waits until it’s no longer moving (or the velocity is 0), and then it checks which arrow component has the forward vector closest to (0.0, 0.0, 1.0). This arrow component corresponds with a dice face value. That value is then passed to the game manager.


Game Manager

Much of the functionality of this game happens behind the scenes, meaning there is not much happening on screen to indicate what’s going on. The most important actor/class in the game is the GameManager class.

GameManager Blueprint Event Graph

Blueprint

The class is made up of a parent C++ class and its child blueprint class. The blueprint class handles much of the functionality required for communicating between other blueprint classes. This is done with Blueprint Interfaces.

C++ Class

The C++ class is about 500 lines of code, and much of it is the logic for determining if there is a valid scoring dice combination, and if so, calculating the score of those dice.

Reveal Code


AI

From the beginning, I have planned implement an AI system so that the game could be played “single-player.” While this feature has not been implemented yet, I have created the foundations for this feature. Much of the code was written to account for an AI player (or 3). Additionally, I have written pseudocode and outlines for the logic of the AI.


What’s Next?

This is the first version of the prototype. The main gameplay loop is complete, and the game can be fully played with no game-breaking bugs, which is a good first step. The next steps involve making the game more engaging, removing bugs, and implementing AI!

Bug Fixes & Other Needed Changes

Priority issues include:

  • There is an issue when calculating 3-pairs. Example observed: (4, 4, 4, 4, 2, 2) resulted in a valid selection if selecting all dice, but the score it added was not correct.
  • Round Score only displays the score of the current selection. In the backend the logic is correct and the scores are calculated correctly, but visually it is confusing.
  • Need to add an indicator to represent whose turn it is at any given time.
  • Rarely, a dice will get stuck on the edge of the mesh, this causes the editor to crash. I’ve implemented a potential fix, but I haven’t been able to observe the bug happen in game since then.

Gameplay Improvements

After the priority bug fixes have been completed, I can start planning and making changes to the gameplay.

Plans for future development:

  • AI Implementation.
    • Levels of difficulty (more or less risk?)
  • Add an optional player name.
  • Data persistence for saving high scores, and saving game progress.
  • Additional game modes or ways to modify the rules.
    • Ex. Make the game faster by lowering the win amount from 10,000. Or vice-versa make the game longer by raising it.
  • Customization for your player profile. Change the color of your scoreboard or the look of your dice.