refactor: add fuel efficiency tracking to Turtle class
This commit is contained in:
@@ -98,6 +98,11 @@ export class Turtle extends EventEmitter {
|
|||||||
this._messageIndex = 0;
|
this._messageIndex = 0;
|
||||||
this._lastPromise = Promise.resolve(); // Promise chain for sequential exec
|
this._lastPromise = Promise.resolve(); // Promise chain for sequential exec
|
||||||
|
|
||||||
|
// Fuel efficiency tracking
|
||||||
|
this._stepsSinceLastRefuel = 0;
|
||||||
|
this._totalSteps = 0;
|
||||||
|
this._totalFuelUsed = 0;
|
||||||
|
|
||||||
// Connection tracking
|
// Connection tracking
|
||||||
this.connected = false;
|
this.connected = false;
|
||||||
this.lastUpdate = Date.now();
|
this.lastUpdate = Date.now();
|
||||||
@@ -447,6 +452,8 @@ export class Turtle extends EventEmitter {
|
|||||||
if (result === true || (Array.isArray(result) && result[0] === true)) {
|
if (result === true || (Array.isArray(result) && result[0] === true)) {
|
||||||
this.updatePositionForward();
|
this.updatePositionForward();
|
||||||
this._deleteBlockAtPosition(this._position);
|
this._deleteBlockAtPosition(this._position);
|
||||||
|
this._stepsSinceLastRefuel++;
|
||||||
|
this._totalSteps++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user