|
Post by Majin_Blues on Nov 27, 2001 21:28:32 GMT -5
my lines do reflip (change direction) if it doesn't fit, . so this orientation is valid in my case. , but . . 4 3 2 2 4 3 . . 4 3 . . 4 . this grid there's no way a line of length 3 can fit, the only way to get around it i found was to make the lines in this order, 4, 3, 3, 2 .. , .but its a cheap way to get around the problem., any suggestions? you should place them in that order, and since you got that re-flip thing which repeats, then you don't have a problem... (the problem is that if you "flipped" for horizontal/vertical and you don't reflip if there's no space... you have that taken care of)
|
|
|
Post by Sylph on Nov 28, 2001 15:50:01 GMT -5
my program doesn't seem to work when i change the grid size to 4. how long did u have to wait for it to finish? but it works for size 5 (quickly). weird thing is, my burying method buries it in the order 4, 3, 3, 2. it should work... but i don't think burying the bonelines from largest to smallest is being cheap; it's just a preference, and it's perfectly valid.
|
|
|
Post by Yingster on Nov 28, 2001 16:31:34 GMT -5
my program doesn't seem to work when i change the grid size to 4. how long did u have to wait for it to finish? but it works for size 5 (quickly). weird thing is, my burying method buries it in the order 4, 3, 3, 2. it should work... but i don't think burying the bonelines from largest to smallest is being cheap; it's just a preference, and it's perfectly valid. i had the same problem, and i found if i compiled the java files in different orders, if i compile it in the correct order, my grid gets created really quickly, if i compile it in a different order my program runs on forever. It's weird, but try it
|
|
|
Post by Sky on Nov 28, 2001 20:01:11 GMT -5
well after i found out this could happen: xxbx xxbx xxbx xxbx (if any one of the two lines with 3 bones choose to be horizontal...the loop may go forever) i added another method to my burybone class to check if there is any space available for the line of 3 bones to fit into the grid(i call this method inside the method that bury my line of 3 bones and also line of 2 bones for safety) ...if there is space in the grid for that direction...it will keep it's random direction...if no space available...it will change the direction so the loop won't go forever
|
|
|
Post by Majin_Blues on Nov 28, 2001 21:08:52 GMT -5
what if you had this:
--4- --43 2243 --43
you got no space for the row of 3 bones...
(which is why it's best to bury in the order from largest to smallest)
|
|
|
Post by Sylph on Nov 28, 2001 21:09:41 GMT -5
well after i found out this could happen: xxbx xxbx xxbx xxbx (if any one of the two lines with 3 bones choose to be horizontal...the loop may go forever) i added another method to my burybone class to check if there is any space available for the line of 3 bones to fit into the grid(i call this method inside the method that bury my line of 3 bones and also line of 2 bones for safety) ...if there is space in the grid for that direction...it will keep it's random direction...if no space available...it will change the direction so the loop won't go forever for my program, if it overlaps, it randomizes a new position, randomizing whether it is vertical or horizontal as well. so it still should work like 3243 3243 3043 0040 Yingster, i'm using CodeWarrior at home...
|
|
|
Post by Sky on Nov 28, 2001 21:15:31 GMT -5
Just to reply Blues i buried the bones in the order of 4, 3, 3, 2
xbbx bbbx bbbx bxbx that's why i use that method also when i choose the line of 2 bones
|
|
|
Post by Sylph on Nov 29, 2001 13:39:48 GMT -5
i'm not sure why my program doesn't work when the grid is of size 4. the way i did it, the bone lines start at the topmost or leftmost position, as in 0 (this is ok, right?). no matter what, it shouldn't loop forever if i bury the bones in the order 4, 3, 3, 2. are they gonna test this, if it works for a grid of size 4?
|
|
|
Post by Sylph on Nov 29, 2001 14:58:19 GMT -5
oh, i fixed it now! i misinterpreted the nextInt(int n) method in the class Random. i didn't think carefully about what [0, n) meant.
|
|