Translate

Sunday, May 13, 2012

Computing Line of Sight

In some hex-based boardgames it is necessary to determine if a clear line of sight exists between a firing unit and the target unit. This can be done easily enough in a tabletop game by a simple rule to examine the hexes along an imaginary line from the center of one hex to the center of another. This is not so easily done in a computer boardgame. This post outlines a method for determining line of sight in a hex-based computer game.

Consider a map image. It consists of pixels that form an x/y Cartesian coordinate system. Overlaid on the map image is a hexagon grid.

Assume that we know the pixel coordinates of the center of each hexagon. Assume further that we have a firing unit at hex 1 with pixel x/y center at x1,y1 and a target hex 2 with center at x2,y2.

We want to "draw" a line from x1,y1 to x2,y2 and determine of a hex center x0,y0 is within d pixels of the line. If it is, then we can say that the hex at x0,y0 is in the line of sight between the firing and target hexes.

Given a point and a slope, a line is given by the equation

                         (1) y-y1=m*(x-x1), where m is the slope of the line.

 Given two points, the slope, m, of the line that goes through each point is

                         (2)  m = y2-y1/x2-x1.

Subsituting (2) into (1), we have

                         (3) y - y1 = (y2-y1/x2-x1) * (x-x1) or

                         (4) (x2-x1)*y + (y1-y2)*x + (y2*x1-y1*x2) = 0.

A line is expressed by ax + by + c = 0. From (4), we have

                         a = y1 - y2

                         b = x2 - x1

                         c = y2*x1 - y1*x2.

Now the distance, D, from a point x0,y0 to a line ax + by + c = 0 is given by the equation

                         D = ABS(a*x0 + b*y0 + c) / SQRT(a*a + b*b).

For each hex center point x0,y0 on our map image, compute a value of D. If D < d the hex center is within d pixels of the line between x1,y2 and x2,y2 and can be said to be in the line of sight between hex 1 and hex 2.







Wednesday, May 9, 2012

Review of At Neuve Chapelle

I had a chance to get At Neuve Chapelle on the table for a solo learning game this weekend (fortunately there is nothing hidden that makes solo play a problem).

I was really impressed. It's a very exciting game with a very easy to play system. The rules are only four pages long but give enough differentiation to make artillery, defensive fire, and assault their own unique systems. The game also has a command mechanism where after the initial attacks some of the British Divisions will go inactive just when you most want them to move.

The battle covers three days and has an interesting flow --- the first day sees a strong British force attacking the thinly held trenches and pillboxes. In this phase the British will rush to consolidate gains and reach for victory objectives while facing possibly inactive divisions and the fear of over-extending themselves. The Germans move a major counter attack into place on the first night and the second day will see a much tougher fight as both sides struggle to consolidate their positions. Finally the third day will likely see a tough stand-up fight as the lines become locked in place and both sides fight for the few victory locations that are likely to change hands.

The game had two mechanics that I really liked. First at night units can fortify their hex. This is crucial for units that are not in good terrain and need a safe launching place for the next days fight. The second is the simple weather roll. There is a 50% change that each turn will be Misty and prevent artillery from firing. Misty turns are a great chance to creep out of trenches but the players have to fear that the next turns Clear weather may find their units in the open and expose them to nasty artillery attacks.

I'm really looking forward to trying this one out face to face. I found it very playable with some tough and exciting decisions.
See At Neuve Chapelle Details.

Sunday, May 6, 2012

Shield Wall AAR

The following is a replay of Shield Wall posted on BoardGameGeek by Chris Hansen.

I played this game on Saturday April 28th with my brother, Brad (bradleygh4).

I played the Saxons and set up my units along the Senlac Ridgeline. I set up my huscarl units along the frontline (I wanted to begin with a strong defense) with fyrds in the back ready to move up into any openings along the line. Brad set up his unit along the Norman start line. His Bretons were on his left, Normans center, and French on the right.

He was a little overly cautious on his first move and didn’t bring too many units up the hill. The Norman assault accomplished very little but the Bretons were able to get a small toehold on the ridgeline. The French units were not successful in their assault but they did cause a few of my units to involuntarily charge down the hill. Unfortunately for me, this charge consisted of one leader and (Leofric) and two other huscarl units. (Unfortunately for Brad, Leofric turned out to be a killing machine that the Normans could never kill.)

End of turn one

The game progressed over the next few turns in a similar fashion. I had Saxon units centrally located the the Norman assaults were never able to make serious headway. However, the Breton units on the left and French on the right were able slowly pick away at my flanks. The Bretons actually were able to gain some territory on the ridge while the French, while never setting foot on the ridge, were able to get me to abandon it through involuntary charges.

End of turn three. The Saxons have all but abandoned the right side of the ridge chasing the French units.

At first I was upset about the units that had involuntarily charged. But the units at the bottom of the hill soon proved beneficial because they were able to block much of the Norman charge.

The Normans send up a large charging assault up the hill everywhere they are able. Much of their attack path is blocked by Saxon units.

Meanwhile, Leofric, who had charged down the hill in turn one, continued to slaughter Norman troops turn after turn. Brad had some amazing bad luck in his combat. There were turns where Leofric was attacked by four separate units but was able to withstand them all and then pick one of them off in retaliation. At one point in the game, he was within two hexes of William, which could have ended the game if he’d been able to get close enough to kill him.

By turn six, most of the Norman archers had run out of arrows and been removed from the game. However, there were still two French archers on the board who were annoying me a lot. I did my first voluntary charge of the game by sending a fyrd unit down the slope to take out the last two archers. This he accomplished easily (archers are eliminated as soon as an opposing unit is adjacent) and following the example set by Leofric, he proceeded to kill three more French units before the end of the game.

Eventually, the fyrd faced off with the French leader, Robert (right side of the image). Mighty battle ensued on the last turn of the game but neither was able to eliminate the other.

On turn seven, the Breton units sent up a large charge. This was entirely unsuccessful in taking any territory but it did result in most of the Saxons on the left side of the hill involuntarily charging after them. The Bretons were all but eliminated, but it was a pyrrhic victory since the Saxons had left a huge opening on the ridge. For the first time in the game, a Norman knight could easily charge directly to Harold.

On the final turn of the game, both sides were severely depleted but the Normans had a clear path to take a large section of the hill. They, of course, took advantage of this by moving five units up. I was able to move in and eliminate three of these units, but two remained. I even tried charging with nearby units in a desperate attempt to remove them but to no avail. They remained at the end of the game so the result was a draw.

The end of the game. Two knights remain on the hill ending the game in a draw.

I’m not sure exactly what a draw meant in terms of history. Neither side was terribly willing to compromise but I suppose eventually, William would have withdrawn his remaining army and attacked again somewhere else - or been forced to retreat back to Normandy.

Both of us had a few lucky streaks in the game. As I mentioned, I had two units that were able to kill 11 or 12 Norman and French units between them. Brad was also lucky at forcing involuntarily charges. I’ve never seen the Saxons charge down the hill and abandon their defensive advantage as much as they did in this game. Also, Brad had a huge advantage in reinforcements. William was able to roll the maximum number of rally points on just about every turn, bringing back from dead everyone I had managed to kill on the previous turn. I did not have similar luck with Harold. I think he was only eligible for rally points once in the entire game. This resulted in Brad having a lot more troops at his disposal than I did in the later turns of the game. Overall, the game was fun for both of us, even if we found the draw result to be a little anti-climactic.