Passing a parameter to the program using the console and on chat command. An on chat command in a MakeCode program open in code connection can be activated by entering its name in the Minecraft console. Parameters for the on chat command can be passed by leaving a space and putting the parameter value.
For example: The on chat command: On chat command <command> <variable> The console: <command> space <value>
TASK Try making a MakeCode program that does what the pseudocode asks.
Using MakeCode in Minecraft allows programs to sense the environment. An example of this could be detecting something in front of the agent.
Some examples of sensor blocks are:
These sensors allow the agent to gain knowledge of the environment. They can be effectively used to add a degree of intelligence to the program. For example when an agent detects a wall it seems to know when the wall ends and then stops and moves over it and down the other side.
TASK Complete the task which uses a sensor to help the agent detect a block in front of it. The program uses a variable to hold a value of the height of the wall so it can descend the same number of blocks it climbed.
These are smallish chunks of code that do one specific task. They can be called by their name (In MakeCode they cannot use parameters). They are called from the main program (usually after an on chat command). These functions help the organisation of the program in small easy to understand units.
These are added to the code to explain what the code does and how it does it. These comments are added for the programmer and other people that need to understand the code.
For achieved: documenting the program with comments For merit: documenting the program with variable names and comments that describe code function and behaviour
In the agent climbs the wall program there is no comment to explain what the item variable is used for. Also the variable name item is not descriptive of its use so it could be renamed to 'height'. In the example below the before pseudocode is at achieved level and the after pseudocode is at merit level.
TO ADD A COMMENT
Right click on the block you want to add a comment to
Choose Add Comment
Click the ? to add the comment to the displayed box
TASK Open the Agent Climbs the Wall program. Add comments to Achieved or Merit level.
Using say to track programs progress
At important points in the program, say can be used to let the user know what is happening. This can be useful debugging your program.
Add Say blocks to inform the user what the program is doing.
TESTING & DEBUGGING
A program needs to be carefully tested to find bugs (problem with the operation of the program). The bugs are fixed until the program meets the standard required. Expected test cases: these are the things your program should do. The things that must work for the program to operate.
For achieved: testing and debugging the program to ensure that it works on a sample of expected cases A good way to find expected test cases is to look at everything the program should do. Make a list. Five are needed for achieved and ten for merit. Expected test cases activity
BOUNDARY TEST CASES
These are situations that may not occur often but if not tested may cause your program to fail and would be a bug in the program. For merit: testing and debugging the program in an organised way to ensure that it works on expected and relevant boundary cases.
Comprehensive testing At least ten expected and five boundary test cases are tested and documented. The program has been comprehensively been tested and debugged. For excellence: comprehensively testing and debugging the program.