Game
Domino

3 days ago

Domino is written in C language!!! (My new game!)

If you are a programmer, then it will be interesting for you to read this post. Because I'll tell you what structures and algorithms were used in the development of this game =)


Domino Game Implementation Overview

The domino game is structured using two key data structures: a stack for managing player hands and the bazaar, and a doubly linked list for representing the game board. Here's a brief explanation of their roles:

Stack for Player Hands and Bazaar

A stack is a last-in, first-out (LIFO) data structure that allows elements to be added (pushed) and removed (popped) only from the top. This makes it ideal for managing domino tiles during the game.

  • Player Hands: Each player’s hand is represented by a stack. Players draw tiles from the bazaar (push) and play tiles onto the board (pop). This keeps the gameplay organized and efficient.

  • Bazaar: The stack also represents the bazaar—a shared pool of tiles. When a player cannot make a move, they draw tiles from this stack until they find one they can play or the bazaar is empty.

Using stacks simplifies tile management, ensures efficient memory usage, and integrates seamlessly into the game logic.

Doubly Linked List for the Game Board

The game board is implemented as a doubly linked list, a structure where each node contains a domino tile and links to both its predecessor and successor.

  • Efficient Tile Placement: Dominos can be added to either end of the board in constant time O(1), which is crucial for the game’s mechanics.

  • Bidirectional Traversal: The doubly linked list allows traversal in both directions, enabling easy checks for valid moves and board state updates.

The use of a doubly linked list over a singly linked list provides additional flexibility, such as efficient removal or insertion at either end and the ability to traverse backward when needed. These features are essential for smooth gameplay and accurate rule enforcement.

Alpha-Beta Pruning in the Domino Game

Alpha-beta pruning is an optimization technique for decision-making algorithms in game trees, such as Minimax. It reduces the number of nodes evaluated when determining the best move, thereby speeding up computations without affecting the final outcome.

How Alpha-Beta Pruning Works

  1. Two Thresholds:

    • Alpha: The best guaranteed value for the maximizing player.

    • Beta: The best guaranteed value for the minimizing player.

  2. Branch Pruning:

    • If a node’s value is worse than the current alpha or beta, the corresponding subtree is skipped since it cannot influence the final decision.

  3. Recursive Process:

    • The algorithm alternates between the maximizing and minimizing player, updating alpha and beta values to refine the search and limit exploration to only relevant branches.

Application in the Domino Game

In the domino game, alpha-beta pruning is used to evaluate moves when playing against a bot with open tiles. The bot employs this algorithm to determine the optimal move by simulating possible future game states.

Advantages:

  • Speed: By pruning irrelevant branches, the algorithm processes complex game states efficiently.

  • Strategic Depth: Even with limited computational resources, the bot analyzes several moves ahead.

  • Enhanced Decision-Making: The algorithm considers factors such as blocking the opponent, minimizing remaining tiles, and maximizing potential future moves.

Adaptive Behavior:
The algorithm dynamically adjusts its search depth based on the complexity of the current game state, ensuring flexibility and efficient resource utilization. This makes the bot more competitive and enhances the gameplay experience for both beginners and advanced players.

Code::Blocks

The domino game is implemented in C. To create the graphical interface, the application Code::Blocks was used, as it supports OpenGL for rendering. Additionally, the program is compiled with the /O2 optimization flag, which enhances performance by optimizing the code for speed and efficiency.

End

In general, I have nothing more to tell. I wanted to share with you my experience in developing the game, so I wrote such a long post =) The game is not perfect, but it has the right to be published. I would like to have my game on the Internet that anyone can play :D.I hope that this post has given interesting information to someone about the structure of the game itself



0 comments

Loading...

Next up

A little bit about the changes in the game Немного об изменениях в игре

My sprites

My new sprites

I think this is the best spoiler of the game. There is a lot of information here. What do you think?

Happy Halloween!

Happy Easter!

And you are ready for the new year or Christmas.

What happened here? 👀

Christmas tree

I was able to figure out how to replace the terrible bunker. Now the bunker looks better than before.