Learn How to Think with Karel the Robot. Appendix A. Karel App in NCLab

Appendix A
Karel App in NCLab

The Karel app is located in the Programming section of the Creative Suite on NCLab’s Desktop. It allows you to create your own mazes and games, write your own programs, save them in your NCLab user account, and publish them online and share with others. In this chapter, we will show you how to launch the Karel application and how to use it.

A.1. Launching the Karel app

The Karel app opens with a demo program:


Figure A.1: *

The Karel app in programming mode, with a demo program.

The top menu bar includes three items: File, Settings, and Help along with two zoom icons. The File menu allows you to open a new instance of the application, open an existing file, save the maze to a file, etc. The Settings menu allows you to change the robot’s speed, show/hide the status bar, highlight the active line of the code, etc. The status bar is located on the bottom of the window and it displays important information about the status of the robot.

The Karel app has 4 modes: Manual, Programming, Designer, and Games. The Manual mode allows the user to guide the robot using the mouse or keyboard. For more information about the Manual mode visit Program 2.1 on page 26.

The Programming mode makes it possible to write, execute, and debug programs for Karel. For more details about the Programming mode visit Program 2.5 on page 46.

A.2. Building mazes

The Designer mode allows you to create your own mazes, save them in your NCLab user account, and to share them with others online. This is how the Karel app looks in Designer mode:


Figure A.2: *

The Karel app in Designer mode.

The Designer has its own menu on top:


Figure A.3: *

Designer menu.

From left to right, the functions of the menu buttons are as follows:

Themes: The Designer offers over 20 different themes including Zoo, Garden, Mines, Desert, Jungle, Factory, Mountains, etc. In each theme, there are several wallpapers to choose from. For example, five wallpapers are available in the Jungle theme. Clicking on a wallpaper will install it to the maze:

Figure A.4: *

Jungle theme wallpapers.

Obstacles: The Obstacles button is the second one from the left in the Designer menu, and it has a grey wall on it. There are more than 40 different obstacles including wall, fire, water, stone, acid, etc. To install an obstacle into the maze, click on it and then click into the maze. There are two types of obstacles: thin (one-dimensional) and thick (two-dimensional). The thin ones occupy an edge of a square. The thick ones take an entire grid square. There are 21 different types of walls.
Collectible objects: Over 60 different types of collectible objects are available under the pumpkin button (third one from the left).
Containers: Containers (the fourth button from the left with a basket on it) are objects which can store other objects in them. When placing a container, one can specify its capacity as well as the types of objects that it admits. Karel has 14 types of containers: mark, target (target is invisible to the user, mark is visible), box, bag, basket, mining cart, etc.
Erase mode: The button with the red mark “X” on it is used to remove individual objects, containers, or obstacles from the maze. If this button is toggled, one can move the mouse over the maze and start removing objects. One can remove everything except for the robot and his home square. The home square can be hidden in the Maze menu which is located above the maze.
Erase all: Pressing the button with the eraser mark on it will instantly remove all objects, containers and obstacles from the maze. This comes handy when one is starting to design a completely new maze.
Random mode: When this button is toggled, obstacles, collectible objects, and containers will be added to random positions in the maze as one clicks on them in the left panel.
Undo: This is the fourth button from the right. The Designer remembers all your actions (since the app was last launched), so all of them can be undone using this button.
Redo: If you have used the Undo button, then this button will undo the undo.
Left: The left arrow button will turn Karel left 90 degrees.
Right: The right arrow button will turn Karel right 90 degrees.

Besides this, one can use the mouse to drag and drop the robot, the home square, as well as all the obstacles, collectible objects, and containers.

When the maze has unsaved changes, the button "Save maze" will start flashing, reminding you to click on it and save maze changes. If the maze hasn’t been saved yet, then the File Manager will launch, asking you to choose a folder and filename. Otherwise, the maze will just be saved to the existing file and the button will stop flashing.

A.3. Create your own game!

Let’s create a game! First of all, you need to figure out a story and a task for Karel. Today, Karel will be exploring an abandoned gold mine and collecting nuggets. However, he must beware of skulls and radiation! If comes across them, he must pass them either on the right or on the left.

The first step in creating a game is to launch the Karel app and write the story. For this, click on the welcome message of the Karel app. The text will open in a WYSIWYG text editor. The editor allows you to insert and remove text, change text size, font and color, insert images, code snippets, and even videos, and do many other things.

Although sometimes one is tempted to write a long and intricate story, keep in mind that the story is not the main objective of the game. Make it short and sweet. And most importantly - precise. It should be perfectly clear to the users what the game goal is.


Figure A.5: *

Writing the story in the WYSIWYG text editor.

When you are satisfied with the story, hit "Save" in the upper left part of the text editor. This will save the text and exit the editor.


Figure A.6: *

After exiting the editor, the story is ready.

At this point you can still lose all your changes (for example, if your computer gets disconnected from the Internet). So, let’s save the file in your NCLab account. This can be done by clicking on "Save in NCLab" in the File menu:


Figure A.7: *

Saving the file in your NCLab account.

This will launch the File Manager, and you will be able to enter the file name as well as select the folder where your game should be saved. We saved the file under the name "In the Mines":


Figure A.8: *

When the file is saved, the name is displayed in the header.

The next step is to build a maze to match the story. You already know from Section A.2 how to do that, so we will leave this step to you. Try to come up with your own maze! The maze we created is shown below:


Figure A.9: *

The Designer is used to build the maze for the story.

When your maze is finished, do not forget to click on the blinking button "Save maze" before leaving the Designer.

A.4. Check how difficult your game is

It is very easy to build a maze which is extremely difficult or impossible to solve. Therefore, at this point, it is important that you try and solve the maze by yourself. When you plan for your game to be in manual mode, switch to Manual mode and solve it. When your game will be in programming mode, then switch to Programming mode and write the corresponding program. Here is our program which is based on the First Maze Algorithm, enhanced with additional tests for skulls and radiation:

1while not home 
2  go 
3  if nugget 
4    get 
5  if wall or skull or radiation 
6    left 
7    if wall or skull or radiation 
8      right 
9      right

That was not too difficult, was it? Nine lines is a short code. But to achieve this most elegant solution, the user needs to realize that the skulls and radiation should be treated just as additional types of walls. Not everybody will do that - most frequently the users will try to handle the walls and the remaining obstacles separately. Then their code will be longer, and they should get fewer points for that. This brings us to the next step - defining game goals.

A.5. Convert worksheet into a game

In order to define game goals, we need to convert the worksheet into a game first. This is done by clicking on "Convert into game" in the File menu:


Figure A.10: *

Converting the worksheet into a game.

This is an irreversible change, so be sure that you want to do this. The menu in the upper part of the window will change:


Figure A.11: *

After converting into a game, the upper menu changes.

The button "Play game" can be used to play the game as if you were the user. But we are not there yet. First, we need to define game goals. For this, click on "Edit game". Then the following menu will appear:


Figure A.12: *

Edit game menu.

In the column on the left you will see many different flags. Each flag represents one language - in case you want to have your game translated into several languages. The top menu contains the following items:

  • Solution: This is where you insert the correct solution (in Programming mode only).
  • Initial code: This is where you insert the code that the user should see at the beginning (if any).
  • Code template: This is where you insert help code (if any). The user will see he Code template button when they start the game.
  • Pages: This is where you can add / edit / remove introductory pages with explanations.
  • Hints: Here you can specify hints which the user will obtain after the first failure, second failure, etc.
  • Links: Here you can specify links to a PDF document and a tutorial video.
  • Goals: Here you define game goals. We will discuss this step separately.
  • Variables: Here you can specify variables whose values should be checked at the end.

A.6. Define game goals

The panel used to define game goals is shown below. It contains the following items:

  • Steps: Here you can limit the maximum number of steps Karel is allowed to make.
  • Max. operations: Here you can limit the maximum number of operations.
  • Objects to collect: In case you want Karel to collect some ojects in the maze but not all, here you can state their number.
  • Collect all objects: Check this box if Karel is supposed to collect all objects in the maze.
  • Victory message: Here you can type a custom victory message. The first_name in the curly braces will be replaced by the user’s name as defined in his/her Settings.
  • Face direction: If you want Karel to face a given direction (West, East, South or North) after the game finishes, select it here.
  • Max. lines / points: This is where you specify how many points the user is getting for various numbers of lines. Typically, the shorter the program, the more points.
  • Stepping mode only: This option will force the user to step through the code.
  • Lock code: Checking this box will freeze the code - it will become non-editable.

    Figure A.13: *

    Game goals panel.

  • Enable Code Sharing for students: This option is used when creating courses.
  • Mode: Here you choose whether your game should be in Manual or Programming mode.
  • Fill all containers: If the maze contains containers, here you can require that Karel fills them all.
  • Finish: Here you choose where Karel should be when the program ends.

The rest are technical options used for course creation.

A.7. Final test

After game goals have been defined, you need to press the "Play game" button and try to solve the puzzle as a user would. This will make sure that all game goals can be fulfilled and the game is solvable.


Figure A.14: *

Playing the game in user mode.

That’s it, your game is now ready! In the next section we will show you how to share it with others, and let them play it.

A.8. Publish your game in the Internet!

Let us now publish our example game and share it with others. For this, one needs to open the File menu and click on "Publish to the web":


Figure A.15: *

The File menu offers "Publish to the web".

A window “Publishing options” should open:


Figure A.16: *

Selection of “Anyone can view and run”.

Here, you will be offered several options for publishing your game. This is the generic publishing menu for all programs in NCLab, so some of the options may not be relevant at this moment.

We recommend the option “Anyone can view and run”. This will allow the users to view and play your game, but they will not be given access to the Edit menu and to the Designer - hence they will not be able to modify their copy of the game. If you wanted to enable them to do that, you would select the last menu option with the most access. BTW, do not worry about the users changing your original game worksheet - they cannot. Even if they are allowed to make changes, it is only in their copy.

Finally, you can post the public link to the game directly to social networks using the corresponding buttons. Or, you can copy the link and share it with others, for example, via email. Anybody with this link will be able to click on it and play your game.

Table of Contents

Created on September 27, 2018 in Karel.
Add Comment
0 Comment(s)

Your Comment

By posting your comment, you agree to the privacy policy and terms of service.