42876c1a93
Introduce health (hp) and damage handling to Robot/BaseRobot interfaces. Add SmartBot implementation. Refactor bot mining and movement to use new World APIs (mine, mineAllPositive, sortPositiveValues). Simplify RandomBot, DigDeepBot, and SortBot logic, rename/overhaul World rearrange/display, and fix several indexing/logic bugs and minor cleanups.
20 lines
582 B
C++
20 lines
582 B
C++
#include "../include/DigDeepBot.h"
|
|
#include "../include/World.h"
|
|
|
|
DigDeepBot::DigDeepBot ( const int startX, const int startY ) : BaseRobot ( "DigDeepBot", startX, startY ) {}
|
|
|
|
int DigDeepBot::mine ( World &world ) {
|
|
/* Mine up to three positive blocks from the current column, scanning
|
|
from top depth to bottom depth.
|
|
Complexity: O(z) where z = column depth */
|
|
int total = 0;
|
|
|
|
for ( int i = 0; i < 3; ++i ) {
|
|
int mined = world.mine( x_, y_ );
|
|
if ( mined <= 0 ) break;
|
|
total += mined;
|
|
}
|
|
score_ += total;
|
|
return total;
|
|
}
|