1

** This question involves knowledge of computer programming and/or math and algorithms. **

I am working on writing a Warhammer combat simulator in Java and have hit an interesting snag.

Pg 20 BRB: "Once the charging unit contacts the enemy unit, it must perform a second, bonus wheel if required to bring its front facing into flush contact with the facing of the enemy unit that has been charged, maximizing the number of models in base contact on both sides"

Aligning the units in this way is absurdly simple when looking at them, but trying to write the code to do the same thing is proving difficult. I tried posting the question to Stack Overflow, but I think the concept is too vague.

Basically, I'm trying to simulate combat between a unit of spearmen (20x20mm bases) and a unit of horsemen (25x50mm bases), and programatically determine how many models will get attacks during the combat.

Any help would be appreciated.

6
  • I'm pretty sure this would get a much better answer on GameDev.SE, since it's related to the math of a design instead of an actual board/card/table-top game. Commented Mar 13, 2015 at 18:53
  • The linked question on Stack Overflow actually describes what you're trying to do - that seems like a much better way to get answers, and honestly, it seems like it's a better fit for Stack Overflow. There might be a few more people who know how Warhammer works, but I think most of us don't so you're going to have to explain anyway to get an answer, and as long as you're explaining, you're just asking a programming question, so SO is a good place.
    – Cascabel
    Commented Mar 20, 2015 at 1:01
  • Note: The question has been asked, and answered on SO. It's a neat analytic geometry problem. stackoverflow.com/questions/29035291/…
    – John
    Commented Apr 19, 2015 at 2:58
  • 1
    Yes, PaulDouglas's answer is spot on. It requires some more math to get to code, but if the OP can't do that math, then I think this project is beyond his ability.
    – John
    Commented Apr 19, 2015 at 13:03
  • 2
    I'm voting to close this question as off-topic because it is only tangentially related to gaming Commented Apr 20, 2015 at 14:56

1 Answer 1

0

get the number of unit on the face being charged, see how many of the charging units front of base length fit in it then * that by the number of units being changed are open on that side.

if you have uneven formations you would need to keep the current shape of a unit in an object, then find all the lengths along the charged side and use some sort of packing algo to put the charging units along them

Not the answer you're looking for? Browse other questions tagged .