#What does this error mean
1 messages ยท Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
For-loops in java must always have three parts within the parentheses, delimited with semicolons. You can leave any of the parts blank, but you need to include the semicolon separators. You for-loop only has one semicolon between the parenthses
would putting a semicolon and i=i have the same effect?
yes
for (int i = 0; i < 14;) {
}
would do the same as
for (int i = 0; i < 14; i=i) {
}
since well, i=i doesn't do anything
well thats a logic problem, no?
the problem here is that you ask
"is the front clear"
if yes, go forward
if no...?
just does nothing
then
while the front is blocked - turn left, move forward, turn right move forward, ...
but thats not really general directions
the thingy I'm using has those things given (suppose the library has those methods)
yeah no i get that
i'm saying that those directions don't work when you get to the end
try this
if (frontIsClear()) {
move();
i++;
continue;
}
if (frontIsBlocked()) {
jumpHurdle();
i++;
continue;
}
what I think is happening (and to be clear i'm not reading too closely)
is that you know you need to go 14 spaces total
and you either go forwards or "hop", which is a bunch of small steps
but because you say "while front is clear"
and "while front is blocked"
you are making more than 14 moves
and so are just reaching the end and trying to hop over the last wall
Shouldn't turning i<13 limit it to the block before the last block? Then, I should be able to just say move(); that doesn't work for some reason
it would, if you only did one thing for each i
one block for each i?
I feel like I'm doing dat tho since I place one "jumpHurdle" and one block
public void run() {
for (int i = 0; i < 14; i++) {
if (frontIsClear()) {
move();
}
else {
jumpHurdle();
}
}
}
try this^
after while (frontIsClear()) you then execute while (frontIsBlocked() before checking if you've done 14 things total yet
it worked with i<13 for some reason
doesn't make a lot of sense but as long as it works ig
well lets not move on until it makes sense
if you have 14 spaces to go and you start in one of those spaces
well thats only 13 to go
