SVG Perl Script to Make Alquerque Game Boards

Alquerque boards are used for a variety of games. Fanorama, Tigers vs Goats (Bagh bandi), Fox and Geese and other variants similar games are some of the examples. Here is how to make Alquerque game boards in SVG using Perl.

Games that use Alquerque boards:

Fox & Geese
Several variants of this such as pirates vs soldiers or tiger vs goats.
The aforementioned tigers vs goats. Goats try to surround tigers. Tigers jump/eat goats. Play twice to determine winner.
This is essentially checkers with a higher degree of strategy.
A unique game that takes longer to setup than to play, but you slide in and out using strategy to capture all of your opponents pieces.

Creative Problem Solving through Coding

The math and logic to create this Alquerque board was interesting, so we wanted to share it. More importantly is the idea of creative problem solving, and that is what this article talks about specifically. Anyone can copy code and use formulas. It’s harder, and more fun I’d argue, to come up with solutions in the first place, and know how to apply code and formulas.

The rules for the various games using these boards will be put into the games category. This article will talk only about the process of creating the game board and the script involved.

Step 1: Know Your Objective

One of my favorite verses is Proverbs 29:18 “Where there is no vision, the people perish: but he that keepeth the law, happy is he.” This rings true in all aspects of life. If you do not know what your objective is, you will most certainly have a more difficult time reaching it.

In the book of James 1:6-8, a similar verse echoes “6 But let him ask in faith, nothing wavering. For he that wavereth is like a wave of the sea driven with the wind and tossed. 7 For let not that man think that he shall receive any thing of the Lord. 8 A double minded man is unstable in all his ways.”

Knowing that I simply wanted a square with lines through it like an X greatly simplified the task list. Now it was time to identify the sub-tasks.

Step 2: Refine Objective

The first goal was to simply create a 4×4 Alquerque board, which I drew out on paper. I drew a 3×3 board too and saw that the math didn’t work right, but a 6 or 8 did. So I refined my goal to boards with an even number of squares only.

One Bite at a Time

When deciding how to eat an elephant, surely you’ve heard that eating it one bite at a time is the best way. By breaking down the objectives into smaller steps, they problems seem easier. Habbukuk 2 says “Write the vision; make it plain on tablets, so he may run who reads it.” Simply outline in very clear objectives all of the steps it takes to do what your goal requires.

“The important lesson is to break down big tasks into smaller ones, then focus on solving the smaller ones.”

Now we need to Refine Sub Goals

It would appear that the problems can be identified as:

  • A: Make a Square
  • B: Make an X through the Square
  • C: Stack them together orderly

A: Make a Square

This part was easy. I already figured out some code for making a square when doing the other scripts. I skipped over this hurdle as it was already solved.

B: Make an X Through the Square

I drew out the board we were trying to make and then broke it down into coordinates. At first, I thought long lines would be best, but after looking at it. After a few thoughts about it, long lines would require recalculating things over and over. If instead I made it from 2×2 squares, I would have all of the coordinates already, and do less math. It would only require advancing 1 square x or 1 square y. That is the path I chose – to make a stack of squares with X inside of them instead of a other ways.

C: Stack the Squares Together, Orderly

One way would be to solve for every possible combination and then use that list. This is obviously not an efficient way, as I’d have to solve by hand. So, I decided to solve a few to see the patterns and then write a program to match the patterns as that is the time consuming part, and I didn’t want to do it by hand hundreds of times.

I knew already that I could print out a grid, as the checkered/squares program was written before this.

Demo Code for Logic Only

Then, after the patterns were apparent, I wrote up mock code that only gave me coordinates with a fixed input. On paper this was 3 lines to tell me what logic I wanted to accomplish. Then I started writing the actual code to do the “test”.

Again the goal of this was to make sure my logic was sound. Do I loop over X first? Y first? I had to test it to see before going further.

1 Peter 1:13 explains a key point here. Too much thought and no action isn’t profitable. Take action in all things (test it, try it)!

Therefore, preparing your minds for action, and being sober-minded, set your hope fully on the grace that will be brought to you at the revelation of Jesus Christ.

The key point is: take action. Whatever your goal is, put it into motion. We are not blindly coding at this point. We have a goal, and know specific problems to solve.

Later, I polished it a bit, used better coding practices, commented it, and tried to break the logic with all types of different configurations, like a user might.

Enjoy the Good of Your Labor

The final product, produces boards exactly like we planned. We ran it a few times to make the boards we wanted and saved the SVG files for later use with the CNC router that will cut the game boards.

We Enjoy Coding

Coding isn’t fun for everyone, but it is something we love to do. Ecclesiastes 3 talks about the joy of your labor.

12 I know that there is nothing better for them than to rejoice and to do good as long as they live; 13 and also that every man should eat and drink and see and enjoy the good of all his labor—it is the gift of God.

God gave us problems to solve, and skills to solve them. We enjoy coding, one of our labors. We enjoy problem solving. I also enjoy playing games with my family and kids. What do you enjoy?

We help solve IT related problems, such as writing programs. If you want help, please contact us and we can give you a free quote on custom programming so you can spend more time doing the labor you enjoy, and we can enjoy coding for you!

8×8 Alquerque Board From Perl

4×4 Alquerque Board From Perl

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.