Users who have LIKED this post:
What algorithms have you been doing on the Microbits?
In our microbit project we were able to choose different tutorials which showed us algorithms to follow in order to make a code for games. An algorithm is a type of instruction the computer follows. I was able to code, a compass script, a spinner script, whack a mole script, pong script, catch the egg script. The compass script shows weather you are facing North, South, East or West. I attempted to improve the algorithm by adding a NE, NW, SW, SE, I wasn’t able to finish it but if we had more time in the future I would come back and debug my code. The spinner script is coded to show and arrow facing a random way when it has been shaken, this was quite a simple algorithm but it enabled me to discover my way round the set up, I explored new variables and I included a variety of if else codes in my algorithms. My Whack a mole script was an advanced algorithm it was harder to follow, because the computer didn’t show you where all the pieces of code were. To attempt this I had to know my way around simple variables, loops, else if and plotting lights. This code required a lot of debugging and eventually I was able to completely debug it after many attempts and place the script onto my microbit. The catch the egg script was quite simple once you gained an understanding of what the pieces of algorithms meant and did. I was unable to complete the pong script, I attempted this script on my second go at making an algorithm which was a big step, because I had little experience with the touch develop coding style. I was used to doing the block coding style which is much more simple all you have to do is drag pieces of block code onto your script. If we had more time I would come back to my script and finish it having gained more knowledge since then.
How has sequencing affected your code?
Sequencing is vital in your code if the sequencing is wrong it can have a knock on affect with your whole code. It doesn’t matter how little is wrong it will still affect your code and your game will not work properly. Before compiling the scripts I checked my sequencing was correct, I found the easiest way to check is to compile that game and play it on your micro bit. Having understood your code, if there is something wrong you know your sequencing is wrong and you can debug and change the algorithm. Sequencing on the touch develop tutorials were easier, because it told you if and where you had made a mistake as you went along.
Have you debugged any thing? Provide examples.
The Whack a mole script needed a lot of debugging, because it was not on a tutorial mode I just had to refer to a picture of the code which could easily be misread. I managed to use my own knowledge to adapt the script so it worked properly. I debugged section by section and changed the sequencing to the correct order. Eventually I got the game running and displayed it on my microbit. Other scripts required debugging as I went along which made it a bit more time efficient, because you don’t have to go through the whole script again to try and find the bug.
What variables have you used when programming the microbit?
I used the GameRunning?, ButtonPressed?, Mole position, start time, change item to, change item by number. The game running variable is used to start and stop your game it is usually attached to a true or false block. The ButtonPressed? variable is also usually attached to a true or false block. It is used to determine what the game does if A or B is pressed. The mole position variable is used before plotting where the LEDS are suppose to be. I used this variable in the whack a mole game. Start time before the running time input. The change item to variable is used to change something the script is telling the computer to do so that the code tells the computer to do something else. E.g. Change – time- to 60
Have you used any loops?
I have used loops in almost all my scripts, loops are used to repeat a script forever, when the script is ended the computer will read that script from the top again and carry on doing this for as many times you code it to, e.g. repeat — times, do. The ‘do’ is used so they computer knows what to follow for —– times. Another loop I used was the while do loop, it tells the computer to do two things at a time, e.g. while button A pressed, set time to.
What are functions and how have you used them?
Functions are sections of a program that performs a specific task. We used them to save us from writing the same piece of code over and over again. In your code once you have selected the function name you need to code a mini script of how the function is going to work, you need to put in ‘end function’ at the end so that the computer knows where the mini function code ends and the rest of the script starts again. E.g. Dance function, code the character to dance then, ‘end function’ later on if you need to make your character dance again on instead of coding the dance part again select the dance function you have coded already. Functions allow us to save space and time.
This project was very interesting, because we got to see how easy it is to change someones look. I think this project went well, I was able to change most exercises in good quality. If I did this again I would aim to do more tasks in the time given. Overall I enjoyed this topic.
Users who have LIKED this post: