-
Notifications
You must be signed in to change notification settings - Fork 11
Grasshopper
Each player starts with three Grasshopper tiles.
The Grasshopper moves by leaping up and over a straight line of bugs. It can both start and/or end completely surrounded by other bugs. It can leap over stacks of Beetles. It cannot leap over a gap. It cannot break the hive.
Pick a direction from the starting position. If there's a tile in that direction, then keep checking for further tiles in that direction. Stop when there's no more tiles in that direction. If there was at least one tile in that direction, save the move to the last position you checked (where there was no tile). Repeat for all directions from the starting position.
Assuming you've already validated that moving the Grasshopper does not break the Hive, the pseudo-code looks as follows:
validMoves = new collection of valid movements
startingPosition = starting position of Grasshopper
foreach (Direction direction in Directions)
landingPosition = position in direction from startingPosition
distance = 0
while (HasPieceAt(landingPosition))
landingPosition = position in direction from landingPosition
distance++
if (distance > 0)
validMoves.Add(move to landingPosition)
return validMoves
Mzinga Copyright © 2015-2023 Jon Thysell.
Hive Copyright © 2016 Gen42 Games.
Mzinga is in no way associated with or endorsed by Gen42 Games.
Getting Started
Mzinga's Projects
Other