After two whole days away from a computer, I'm finally back to continue my work on my various, incomplete (and far from it) projects.
The last time I ran my Chess program, I was able to move a Piece. The screen sorta froze at that point. I had assumed that what it was doing was a complete drain on the processor.
I just found what was causing the problem. The problem is in the following code segment:
while (isValid(newloc)) {
if (!isEmpty(newloc)) return objectAt(newloc);
newloc=loc.nextLocation(dir);
}
The method nextLocation(dir) returns the neighbor of the location loc. Because loc is not changing, neither is newloc, and the loop continues indefinitely. I'm going to change the last line to
newloc=newloc.nextLocation(dir);
recompile and try it again.
YAY! It allows me to move without freezing. But, I can't move my black pawns because then the white queen checks my black king (!) and there seem to be some other problems, too.
I'm going to work on them now.
Until next time, remember that small errors lead to big problems.
---TDM
Sunday, November 07, 2004
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment