make_a_maze_world
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| make_a_maze_world [2022/08/30 12:18] – frchris | make_a_maze_world [2023/09/17 11:21] (current) – frchris | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Make A Maze World ====== | ====== Make A Maze World ====== | ||
| + | ====== Step 1 ====== | ||
| 1. Make a new Java Project called '' | 1. Make a new Java Project called '' | ||
| import java.awt.Graphics; | import java.awt.Graphics; | ||
| Line 227: | Line 228: | ||
| }</ | }</ | ||
| + | |||
| + | ======Step 2====== | ||
| 2. As written it will Make 10 rows and 10 columns, but feel free to change this. | 2. As written it will Make 10 rows and 10 columns, but feel free to change this. | ||
| + | ======Step 3====== | ||
| 3. Keep clicking it until you have one you like, and take a screen shot with | 3. Keep clicking it until you have one you like, and take a screen shot with | ||
| Coomand-Shift-4 | Coomand-Shift-4 | ||
| Line 234: | Line 238: | ||
| {{:: | {{:: | ||
| + | ======Step 4====== | ||
| 4. Look for it on your Desktop and rename it with your name (For example it might be called '' | 4. Look for it on your Desktop and rename it with your name (For example it might be called '' | ||
| + | ======Step 5====== | ||
| 5. Next you are to use these commands to make a .kwld text file. Here is an example That Describes BobS.png: | 5. Next you are to use these commands to make a .kwld text file. Here is an example That Describes BobS.png: | ||
| - | < | + | < |
| KarelWorld | KarelWorld | ||
| streets 7 | streets 7 | ||
| Line 264: | Line 270: | ||
| {{:: | {{:: | ||
| - | You can put your file in the same folder as the project | + | To see your progress, you can put your text file in the same folder as the |
| <code java ShowWorld.java> | <code java ShowWorld.java> | ||
| Line 273: | Line 279: | ||
| public static void main(String[] args) | public static void main(String[] args) | ||
| { | { | ||
| - | World.setDelay(30); | + | |
| // change the file name to match the text file | // change the file name to match the text file | ||
| // you made and put in the project folder: | // you made and put in the project folder: | ||
| + | | ||
| World.readWorld(" | World.readWorld(" | ||
| - | World.setVisible(); | ||
| World.setBeeperColor(Color.BLUE); | World.setBeeperColor(Color.BLUE); | ||
| - | + | World.setVisible(); | |
| } | } | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | Try removing or changing a wall in the BobS.txt file to get a feel of how the code changes the KarelWorld drawn by the ShowWorld main method. | ||
| + | |||
| + | ======Step 6 ====== | ||
| + | 6. Now it is your turn. Make a new text file (or rename " | ||
| + | |||
| + | When you are done, place 2 beepers in the best locations for the longest run for a MazeRunner robot. | ||
| + | |||
| + | |||
| + | === For those will experience with placeEWWall and placeNEWall === | ||
| + | For those who are used to the [[http:// | ||
| + | <code java World.java> | ||
| + | |||
| + | /** | ||
| + | * This is a replacement for the World | ||
| + | * found in karelworld.jar | ||
| + | | ||
| + | * to help you convert your placeWall statements | ||
| + | * with the format needed for a kwld text file format. | ||
| + | * | ||
| + | * @author Chris Thiel | ||
| + | * @version Sept 4, 2022 | ||
| + | */ | ||
| + | public class World | ||
| + | { | ||
| + | public static void placeEWWall(int str, int ave, int len) | ||
| + | { | ||
| + | int end = ave + len - 1; | ||
| + | String result = " | ||
| + | System.out.println(result); | ||
| + | } | ||
| + | | ||
| + | public static void placeNSWall(int str, int ave, int len) | ||
| + | { | ||
| + | int end = str + len - 1; | ||
| + | String result = " | ||
| + | System.out.println(result); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Alternatively your can use placeWall methods and save the world to file. | ||
| + | ====== Links to Karel and KarelWorld Reference ====== | ||
| [[http:// | [[http:// | ||
| + | ====== Show and Tell ====== | ||
| + | Go to [[https:/// | ||
make_a_maze_world.1661876296.txt.gz · Last modified: 2022/08/30 12:18 by frchris