diff --git a/data/lessons.js b/data/lessons.js index b432f17..0cdbdf7 100644 --- a/data/lessons.js +++ b/data/lessons.js @@ -848,77 +848,6 @@ print("Done!") })() - }, - { - id: 'robot1', - title: '1. Moving the Robot', - tabtitle: 'Importing Modules', - level: 'robot', - content: ` -
This robot simulation is a simplified version of a real robot.
-It has a single library which you can use to access all its controls and sensors.
-In a real robot you would have many different libraries for different parts, sensors, and even microcontroller functions.
- -We'll start by importing the robot library, and using it to move.
-
-import robot # Import the robot library
-import time # Import the time module
-
-robot.move(1) # Move forward at max speed
-time.sleep(2) # Wait for 2 seconds
-robot.move(-1) # Move backward at max speed
-time.sleep(2) # Wait for 2 seconds
-robot.move(0) # Stop the robot
-
- `,
- objectives: [
- "Reach the first checkpoint",
- "Reach the second checkpoint",
-
- "Code should complete without errors"
- ],
-
- doneCondition: (() => {
- return ({ code, consoleText, codeRanGood, gameWorld }) => {
- const progress = {
- firstCheckpoint: gameWorld.waypointsReached[0],
- secondCheckpoint: gameWorld.waypointsReached[1],
- codeRanGood: codeRanGood,
-
- };
-
- if (!codeRanGood) {
- return { done: false, hint: "" };
- }
-
-
-
- // 5. Build hint
- const missing = [];
- if (!progress.firstCheckpoint) missing.push("reach the first checkpoint");
- if (!progress.secondCheckpoint) missing.push("reach the second checkpoint");
-
- let hint = "";
- if (missing.length === 1) {
- hint = `I still need you to ${missing[0]}`;
- } else if (missing.length > 1) {
- hint = `I still need you to ${missing.slice(0, -1).join(", ")} and ${missing.at(-1)}`;
- }
-
- return {
- done:
- progress.firstCheckpoint &&
- progress.secondCheckpoint &&
- progress.codeRanGood,
- progressArray: Object.values(progress),
- hint,
- };
- };
- })()
-
-
-
-
},
{
id: 'lesson10',
@@ -1022,5 +951,147 @@ print("Done!")
+ },
+
+ {
+ id: 'robot1',
+ title: '1. Moving the Robot',
+ tabtitle: 'Importing Modules',
+ level: 'robot',
+ map: 'Level 1',
+ content: `
+ This robot simulation is a simplified version of a real robot.
+It has a single library which you can use to access all its controls and sensors.
+In a real robot you would have many different libraries for different parts, sensors, and even microcontroller functions.
+ +We'll start by importing the robot library, and using it to move.
+
+import robot # Import the robot library
+import time # Import the time module
+
+robot.move(1) # Move forward at max speed
+time.sleep(2) # Wait for 2 seconds
+robot.move(-1) # Move backward at max speed
+time.sleep(2) # Wait for 2 seconds
+robot.move(0) # Stop the robot
+
+ `,
+ objectives: [
+ "Reach the first checkpoint",
+ "Reach the second checkpoint",
+
+ "Code should complete without errors"
+ ],
+
+ doneCondition: (() => {
+ return ({ code, consoleText, codeRanGood, gameWorld }) => {
+ const progress = {
+ firstCheckpoint: gameWorld.waypointsReached[0],
+ secondCheckpoint: gameWorld.waypointsReached[1],
+ codeRanGood: codeRanGood,
+
+ };
+
+ if (!codeRanGood) {
+ return { done: false, hint: "" };
+ }
+
+
+
+ // 5. Build hint
+ const missing = [];
+ if (!progress.firstCheckpoint) missing.push("reach the first checkpoint");
+ if (!progress.secondCheckpoint) missing.push("reach the second checkpoint");
+
+ let hint = "";
+ if (missing.length === 1) {
+ hint = `I still need you to ${missing[0]}`;
+ } else if (missing.length > 1) {
+ hint = `I still need you to ${missing.slice(0, -1).join(", ")} and ${missing.at(-1)}`;
+ }
+
+ return {
+ done:
+ progress.firstCheckpoint &&
+ progress.secondCheckpoint &&
+ progress.codeRanGood,
+ progressArray: Object.values(progress),
+ hint,
+ };
+ };
+ })()
+ },
+ {
+ id: 'robot1',
+ title: '2. Steering the Robot',
+ tabtitle: 'Importing Modules',
+ level: 'robot',
+ map: 'Level 2',
+ content: `
+ Turning is very similar to moving, we use the robot.turn(amount) function.
The amount parameter is a number between -1 and 1, where -1 is full left, 0 is no turn, and 1 is full right.
+import robot
+import time
+
+robot.turn(1)
+time.sleep(2)
+robot.turn(0)
+
+
+This code causes the robot to turn right at max speed for 2 seconds, then stop.
+ +You'll need to combine moving, turning, and waiting to reach all the checkpoints.
+Note: The values for move, turn, and sleep can all be decimal numbers (floats). ie time.sleep(0.5) or robot.move(0.8)