David Newton wrote:Instead of apologizing for the messy code, why not just format it in a reasonable way? Almost every IDE will do this for you at the push of a button. Here's what it looks like in a way that makes it intelligible.Unfortunately, without knowing what the code is trying to do, or with some idea of what should be in pieces, or knowing what the start value of a is, it's difficult to answer your question. I'm also a little confused by the usage of both bishopNorthEast and bishopSouthEast--I don't know if this is a cut-and-paste error, or if it's meaningful in some way.
David Newton wrote:Glad you got it worked out, although I don't see how that code would compile because of the "><" constructs.
It sure seems like the code would be a good candidate for refactoring since there are four "chunks" that do essentially the same thing: is the goal to see if there are any pieces along any of the directions the bishop can move?
It also seems like determining the possible moves would be a prime candidate for moving into the Bishop subclass, no?
David Newton wrote:It'd be a lot easier to help if you posted a board configuration that exhibits the error/
David Newton wrote:I think you misunderstood me: an "error" is anything that doesn't work the way you want it to. What I asked for was a board configuration that exhibits the error--rather than making us reverse engineer *everything*, provide an SSCCE for us to examine. It's difficult enough to read your code without having to also figure out how to create a scenario that causes the undesired behavior.
David Newton wrote:(And I can't tell if you have a cut-and-paste error in your code, or if it's what you really mean: perhaps posting an explanation of your algorithm would also be useful to the dwindling number of people that are still trying to help.)
David Newton wrote:If the debugged bishop code works, what's the issue? The rook code?
You're confusing on several levels... And please, *please* format your code.
David Newton wrote:The code above will not compile--do you understand that? You need to post the exact code that doesn't work the way you expect, you need to state how you want your code to work, and so on.
I think there is a bug on the Ranch which produces >< every now and again when you are supposed to have only one of those characters.David Newton wrote:Maybe I'm missing a bracket? Really?
That aside:Tell me how that compiles. (Hint: it doesn't. It's on line 185 above, and in the other three blocks as well.)
Why won't you format your code nicely?
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Campbell Ritchie wrote:Do you have Pawn objects and Bishop objects and Knight objects, etc?
Barry's not gonna like this. Barry's not gonna like this one bit. What is Barry's deal with tiny ads?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|