Unstated game logic change?

It looks like we change the game rules around movement when we fix the final bug in the Unit Move with Pathfinding lesson:
Before this change, units are allowed to move 4 spaces in any direction:


(note that the above actually does show one incorrect square, where I’ve drawn the red arrow. It isn’t possible to reach this square via any legal sequence of moves totaling 4)

After this change (shown ~12:35) we’ve fixed units being able to walk far beyond what their costs should allow, but we’ve also made a change to our game rules!

If we contrast the diagonal movement between the before and after pictures, we see that the allowed diagonal moves change from 4 to 2. The squares from the Before are actually correct (per our original game rules) provided we don’t have the pillar directly in front of the Unit. This is because we’ve changed our game logic to count diagonals as 1.4 (1.4 * 3 is 4.2 which exceeds our allowed movement cost).

After this change, our costs seem to now be based on rules which fall out of the A* pathfinding algorithm costs, rather than a pure tiles-moved cost as we had before. Totally fine if we want to have this ruleset instead, but it threw me for a loop as this game rules change isn’t explicitly called out anywhere.

1 Like

I’m not sure I understand exactly what is unstated, I mentioned implementing pathfinding into the logic and calculating the path length and using that to validate the position.
Are you saying that what confused you was when doing that change you didn’t remember how pathfinding works, the horizontal vs diagonal cost?
If so yeah I don’t think I re-stated how the pathfinding logic works, just reused it.

1 Like

Ah, I can clarify. I understand the pathfinding logic, but the result of how we use that here is a game logic change.

What I mean by this is that, prior to this lesson, our game rules are that a Unit moves as if it were a queen on a chessboard, restricted to a range of 4 squares on a diagonal, vertical, horizontal, or some combination thereof. After this change, a Unit moves as defined by the real distance we calculate using the Pythagorean theorem as part of our A* algorithm.

Neither of these ways of defining game rules for unit movement are wrong, but we’ve changed from one to the other without explicitly acknowledging that our game rules have changed. Instead it’s just kind of described as “this is the right way to do it.” I think I’d have been less confused if you had said something along the lines of “hey so we had these basic Chess-style rules before, but now we’re going to calculate actual distance” or something along those lines.

2 Likes

Privacy & Terms