|
BoneDig
Nov 25, 2001 21:57:17 GMT -5
Post by JackOfAllTrade on Nov 25, 2001 21:57:17 GMT -5
Thanks! This will help me. How did you check to see if a bone has already been buried before burying another one? How/Where did you put the if statement to check this? JOAT The order in which you choose to hide the lines of bones does not matter. Ie. if you hide the 4 bone line first and then the two 3 bone lines, it doesn't matter. The only thing that you have to make sure is random is the placement. Ie. first randomly choose whether it will go north-south or east-west and then randomly choose which row/column it will go in. I used the Random class, I hope that's the right way. I made a Random called random, ie - Random random = new Random(); and then used that. It says there must be a 50% probability in the outline for north-south or east-west and I used nextInt() to select both my direction and column/row. I may have to change it to a boolean if it must be a 50% chance but I'm not sure. I've finished my whole program and it works but I'm just not completely sure on some of the details. The hardest thing is not making the game but fulfiling all their stuff about having an input-output class seperate and making sure you can change the grid size through just changing one line.
|
|
|
BoneDig
Nov 25, 2001 22:28:48 GMT -5
Post by Observer on Nov 25, 2001 22:28:48 GMT -5
I used a 2D String array for the assignment. I have a method for burying bones and in that, the same time I randomly selected the placement I had a if statment to ONLY place the line of bones if none of the places where it was to be potentially put. I did this by comparing the string at that particular point in the array.
Ie. if one of the points contents that had been randomly selected to place a bone did not equal the character I was using for bones but equalled a "." (for not guessed) it was okay to place a bone down. All of that if statement was of course in a loop so that continued to go round until a place that had no bones could be chosen for the new bones I was planning to put down. So:
if ( map[randomInt][anInteger] == ".") { <then place the bone> }
where map is the name of the array and those two things in the brackets are random ints (well, one of them is, the other you'll just be incrementing from 0 to the length of the bone). But you'll have to make sure all of the points potentially in the line where the bones are to go are equal to "." (or whatever symbol you're using) before placing any bones at all.
This is all rather vague and probably FAR more confusing than it really is and I'm really sorry about that. I just don't know whether I can give actual examples without actually showing exactly how to do it. One piece of advice: it's good that you are attempting this now. It would be extremely difficult IMO to do this the night before.
|
|
|
BoneDig
Nov 26, 2001 6:47:14 GMT -5
Post by Majin_Blues on Nov 26, 2001 6:47:14 GMT -5
Also does anyone know if the grid size have to be put in the main method? I have mine in the bury bones class. hrmm I used to have majin buu pics but lost them all in a format im sure they are not too hard to find though. it sounds as if it doesn't have to be... all they say is that you should be able to change the size of the grid by only changing one line... thanks for the info but i was looking for "fat buu" animated gifs from a game called "Dragonball Z: Hyper Dimension"... those are really hard to find
|
|
|
BoneDig
Nov 26, 2001 19:42:14 GMT -5
Post by 1.8T on Nov 26, 2001 19:42:14 GMT -5
ok i got my prog to randomly place lines of size, 4, 3, 3, 2 on the grid, ., but i notice it being really really slow in going through all those loops i made., just to make sure i don't generate a line length that i've already used., (works for when line lenght =3) .. how fast do you ppl generate that grid?. mine takes around 15-20 seconds., which is pretty bad., like the way i did it is sooo sooo slow it works though., will they deduct marks if it runs slow?. hahaha
|
|
|
BoneDig
Nov 26, 2001 19:58:16 GMT -5
Post by bladehunter on Nov 26, 2001 19:58:16 GMT -5
;D i don't know about my prog since once i ran it the grid was already made.
About deduction of marks, i don't think the autotester will deduct marks for that, but maybe the TAs will for inefficient style.
|
|
|
BoneDig
Nov 26, 2001 20:04:25 GMT -5
Post by 1.8T on Nov 26, 2001 20:04:25 GMT -5
oh.,. ic,. crap., cuz if i do it so that it goes through 4 things instead of 10x10 things x like 10x10 times. hahaha, i guess it'll be much quicker but then the programming would be redundent,. , the way i did it , was made it into a static method, and call that method with parameter the length of the lines, 4, or 3, or 3, or 2, so in my program i call this method 4 times,. inside this method i have the check and save to grid part., and it generates a random line length ., compares to the paramenter, if it equals then do all that stuff if it doesn't , it randomly generates another line length., and continues until it equals the parameter../ .. either i do that., or i make like 8 if statements like so: (line length 4, direction 0) (line length 4, direction 1) . . . . (line length 2, direction 1) but this way of doing it is redundent and won't let u 'easily' change the program in the future.. any suggestions?..
|
|
|
BoneDig
Nov 26, 2001 21:14:18 GMT -5
Post by 1.8T on Nov 26, 2001 21:14:18 GMT -5
OMG, i made this so much more difficult for myself., .., do the length of the bones have to be picked randomly from size, 4, 3, 3, 2? like for first bone , do we hafta randomly pick if its length 4, 3, 3, 2 ?. ,or its just predefined in our program and we place bones in the order, 4, 3, 3, 2 , or any order?. like, it does not require us to randomly picked the length right?. ,? confused,.
|
|
|
BoneDig
Nov 26, 2001 21:25:26 GMT -5
Post by SquirrelHunterPro on Nov 26, 2001 21:25:26 GMT -5
Quick question... how can I do a System.out.println(.....) with a 1 dimensional array as the output... meaning I want to output all the elements in the array onto 1 line. could someone plz show or tell me how....
I cant believe the president had to feel if Raiden had balls.... so funny.... cant blame him, Raiden looks so girly, how the hell did he become the platoon leader?
|
|
|
BoneDig
Nov 26, 2001 21:46:12 GMT -5
Post by 1.8T on Nov 26, 2001 21:46:12 GMT -5
you do this
System.out.print (.....)
hope that helped., but isn't this wut u did to output the dot's for the grid?. how else do u do it?
|
|
|
BoneDig
Nov 28, 2001 17:11:13 GMT -5
Post by Brutal_Chicken on Nov 28, 2001 17:11:13 GMT -5
Just a question... how many static methods do you guys have in total? I have a total of 0.
|
|
|
BoneDig
Nov 28, 2001 17:21:30 GMT -5
Post by 1.8T on Nov 28, 2001 17:21:30 GMT -5
b4 i had like 3 or 4, now i have 0 ., .if u guys made it with static methods., its not that hard to change it back...,
|
|
|
BoneDig
Nov 28, 2001 17:23:18 GMT -5
Post by gundamf91 on Nov 28, 2001 17:23:18 GMT -5
static all the way for me....
|
|
|
BoneDig
Nov 28, 2001 17:27:09 GMT -5
Post by 1.8T on Nov 28, 2001 17:27:09 GMT -5
but the assignment says don't use that many static methods., ., cuz u would wanna change the program later . or something
i duno., i don't see how having static methods would prevent u from changing your program., ., .,., oh well
anyways. when u guys are displaying the grid with user's guesses only -meaning, does not display the lines of the grid.,
did u guys just put an if statement comparing if there exists a bone ? and if so,. display it as a "." to hide it?? .
|
|
|
BoneDig
Nov 28, 2001 18:33:14 GMT -5
Post by Brutal_Chicken on Nov 28, 2001 18:33:14 GMT -5
Look at it this way; Do you really need to show two copies of the grid with one just showing ' . ' a hundred times with bones 'buried' underneath or two separate grids: one that's just empty as is and another that actually shows where the bones are. All you have to do then is to check on your 'master' grid if a bone exists there and place the corresponding answer to your display grid. No need to have two grids with one having embedded bones.
|
|
|
BoneDig
Nov 28, 2001 19:38:04 GMT -5
Post by 1.8T on Nov 28, 2001 19:38:04 GMT -5
but when i generated the bones on the grid i stored it on the grid, ., so whenever i try to print the grid after generating the lines., the lines would show., here's wut i did: if ((grid[row][col]==".")||(grid[row][col]=="o") ||(grid[row][col]=="-")) inOut.print(grid[row][col]); else if (grid[row][col]=="x") inOut.print("."); where inOut.print is calling out my print method using this i can print a grid just showing the user's guesses, where its right or wrong ., and the places where the user didn't guess yet., without showing where the bones are actually stored.. / Look at it this way; Do you really need to show two copies of the grid with one just showing ' . ' a hundred times with bones 'buried' underneath or two separate grids: one that's just empty as is and another that actually shows where the bones are. All you have to do then is to check on your 'master' grid if a bone exists there and place the corresponding answer to your display grid. No need to have two grids with one having embedded bones.
|
|