Skip to content

Conversation

@br3nt
Copy link

@br3nt br3nt commented Nov 26, 2025

Addresses request in #2050

Allow Robodigger to be placed on un-excavated Tile which is adjacent to an excavated Tile.

In additional the the Tile of the mouse click, we can also place the Robodigger on said Tile, which is excavated upon initial placement, rather than on the already excavated Tile next to it. This would eliminate the need for the DiggerDirection window, and the Direction field of the Robodigger class. This both simplifies the user interface, and the programming interface.

The attached video, I showcases the change. First, I select an empty tile that is not adjacent to an excavated square, which displays an error message to the user. Next, I select a tile adjacent to an excavated tile, and the digger is placed, then completes the excavation after a few turns.

Screen.Recording.2025-11-26.at.10.13.37.pm.420p.mov

Comment on lines -17 to +25
<ItemGroup>
<ClCompile Include="MapOffset.test.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="RandomNumberGenerator.test.cpp">
<Filter>Source Files</Filter>
<ItemGroup>
<ClCompile Include="DiggerUtility.test.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MapOffset.test.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="RandomNumberGenerator.test.cpp">
<Filter>Source Files</Filter>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the line ending have changed unexpectedly for a few lines here. MSVC project files should use Windows style line endings (CR LF).

For non Windows specific files, such as source code files, the convention is to use Linux style line endings (LF).

Comment on lines +8 to +14
/**
* Picks a digger orientation that points away from already excavated neighbors.
*
* The neighbor array uses the same ordering as DirectionClockwise8:
* North, NorthEast, East, SouthEast, South, SouthWest, West, NorthWest.
*/
Direction chooseDiggerDirectionAwayFromExcavated(const std::array<bool, 8>& excavatedNeighbors);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the objectives of the issue is to eliminate the mDirection field, rather than auto set it.

constexpr std::size_t AdjacentTileCount = 8;


std::array<bool, AdjacentTileCount> gatherExcavatedNeighbors(const TileMap& tileMap, const Tile& tile)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming we get rid of mDirection, we shouldn't need to gather an array of data for placement checks. We only need to know if there is some adjacent tile which is excavated and unoccupied.

Comment on lines -253 to +254
void RobotPool::deployDigger(Tile& tile, Direction direction)
void RobotPool::deployDigger(Tile& tile, Direction direction, MapCoordinate target)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the position is obtained from the tile, there is no need to pass it separately here.

Rather than add a new parameter, we should look at removing the direction parameter, as it should no longer be needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants