Discussion Board
There are no previous messagesThere are no next messages
Current Forum: Homework 6 Part 1
Date: Sun Dec 2 2001 2:25 am
Author: Zelinski, Adam C. <acz@ece.cmu.edu>
Subject: Serious DemoBoard.class Error

Please see below. (Ive pasted my moves while using DemoBoard.class)

(Btw, I can't get the bboard to format my pasted 9mensmorris board right, but the ascii 'art' below will still show the error.. even tho' it looks bad)


W-----W-----W
| | |
| B---+---+ |
| | | | |
| | W-B-W | |
| | | | | |
+-W-B B-+-+
| | | | | |
| | W-B-W | |
| | | | |
| +---B---+ |
| | |
B-----B-----+

Player to move: Human Player
Enter move for WHITE:
3,0

/* ^ notice, i don't type in all 4 integers,
I know I should type 2 coordinate pairs,
but I was testing my own code (MyBoard) for errors when I
discovered this bug..
*/

/* now, watch what occurs */

W-----W-----+ <-- W is gone from 3,0
| | |
| B---+---+ |
| | | | |
| | W-B-W | |
| | | | | |
W-W-B B-+-+ <-- W appears at 0,0 (!!!)
| | | | | |
| | W-B-W | |
| | | | |
| +---B---+ |
| | |
B-----B-----+

/* ^ as you can see the white piece at "3,0" just warped to "0,0"!!! (you can cause this error in DemoBoard to, if you don't believe me hehe)

Anyway, I decided to call this bug the "teleport pad" (lol)

I think it is occurring because, whoever coded the higher layers above the Demo/MyBoard.java files, had the program assume that
if someone types in 2 numbers during a move that is supposed to accept 4, it automatically creates move as a 4 element array with the following:

move[0] = the first num you type
move[1] = the second num you type

And, instead of stopping there (realizing you didn't type the 2nd coordinate pair), it sets..

move[3] = 0
move[4] = 0

.. the 3rd and 4th array elements to zero as well..

That'd mean when I typed "3,0" to the program,
it considered it as me typing "3,0,0,0"


Anyway, I was able to fix this "teleport pad" error in my code
by saying, roughly, "if move.length is 4, but you're didn't type one of the 3 coordinate pairs adjacent to 0,0, then don't permit the move"

However, there's no way you can change how the higher code layers accept your input, so you have to always remember, if you type only 1 coordinate pair as input into a "move from coord1 to coord2" type move, it'll always try to move from your first coord to "0,0"...

Just figured I'd post this so everyone knows to make sure to not have the teleport pad error in their own code

(although it would be cool to teleport if the move would benefit you, but I guess that'd be considered cheatin'.. )

Sorry for the confusing writeup its late and i've worked on code all day =)

nite.

-Adam
Post response

There are no previous messagesThere are no next messages
Current Thread Detail:
Serious DemoBoard.class Error      Zelinski, Adam C.      Sun Dec 2 2001 2:25 am       

Back to previous screen