-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
some improvement part 3 #532
Conversation
src/prototype_creep_routing.js
Outdated
console.log(`getDirections: pathPos: ${pathPos} pos: ${pos} path: ${JSON.stringify(path)}`); | ||
throw e; | ||
console.log(`${Game.time} getDirections: pathPos: ${pathPos} pos: ${pos} path: ${JSON.stringify(path)}`, e.stack); | ||
currentPos = this.pos; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering why we not simply say: const currentPos = this.pos
. Currently I'm missing why we get the pos from the path.
Not sure if it is just stupid implementation to set currentPos
in the first place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i was wondering why you choose try catch and not just a const currentPos = this.pos;
in the last update 😄
src/prototype_creep_routing.js
Outdated
backwardDirection = currentPos.getDirectionTo(nextPos.x, nextPos.y); | ||
} | ||
|
||
if (currentPos.isEqualTo(nextPos)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can this happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on transfer between rooms i thought
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
src/prototype_creep_routing.js
Outdated
if (currentPos.isEqualTo(nextPos)) { | ||
this.creepLog('getDirections: i need to stay'); | ||
} | ||
if (!backwardDirection && this.memory.routing.reverse) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this. I think we shouldn't mess around with it here. The caller of the method should handle the case, that we don't have the direction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was the easiest way to fix carry on the wrong side due to rooms skip.
let offset = 1; | ||
if (this.memory.routing.reverse) { | ||
offset = -1; | ||
direction = backwardDirection; | ||
} else { | ||
this.memory.routing.reverse = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? Isn't it anyway the case that this.memory.routing.rever
is false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, some time it is null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think this is necessary the best place, but fine.
src/prototype_creep_routing.js
Outdated
@@ -151,6 +159,7 @@ Creep.prototype.followPath = function(action) { | |||
} | |||
|
|||
// Recalculate the directions, if `preMove` changed `memory.routing.reversed` | |||
this.memory.routing.pathPos = this.getPathPos(path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.getPathPos(path)
updates this.memory.routing.pathPos
already, so this.getPathPos(path);
is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok changed
src/prototype_creep_routing.js
Outdated
if (config.debug.routing) { | ||
this.log(`${Game.time} moveByPathMy: Directions invalid pathPos: ${pathPos} path[pathPos]: ${path[pathPos]} directions: ${global.ex(directions, 1)}`); | ||
} | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why returning true? We don't move we should tell that to the caller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because you return in followPath (prototype_creep_routing.js:175) moveByPathMy, and that leads to unnessesary 'Directions invalid messages' for carries...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because of the skipped rooms they are on the wrong room side
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so it lead to 'Reached end of handling() why?' for carries and some scourcers
Please fix the codeclimate issues, I improved the rating to A and we should try to stay there. Will try to bring the other files to a similar level, but for the ones I did, I would like to force that codeclimate needs to be green, too. |
btw in moveByPathMy we return moveBackToPath. |
added tooangel comments + improvements
92480db
to
650e360
Compare
Hm, good question, I'm not sure yet, we can start with |
Same here codeclimate for |
@mschultheiss83 Can you please fix the codeclimate issues (https://codeclimate.com/github/TooAngel/screeps/pull/532) in src/prototype_creep_routing.js and I'm fine. |
I'm on holiday. I can try in 3 Weeks |
everything is fixed in #533 |
except in https://codeclimate.com/github/TooAngel/screeps/pull/533 |
A new review, yeah.
|
fixes some routing and direction problems with carry and soucer