Gridworld Bugs

Using the Java SDK with TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
User avatar
Javian85
Posts: 7
Joined: Thu Nov 22, 2007 5:03 am

Gridworld Bugs

Post by Javian85 »

Me and my friend are taking a AP Computer Science class...it is mostly based on Java and Java-script. We often get free time to experiment with gridworld and the coding for it. This week we were assigned to create a bug code with methods such that it is able to move about in a fixed grid so it looks like an infinite symbol (with two steps on each side). With the help of a circle method, would there be a way to create a code for the said infinite symbol? I apologize if this is too vague of a description to share any advise, but like always any information will come in handy. Thanks.
:D Javian85
User avatar
Nicholas Jordan
Posts: 124
Joined: Mon Dec 20, 2004 12:33 am
Location: Central Texas ISO Latin-1
Contact:

grid bugs

Post by Nicholas Jordan »

It took me awhile to figure out what you are saying, you need to look at java's graphic resources. I have never been able to discover how to make graphics, java or otherwise, but one always gets this assignment in advanced placement computer science work. I will take the code home and look at it, but that is what you are supposed to be doing.

Also, moderator - move this to Java. ( :) )

From Moderator: Done, thanks. :roll:
User avatar
Javian85
Posts: 7
Joined: Thu Nov 22, 2007 5:03 am

Post by Javian85 »

Yeah I was afriad I wasn't going to be able to describe it enough to get the right idea for everyone lol...sorry( :oops: )...however the best way I can describe it is if you ever had played around with the coding for the bugs in gridworld you would have a somewhat understanding of how they function in terms of java script (i.e. making it move forward, backwards, side-ways, and even more complex ways make their movement to represent a box or circle with the flowers they produce)...this assignment slightly stumped us...we needed to formulate a code to represent the infinite sign (or an "8" in 90 degree rotation) with the bug making two steps for each side of the sign in the gridworld...we've been working on it for the past two days (mainly with the help of our previously created circle-bug java code as a referrence) and this was our embarrasing last resort...- :cry: ...so anything you have will be greatly appreciated :D Thanks again.
:D Javian85
User avatar
Nicholas Jordan
Posts: 124
Joined: Mon Dec 20, 2004 12:33 am
Location: Central Texas ISO Latin-1
Contact:

getting going

Post by Nicholas Jordan »

Okay, that's what I thought - just pull a little information and we can get up like 300 horsepower skeeter boat driven by Evin Rude - the world is ours now ~ only if it is just a grid on a computer screen. Don't drive a bass boat with 300 horsepower, but you can do it on the screen.

Start like this:

Code: Select all

short [][] pictureArray = new short[8][8];//
Now remember that we are starting up, several things may garner comments by people who know how to use Java Graphics. Remember you can always punch in the question you would ask me or others into google or the java dot sun website, that is slow to get results but it is what the rest of us have to do. Most people put the double sqare brackets on the other side of the word pictureArray, but that is just a name. See java naming conventions as a search topic. The above code gets you a box much like a crossword puzzle that has 8x8 squares. I want you to sit down and put some character in a box you draw yourself shaping and infinity symbol, no matter how crude...

Keep working on it for a day or two and let me know what you are stuck on but try to work from the idea that the [][] is equivalent to rows and columns on a crossword puzzle. Maybe you decide to change short ( a numeric type ) to character, or color or boolean: Just keep in mind that the double square brackets translates to:

Code: Select all

* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
Post Reply