User Tools

Site Tools


labs:minecraft

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
labs:minecraft [2017/05/12 15:07]
mikoenig [Exercise 2]
labs:minecraft [2020/08/31 21:05] (current)
Line 7: Line 7:
 Even though most tasks can be solved using only one turtle, parallelization is the key to do them quickly. This introduces a few synchronization issues that you need to deal with: how to divide the task among the turtles and how to prevent turtles from crashing into each other. Even though most tasks can be solved using only one turtle, parallelization is the key to do them quickly. This introduces a few synchronization issues that you need to deal with: how to divide the task among the turtles and how to prevent turtles from crashing into each other.
  
-**Important**:​ To prepare your machines locate and execute the setup script found in ''/​opt/​Uebungen/​turtles''​. ​Ensure ​you have selected ​the "forge" ​profile ​in the Minecraft launcher ​to start the modded version of Minecraft. We will provide you with Minecraft accounts for this lab.+Don't worry, if you've never played Minecraft beforeThere is a lot of content to the game, but for this lab you just need to know that the world is made of a 3D grid of blocks, which can be mined ("​dug"​) to obtain them as "item" in one's inventory, allowing one to place them somewhere else.
  
  
-==== Exercise 0 ==== +===== Setup ===== 
-Open the example ​Eclipse ​project and run it on a singleplayer worldYou can find both Eclipse and Minecraft ​in the "start menu"​. +  * Before opening ​Eclipse ​or Minecraft, ​run ''/​opt/​Uebungen/​turtles/​setup.sh''​. 
-If you can't find the turtle moving about, try printing its location ​using ''​System.out''​ or using a flat world (seed: ​"qwer"). +  * Run Eclipse and Minecraft ​from the "start menu"​. 
-If you have trouble understanding what's going on, be sure to check out the [[labs:​minecraft#​Hints|Hints section]] below!+  * Log into Minecraft (we will provide ​you with accounts for this lab) and launch ​the game using the "forge" ​profile (set in the bottom left of the launcher). 
 +  * Open a singleplayer worldfor example the one we pre-installed for you. Turtles may now be created by connecting on the port 7473.
  
  
-==== Exercise 1 ====+===== Exercise 0 ===== 
 +Run and read through the example program ("​TurtleMain"​). 
 +If you can't find the turtle moving about, try printing its location using ''​System.out.println(turtle.getLocation())''​. 
 +==== Hints ==== 
 +  * In Minecraft the y coordinate is used for the height axis: near 0 you will encounter indestructible bedrock blocks, while ocean level is 64. 
 +  * By pressing F3 in Minecraft an overlay showing various information can be displayed. This is particularly useful for finding a certain coordinate. 
 + 
 + 
 +===== Exercise 1 =====
 Your first real task is to build a simple 3x1x3 grid (i.e., horizontal, height 1) of blocks at height y = 90 centered right above the spawning location. Your first real task is to build a simple 3x1x3 grid (i.e., horizontal, height 1) of blocks at height y = 90 centered right above the spawning location.
-The goal here is to get accustomed to the API. Keep in mind that turtles need to collect some blocks before being able to place any!+The goal here is to get accustomed to the [[http://​computercraft.info/​wiki/​Turtle_%28API%29|API]]. Keep in mind that turtles need to collect some blocks before being able to place any!
  
-Note that once turtles start placing blocks in the correct spots, the progress of the building will be displayed in in-game chat.+==== Hints ==== 
 +  * Once turtles start placing blocks in the correct spots, the progress of the building will be displayed in in-game chat
 +  * If a turtle function call fails (i.e., returns false), you can use the ''​getFailureReason()''​ method to obtain a string containing the reason. The reason will also be output to stderr. 
 +  * A turtle can interact with the 3 blocks in front of, above and below them. To access other blocks it needs to move or turn. 
 +  * Turtles have an inventory of 16 slots labeled 1 through 16, all starting out empty. A slot can hold up to 64 of any single block type. When a block is mined it is placed in the first slot of its type (if there is any) or into the first empty slot (if there is not). Use the ''​select(int slot)''​ function to choose which slot is used for actions, e.g., for placing blocks from. 
 +  * We extended the [[http://​computercraft.info/​wiki/​Turtle_%28API%29|Turtle API]] by 2 additional methods to allow a turtle to determine its position and orientation in the world: ''​getLocation()''​ and ''​getFacing()''​.
  
  
-==== Exercise 2 ====+===== Exercise 2 ====
 +**Setup:** Copy ''/​home/​lab/​local-data/​turtles/​exercise2/​ComputerCraft.cfg''​ over the existing file of the same name in ''/​home/​lab/​.minecraft/​config'',​ and restart Minecraft. 
 Now that you have understood the basics, it is time to add some parallelization! Build tower hollow of height 10 with a 5x5 area and a few holes in the side (see whiteboard). The tower should be made of cobblestone only (block name ''​minecraft:​cobblestone''​). Now that you have understood the basics, it is time to add some parallelization! Build tower hollow of height 10 with a 5x5 area and a few holes in the side (see whiteboard). The tower should be made of cobblestone only (block name ''​minecraft:​cobblestone''​).
 +Again, the tower should start at y = 90 and be centered around the spawning location.
  
-Try to complete this task as quickly as possible by using as many turtles as you can handle! On world seed "qwer" 50 seconds is a good time. The assistants'​ record is 47.seconds.+Try to complete this task as quickly as possible by using as many turtles as you can handle! On world seed ''​qwer''​ 60 seconds is a good time. The assistants'​ record is 43.seconds.
  
-To tell the mod to detect the towerdownload [[http://​www.disco.ethz.ch/​members/​mikoenig/​ComputerCraft.cfg|this config file]] and place it in your /​home/​lab/​.minecraft/​config folder. Again, the tower should start at y = 90 and be centered around the spawning location.+==== Hints ==== 
 +  * Use ''​getItemDetail()'' ​to find out what materials you picked up. 
 +  * All function calls are blockingi.e., they only return once the operation is complete or has failed. 
 +  * In Java, two strings ''​a'' ​and ''​b''​ are compared by calling ''​a.equals(b)''​.
  
-Hint: Use ''​getItemDetail()''​ to find out what materials you picked up! 
  
- +===== Exercise 3 =====
-==== Exercise 3 ====+
 The room will be divided into two teams, each of which will be provided a server. The goal is to collaboratively build a cobblestone pyramid larger than that of the other team! The room will be divided into two teams, each of which will be provided a server. The goal is to collaboratively build a cobblestone pyramid larger than that of the other team!
  
- +This is a very open-ended task. Feel free to focus on smaller parts of the problem, such as the efficient harvesting of cobblestone from the game world. 
-==== Hints ==== +===== General ​Hints ===== 
-  * Don't worry, if you've never played Minecraft before. There is a lot of content to the game, but for this lab you just need to know that the world is made of a 3D grid of blocks, which can be mined ("​dug"​) to obtain them as "​item"​ in one's inventory, allowing one to place them somewhere else. +  * When creating a world, you may want to turn cheats on to allow you to switch to spectator mode
-  * When creating a world, you may want to turn cheats on to allow you to switch to spectator mode using the command "/​gamemode 3" (press '​T'​ to open a text box in game). +  * Entering ​the command "/​gamemode 3" ​enables you to fly around ​(press '​T'​ to open a text box in game). 
-  * A random seed for a world without much obstruction near the spawn point is "qwer".+  * A random seed for a world without much obstruction near the spawn point is ''​qwer''​.
   * If something goes wrong, you can easily get a clean world by selecting an existing one from the menu and choosing "​Re-Create"​.   * If something goes wrong, you can easily get a clean world by selecting an existing one from the menu and choosing "​Re-Create"​.
-  * In Minecraft the y coordinate is used for the height axis: near 0 you will encounter indestructible bedrock blocks, while ocean level is 64. 
-  * By pressing F3 in Minecraft an overlay showing various information can be displayed. This is particularly useful for finding a certain coordinate. 
-  * Turtles have an inventory of 16 slots labeled 1 through 16, all starting out empty. A slot can hold up to 64 of any single block type. When a block is mined it is placed in the first slot of its type (if there is any) or into the first empty slot (if there is not). Use the select(int slot) function to choose which slot is used for actions, e.g., for placing blocks from. 
-  * All function calls are blocking, i.e., they only return once the operation is complete or has failed. 
-  * If a turtle function call fails (i.e., returns false), you can use the getFailureReason() method to obtain a string containing the reason. The reason will also be output to stderr. 
-  * A turtle can interact with the 3 blocks in front of, above and below them. To access other blocks it needs to move or turn. 
-  * We extended the [[http://​computercraft.info/​wiki/​Turtle_%28API%29|Turtle API]] by 2 additional methods to allow a turtle to determine its position and orientation in the world: getLocation() and getFacing(). 
   * Singleplayer worlds pause when the window loses focus unless you select "Open to LAN" in the menu.   * Singleplayer worlds pause when the window loses focus unless you select "Open to LAN" in the menu.
labs/minecraft.1494594450.txt.gz · Last modified: 2020/08/31 21:05 (external edit)