This lab contains a written part (which can be either typed or handwritten and will be checked in class on Monday) and a coded part (which will be submitted in your turn in folder). The coded part will all be due by Sunday, March 10, at noon.
-------------------------SETTING UP GRIDWORLD: --------------------------------
The GridWorld code is in the Gridworld.zip file in this folder (https://drive.google.com/drive/folders/124OKC1zgDE7M8ccQ-mZjqoo-XtMufwQM?usp=sharing). Download it, unzip it, and move the GridWorldCode folder to your g:/ drive. This folder contains two sub-folders - framework (the actual code for the visual interface and objects) and projects (this is where you will do your work). I also include a .pdf of the old quick reference guide for your reference as well as a gridworld.jar file you will need.
If you want to see the actual code behind the scenes, go to framework/info/gridworld folders. The java files are sorted into various folders. To open and work on different projects, open the projects folder and click on those.
In order for this code to compile, you will need to load the GridWorld.jar file into your libraries in blueJ (go to tools, preferences, libraries, add, then find the Gridworld.jar file, then click on the button to reset the java virtual machine) so the code will compile. On a school computer, you may need to do this every day (sorry).
I have also made a video showing the setup process here: https://www.youtube.com/watch?v=KtgfbYr42fI
------------------------------------------------------------------------------------------------
---------------------------------------------PART ONE------------------------------------
Our goal here is to set up GridWorld, experiment with it, and start to get an idea of what is going on in the code behind the scenes.
Read through the "part 1" .pdf file from my shared folder (https://drive.google.com/drive/folders/124OKC1zgDE7M8ccQ-mZjqoo-XtMufwQM?usp=sharing) and complete all of the exercises inside (questions 1-10 and exercises 1-4 at the end) using the part 1 folder under projects. Please put your answers on a sheet of paper or a google doc. When you are finished, feel free to experiment more with GridWorld and play around with the different methods available or move on to the next part
------------------------------------------------------------------------------------------------
----------------------------------PART TWO/THREE------------------------------------
Throughout this lab you will need to call many methods from various parts of GridWorld. These method names can be seen in the old quick reference guide. There is a copy in the zip file. This will be helpful as you ask questions like "how can I access the grid my bug is in?" or "how do I get a list of empty adjacent locations?" These can be answered by looking at the methods contained in Grid, Location, Actor, etc.
LAB DIRECTIONS: (for some tips and hints, scroll down to the bottom)
*NOTE: in BlueJ, remember to import the gridworld.jar library as seen in class so your code will compile
1. Complete part 2 of the official GridWorld task on working with Bug objects in the part 2 .pdf document here (https://drive.google.com/drive/folders/124OKC1zgDE7M8ccQ-mZjqoo-XtMufwQM?usp=sharing). Do the following tasks.
-Read through the narrative carefully.
-You will need to type the answers to questions 1-4 on page 3 (you may skip questions 5-7). This is part of the written component of this lab and will be submitted in class. (BoxBug is in the part 2 and 3 of the "projects" folder of the GridWorld code)
-You will write your code in the project called part 2 and 3. You will only need to write one class named CircleBug.java. ***DO NOT WRITE THE ZBUG, SPIRALBUG OR DANCINGBUG CLASSES (unless you are bored)***.
-To help you test your code, I have written a driver class called GW23Driver.java and included it in the project folder. Make sure that this Driver stays in your BlueJ project folder, as this is what I will (modify and) use to test your code. When you submit your project, you will turn in the entire project folder
2. Complete part 3 of the official GridWorld task on several of the classes in GridWorld in the official part 3 .pdf document in this folder (https://drive.google.com/drive/folders/124OKC1zgDE7M8ccQ-mZjqoo-XtMufwQM?usp=sharing).
-Read this CAREFULLY, there is a lot of good stuff in here! This material will be INCREDIBLY important as you get ready for your final project. Note that several parts refer to an "interface" - we did not learn about these but they are basically the same as abstract classes.
-You will need to write up (either by hand or in a google doc) the answers to the questions on pages 4, 6, 8, 10. Please ONLY answer questions: all on page 4, questions 1-2 on page 6, questions 2 and 5 on page 8, and questions 1-7 on page 10. You may SKIP all other questions.
-You will code and include in your project folder Jumper.java (just code it by yourself as usual, not in a group). To complete Jumper, you may want to check out how a Bug’s “move” method works so you can write your own for Jumper.
Here are some clarifications for the ambiguity in the problem statement of Jumper:
-you should extend Actor (since a Jumper doesn't drop flowers)
- it should not eat any other objects at any point or make them disappear.
-it should not be able to jump unless the space it would land on is empty.
-If it cannot jump two spaces, it should try to move one space forward. If it cannot do that (because of an obstacle or a wall), it should turn.
You may ignore the optional “what makes it run” part.
-------------------------------------------------------------------------------------------------------------------------------
GRIDWORLD TIPS AND TRICKS:
1. For a guide on how to write your own classes which extend classes in GridWorld and your own driver classes, see the folder I put in here (https://drive.google.com/drive/folders/124OKC1zgDE7M8ccQ-mZjqoo-XtMufwQM?usp=sharing).
2. As an extra note, whenever you write a GridWorld program, make sure to include these import statements:
import info.gridworld.actor.*; //this loads Actor, Bug, Critter, etc.
import info.gridworld.grid.*; //this loads all the Grid and Location stuff
import java.util.*; //ArrayList, etc.
import java.awt.Color; //colors
3. If you are putting an Actor a (or flower, or anything else which extends Actor) in a grid, use a.putSelfInGrid(...). Do NOT use the .put method in grid. Similarly, if you are removing a, call a.removeSelfFromGrid(), NOT the .remove method in grid. This will make sure the Actor also knows it has been added/removed.
4. There is a big difference between checking if a Location object isValid() and checking if it isOccupied() - valid just means that it is part of the grid and not out of bounds. Occupied checks to see if there is something in that spot.
-------------------------------------------------------------------------------------------------------------------------------
Again, make sure you submit your entire project folder containing Jumper.java, CircleBug.java and GW23Driver.java (the version I wrote is fine). Do NOT upload the entire GridWorldCodeBlueJ folder, just the updated "part 2 and 3" folder in projects. Make sure to have the written parts ready to show me in class either on paper or on a computer!