SVG Perl Script to Make 6 Point Star
Solomon’s game is similar to checkers but uses the star of Solomon. It’s a modern game invented by . Here is the Perl code to generate an SVG file game board.
What is the Star of David?
First, there are 2 stars mentioned as false idols in the Bible (Acts 7:43 and Amos: 5:25–27). I do not believe this is that star. Nor do I worship Saturn (read the references). It is well known that Solomon, the wisest man on earth with his 1000 wives, made the mistake of worshiping one of his wive’s false gods. This game has nothing to do with that. There is one God, and he is Jesus Christ.
Objective of Solomon’s Game
Like checkers, the objective is to capture your opponent’s pieces or trap your opponent so they have no legal moves.
Setup of Solomon’s Game
Each player places 6 tokens as per the diagram above using different colored tokens.
Game Play of Solomon’s Game
- The first player moves a piece towards the temple (the box outlined on the opposite side of their color), or sideways (in relation to the opposing temple).
- A piece cannot move backwards until it reaches the temple, where it becomes a “king” like in checkers.
- Moves can only be along the lines.
Capturing Pieces
- Jumps occur like in checkers depending on whether the jumping piece is a “king” or not.
- Only kings can jump back towards the temple of their own color.
- Jumped pieces are removed from the game.
- If a jump is available, it must be taken, except double jumps are not allowed.
Credits
I could not find the reference, but have been told that this game was invented by Martin Gardner and published in Games Magazine. I wrote the Perl, and did the graphics.
SVG to Create Solomon’s Game
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> <svg height="670" width="603" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <polygon points="76.5714285714286,306.285714285714 421.142857142857,107.347307244946 " style="fill: black; fill-opacity: 1; stroke: black; stroke-opacity: 1; stroke-width: 3" /> <polygon points="76.5714285714286,306.285714285714 536,306.285714285714 " style="fill: black; fill-opacity: 1; stroke: black; stroke-opacity: 1; stroke-width: 3" /> <polygon points="76.5714285714286,306.285714285714 421.142857142857,505.224121326482 " style="fill: black; fill-opacity: 1; stroke: black; stroke-opacity: 1; stroke-width: 3" /> <polygon points="191.428571428571,107.347307244946 191.428571428571,505.224121326482 " style="fill: black; fill-opacity: 1; stroke: black; stroke-opacity: 1; stroke-width: 3" /> <polygon points="191.428571428571,107.347307244946 421.142857142857,505.224121326482 " style="fill: black; fill-opacity: 1; stroke: black; stroke-opacity: 1; stroke-width: 3" /> <polygon points="191.428571428571,107.347307244946 536,306.285714285714 " style="fill: black; fill-opacity: 1; stroke: black; stroke-opacity: 1; stroke-width: 3" /> <polygon points="421.142857142857,107.347307244946 421.142857142857,505.224121326482 " style="fill: black; fill-opacity: 1; stroke: black; stroke-opacity: 1; stroke-width: 3" /> <polygon points="421.142857142857,107.347307244946 191.428571428571,505.224121326482 " style="fill: black; fill-opacity: 1; stroke: black; stroke-opacity: 1; stroke-width: 3" /> <polygon points="536,306.285714285714 191.428571428571,505.224121326482 " style="fill: black; fill-opacity: 1; stroke: black; stroke-opacity: 1; stroke-width: 3" /> <circle cx="76.5714285714286" cy="306.285714285714" r="6.7" style="fill: black; fill-opacity: 1; stroke: black; stroke-opacity: 1; stroke-width: 3" /> <circle cx="536" cy="306.285714285714" r="6.7" style="fill: black; fill-opacity: 1; stroke: black; stroke-opacity: 1; stroke-width: 3" /> <text id="l1" style="fill: black; font: Serif; font-size: 32" x="197.277777777778" y="636.5">Solomon's Game</text> <!-- Generated using the Perl SVG Module V2.84 by Ronan Oger Info: http://www.roitsystems.com/ --> </svg> |
Perl Code to Create 6 Point Star in SVG
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
#!/usr/bin/perl # Solomon's Game Board done in SVG use strict; use warnings; use SVG; # https://metacpan.org/pod/SVG # with margins at .25, SCALE of 142*9.5 (last row of dots) fits on an A4 use constant SCALE => '67'; # dots per inch scale, adjust to fit on your board use constant DOTSIZE => '7'; # should be an odd number use constant LINEWIDTH => '3'; # should be an odd number use constant FILL => 'black'; # can be 'rgb(0,0,0)' too use constant STROKE => 'black'; # can be 'rgb(0,0,0)' too my $title = "Solomon's Game"; # create an SVG object, canvas which we use for the rest of the draws my $svg = SVG->new( width => 9 * SCALE, height => 10 * SCALE, ); #---------------------------------------------- # Define the dots, lines, squares, circles etc # Order isn't important, all is eventually drawn # SVG has max of 2-4k objects before browser gets sluggish # keys are sorted alpha for debug reasons #---------------------------------------------- # everything is based off of the segment length # of the circle radius, so "legs" of various length # used throughout rest of the math my $leg1 = (8/7); # 1.1428571429 my $leg2 = (8/7) * 2; # 2.2857142857 my $leg3 = (8/7) * 3; # 3.4285714286 my $leg4 = (8/7) * 4; # 4.5714285714 my $leg5 = (8/7) * 5; # my $leg6 = (8/7) * 6; # my $leg7 = (8/7) * 7; # my $ctr = (8/7) * 4; # 4.5714285714, for code readability # Line Coorids calculated based off of knowing that the # hex was made up of equilateral isoceles triangles # known formulas for calculating all coorids based on # legs only. # line points my $nwx = $ctr - .5 * $leg3; my $nwy = $ctr - (sqrt(3)/2)*$leg3; my $sex = $ctr + .5 * $leg3; my $sey = $ctr + (sqrt(3)/2)*$leg3; my $swx = $ctr - .5 * $leg3; my $swy = $ctr + (sqrt(3)/2)*$leg3; my $nex = $ctr + .5 * $leg3; my $ney = $ctr - (sqrt(3)/2)*$leg3; # Lines are xy start and xy stop coordinates, in inches/scaled my %l = ( la => [$leg1,$ctr,$nex,$ney], # W to NE lb => [$leg1,$ctr,$leg7,$ctr], # W to E lc => [$leg1,$ctr,$sex,$sey], # W to SE ld => [$nwx,$nwy,$swx,$swy], # NW to SW le => [$nwx,$nwy,$sex,$sey], # NW to SE lf => [$nwx,$nwy,$leg7,$ctr], # NW to E lg => [$nex,$ney,$sex,$sey], # NE to SE lh => [$nex,$ney,$swx,$swy], # NE to SW li => [$leg7,$ctr,$swx,$swy], # E to SW ); # Circles are x,y,size and fill my %cs = ( ca => [$leg1,$ctr,.1,1], cb => [$leg7,$ctr,.1,1], ); #---------------------------------------------- # Logic, no reason for sort but to help me see data #---------------------------------------------- # add some lines by looping over lines hash foreach my $cor (sort keys %l) { lines($l{$cor}[0],$l{$cor}[1],$l{$cor}[2],$l{$cor}[3]); } # make our circles by looping over circle hash foreach my $cs (sort keys %cs) { circles($cs{$cs}[0],$cs{$cs}[1],$cs{$cs}[2],$cs{$cs}[3]); } # Text, at SCALE of 142, 6.5 letters per inch, Serif Font # Text, at SCALE of 96, 5 letters per inche, Serif Font # Take half of estimated lenght of title, subtract it from center # that should start half before center, and then half after center # adjust the /5 down to move left, up to move right my $ltitle = length($title); my $xtitle = 4.5 * SCALE - ($ltitle/4.5 * SCALE)/2; $svg->text( id => 'l1', x => $xtitle, y => SCALE * 9.5, style => { 'font' => 'Serif', 'font-size' => 32, 'fill' => FILL, }, )->cdata($title); #---------------------------------------------- # lines sub # really a 2 point polygon, instead of the "lines" function #---------------------------------------------- sub lines { # 4 arguments, xstart, ystart, xstop, ystop my $xstart = SCALE * shift; my $ystart = SCALE * shift; my $xstop = SCALE * shift; my $ystop = SCALE * shift; #print "$xstart,$ystart,$xstop,$ystop\n"; my $path = $svg->get_path( x => [$xstart,$xstop], y => [$ystart,$ystop], -type => 'polygon'); $svg->polygon( %$path, style => { 'fill' => FILL, 'stroke' => STROKE, 'stroke-width' => LINEWIDTH, 'stroke-opacity' => 1, 'fill-opacity' => 1, }, ); } #---------------------------------------------- # circles - x,y start, radius and fill opacity #---------------------------------------------- sub circles { my $x = shift; my $y = shift; my $r = shift; my $fop = shift; $svg->circle( cx => $x * SCALE, cy => $y * SCALE, r => $r * SCALE, style => { 'fill' => FILL, 'stroke' => STROKE, 'stroke-width' => 3, 'stroke-opacity' => 1, 'fill-opacity' => $fop, }, ); } # now render the SVG object, implicitly use svg namespace print $svg->xmlify; |