Online since 2002. Over 3300 puzzles, 2600 worldwide members, and 270,000 messages.

TwistyPuzzles.com Forum

It is currently Thu Apr 17, 2014 4:42 am

All times are UTC - 5 hours



Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Gridworld
PostPosted: Thu May 12, 2011 9:44 pm 
Offline
User avatar

Joined: Wed Jan 28, 2009 7:55 pm
Location: Montana
Gridworld is the AP Computer Science case study provided by College Board as an educational resource to Java programming. Beyond what case studies are shown here, the world has a huge potential for constructing games and models. Here is a list of what I've made so far:

-Maze Generator and Solver
-Genetic Inheritance model (along with a realistic simulation)
-Mine Sweeper game
-Snake Game (Yoshi theme)
-Pong Game (Mario theme)

Along with eight other programs I haven't recorded videos of.

My question to you guys is: have you ever used Gridworld? If you have, what beyond the case study have you made?

_________________
Andreas Nortmann wrote:
Things like this are illegal.
If not I will pass an appropriate law.


Last edited by Ender Delphiki on Sat May 14, 2011 10:51 am, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: Gridworld
PostPosted: Fri May 13, 2011 12:50 am 
Offline
User avatar

Joined: Thu Dec 31, 2009 8:54 pm
Location: Bay Area, California
Rentlix wrote:
Gridworld is the AP Computer Science case study provided by College Board as an educational resource to Java programming. Beyond what case studies are shown here, the world has a huge potential for constructing games and models. Here is a list of what I've made so far:

-Maze Generator and Solver
-Genetic Inheritance model (along with a realistic simulation)
-Mine Sweeper game

Along with eight other programs I haven't recorded videos of.

My question to you guys is: have you ever used Gridworld? If you have, what beyond the case study have you made?
You should give some cellular automata simulations a go. Conway's game of life is fun to play with. I once saw somebody build a Turing machine that computed the prime numbers with a complicated game of life setup. I spent hours exploring and trying to reverse-engineer that setup.

One fun thing is to try to find the longest cycle possible for a given board size like 64x64 cells. You can setup the program to keep track of all previous states so that you can automatically spot cycles and immediately compute their length. Another fun thing to do is to try to find a starting pattern that goes for hundreds or thousands of turns before it either dies or gets stuck in a cycle.

Finally, there are other cellular automata simulations other than "life" that can create geometric fractals like Sierpinski's triangle and such.

_________________
Prior to using my real name I posted under the account named bmenrigh.


Top
 Profile  
 
 Post subject: Re: Gridworld
PostPosted: Fri May 13, 2011 1:22 am 
Offline

Joined: Sat Feb 12, 2011 8:32 pm
I took an AP Computer Science class and must say that Gridworld is quite fun. One of our projects was to design a habitat with various insects that we designed. We had to designs 8 different insects and 3 various types of food in our habitat. Each insect had its own health, life (determined by the number of steps the insect takes), and damage (how much damage it would do to other insects). Our ultimate goal was to build a sustainable habitat where all insects and plants never completely wiped each other out. For example, if one insect was too powerful or bred too quickly, it would quickly take over the habitat. If there were too many insects in the grid, all the food would be eaten and none would be left to spread (therefore causing the lowest-tier insects to die and effectively killing off all the other insects). In my class we were only given a total of 20 or so hours to design this habitat and the longest running habitat lasted for about 20 minutes. (Other things we had to deal with was: how the bug moved, how it turned, how it reacted when meeting other bugs, how it reacted when hitting walls, how far it could see, what bugs it could eat, how long carcasses of dead bugs lasted before deteriorating, predation (i.e. stalking other bugs), and the list keeps going on and on).

I really enjoyed it because it gave me freedom to try things out on my own. At the same time, the program isn't very complex and it isn't the most refined thing in the world.

We were also tasked with designing bugs which could traverse mazes through trial and error. We had to design a bug that had toremember where it had already traveled and made sure not to backtrack into dead ends. At the same time, the bug still had to know how to backtrack somewhat in order to get to new entrances in the maze. This was one of the hardest projects my teacher gave us, and with the mediocre teaching that he had given us it was very hard to do. Eventually my teacher ended up scrapping this project.

_________________
http://www.youtube.com/twoasiancubers - Twisty reviews, speed-solves, and unboxings.
http://cgi.ebay.com/ws/eBayISAPI.dll?Vi ... 500wt_1413 - Auction for Helicopter Dodecahedron and lots of other awesome puzzles!


Top
 Profile  
 
 Post subject: Re: Gridworld
PostPosted: Fri May 13, 2011 10:08 am 
Offline
User avatar

Joined: Wed Jan 28, 2009 7:55 pm
Location: Montana
Yep, we had to design a stable environment as well. The Genetic Inheritance model I linked to is a piece of my project. We had one week to program it. In two days I had completed a stable world which would be capable of running continuously for the entire class period of 90 minutes. I added genetics (in the video) and disease, both contagious and genetic. I had each niche present, and things as little as going back to the lake when it gets thirsty programmed into that. Carnivores would seek out a prey and hunt it, and prey would try to avoid the carnivore when being hunted. Otherwise, they moved according to their own AI. Adding features like this to stimulate what happens in real life is the key to balancing the world. Of course mine was the only to balance out in my class.

The maze solving bug I've linked to was another one of our school projects. We only had two class periods to work on it, but only one person in my class didn't finish it.

Minesweeper was a challenge others in my class gave me. It works but I'm getting a problem with revealing regions of all empty squares. It's supposed to be that when a cell selected has a value of 0, it reveals all the adjacent squares (recursively revealing a region of 0s), but for some reason it just reveals itself and leaves (this is because I've moved the removeSelfFromGrid() earlier to hid the error. However, when the line is placed where it should be, as displayed below, it has a stack overflow error when I click an empty square, and when a click a square that has a value of 1 (which means it shouldn't even reach the recursive revelation) it reveals a bunch of cells with seemingly no pattern.

Code:
public void reveal(){
   if(!gameOn)return;
   if(val==0){
      Cell cell;
      for(int i=0;i<8;i++){
         try{
            if(getGrid().get(getLocation().getAdjacentLocation(i*45))instanceof Cell){
               cell=(Cell)(getGrid().get(getLocation().getAdjacentLocation(i*45)));
               cell.reveal();
            }
         }
         catch (Exception e){}
      }
      removeSelfFromGrid();
   }
   if(val==-1){
      (new Bomb()).putSelfInGrid(getGrid(),getLocation());
      gameOn=false;
   }
   if(val==1)
      (new One()).putSelfInGrid(getGrid(),getLocation());
//rest of method irrelevant
}


Any advice?

_________________
Andreas Nortmann wrote:
Things like this are illegal.
If not I will pass an appropriate law.


Top
 Profile  
 
 Post subject: Re: Gridworld
PostPosted: Fri May 13, 2011 2:43 pm 
Offline

Joined: Sat Feb 12, 2011 8:32 pm
Sorry, can't really help you there! I hate to point fingers but our teacher was pretty horrendous. He often rambled about concepts that we used and refused to show us how his concepts could be implemented. He also could never write code that would compile the first time through. I barely passed the class with a 3 on the AP test and a B average. I actually ended up learning more from my friend than from my teacher. You're environment is really impressive; we had a lot of time to complete the environment but many of us had little success. I took that class as junior in high school; I loved the concept of the class, but I feel like my time was wasted in that class. The AP test ultimately boiled down to using for loops to store data in arrays and then returning that data; we didn't really spend much time on that concept (although I understood it quite well).

_________________
http://www.youtube.com/twoasiancubers - Twisty reviews, speed-solves, and unboxings.
http://cgi.ebay.com/ws/eBayISAPI.dll?Vi ... 500wt_1413 - Auction for Helicopter Dodecahedron and lots of other awesome puzzles!


Top
 Profile  
 
 Post subject: Re: Gridworld
PostPosted: Fri May 13, 2011 8:20 pm 
Offline
User avatar

Joined: Wed Jan 28, 2009 7:55 pm
Location: Montana
One concept my teacher always pointed out about every AP test there's ever been in Computer Science: there's always the removal of an array. Normally, traversing an array start to end testing for removals means you're skipping one element per removal. In every test you have to deliberately code around that directly in the rubric. My teacher taught us to for(int i=arr.length;i>=0;i++) since it goes backwards, so you don't get skipping. The alternative to this is to use for-each loop.

EDIT: I just added Snake to the list in the original post. It took me not even an hour, which really surprised me.
EDIT: I just added Pong as well.

_________________
Andreas Nortmann wrote:
Things like this are illegal.
If not I will pass an appropriate law.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Forum powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group