見出し画像

Minecraft: Education Editionでのプログラミングを大人の人に興味を持ってもらう#3(New Professional Development pathway to engage Adult Learners for "Minecraft Education Edition MakeCode Programming" #3)


注意点

2022/10/24時点で、本記事で取り上げている機能は最新版の教育版マインクラフトv1.18.32へのバージョンアップ時に発生したバグのために試すことができないことに注意が必要だ。このバグについてはフィードバック済みで次のリリースで修正される見込みだ。
It should be noted that as of 10/24/2022, the features discussed in this article cannot be tried due to a bug that occurred when upgrading to the latest version of M:EE v1.18.32. Feedback on this bug has been provided and is expected to be fixed in the next release.

なお、現在解説中の内容をまとめた資料が『教育版マインクラフトでオリジナル MakeCode ブロックをつくろう – 授業・校務活用素材ポータル』で入手可能となっているのでアクセスしてみて欲しい。多少手間はかかるものの、現時点でのバグの回避方法にも言及している。
A document summarizing the contents currently being explained is available at "
Let's Make Original MakeCode Blocks with M:EE - Portal of Materials for Classroom and School Work". Although it takes some time and effort, it also mentions how to work around the bugs at the moment.

最短距離で結果を体験する

前回は、見た目や理屈は一旦横に置いておき、とにかく動くカスタムブロックのつくり方を最短距離で体験することを目的とした解説を行った。

しくみを理解している方からすればやや雑な印象を受けるかもしれないが、一通り実際に動作するところまでの全体の流れを体験しておくことで全体像把握を優先した。

その理由として、カスタムブロックを作成するプロセスは基本的に毎回同じ手続きを踏んで行うことになるため、その流れを何度も繰り返す際に全体の操作の流れを体験しておくことでトラブルを最小に抑制することが可能と考えたためだ。

その後、徐々にポイントを深掘りしていくことで理解を少しずつ深めていく方が抵抗感を抑制することが可能ではないかという仮説をもとに実施している。

Experience results in the shortest possible time.
In the previous issue, we set aside appearance and logic for the moment and explained how to create a working custom block in the shortest possible time. Although this may seem a bit tedious for those who understand how it works, we prioritized understanding the big picture by experiencing the entire process up to the point where the block actually works.

The reason for this is that the process of creating a custom block is basically the same procedure each time, so we thought it would be possible to minimize problems by experiencing the overall flow of operations when repeating the process over and over again.

The process was then implemented based on the hypothesis that it would be possible to suppress resistance by gradually deepening the understanding of the process through gradual deepening of the points.

では、次の本題に入ろう。
Now, let's get to the next main issue.

引数を渡したい

今回は、ブロックの数値引数を実際にコードに渡すことでロケット花火の連射数を変更するカスタムブロックとなるように実装を行ってみたい。
I want to pass arguments
In this case, we would like to implement the block so that it is a custom block that changes the number of rocket fireworks fired in rapid succession by actually passing the numerical arguments of the block to the code.

引数を渡したい

サンプルのカスタムブロックfooには見ての通り、数値型・文字列型・列挙型の引数が3つ定義されている。
今回は連射の数を変えたいので数値型のところに注目してカスタムブロックのコードを読んでみよう。
As you can see, the sample custom block foo defines three arguments of numeric, string, and enumerated types. In this case, we want to change the number of consecutive shots, so let's read the code of the custom block, focusing on the numerical type.

カスタムブロックのコードfoo関数には3つの引数があり、ブロックの見た目の対応は以下の通りとなる。
The code foo function of the custom block has three arguments, which correspond to the appearance of the block as follows.

引数対応

ブロックの方では見えないが、JavaScript側では引数の変数名と型が指定されているのがお分かりだろうか。
You can't see it in the block, but you can see that the variable name and type of the argument are specified on the JavaScript side.

数値の5の部分はJavaScript側では「n」という数値型変数と対応しているのでブロックの方に書いた数値が変数nに代入されることになる。
少なくともこの時点で変数nには5という数値が入っているし、数値を変更すればその値が変数nに代入されている(ただし、連射するコード中では使われていない)。
The 5 part of the number corresponds to a numeric type variable called "n" on the JavaScript side, so the number written in the block will be assigned to variable n.
At least at this point, the variable n contains the number 5, and if the number is changed, that value is assigned to the variable n (but it is not used in the code that fires in rapid succession).

それがどういうことかというのをJavaScriptコードを見て確認してみよう。
Let's look at the JavaScript code to see what that means.

連射数はどこに?

現在のカスタムブロックは、ロケット花火を5連射する状態なので5という数字を探してみて欲しい。
すぐに見つかるはずだ。
The current custom block is in the state of firing 5 rocket fireworks in a row, so look for the number 5.
You should find it soon.

連射数は5

ここの数値が決め打ちで書かれているので繰り返し回数が固定されてしまっているのだ。
では、繰り返しの数を変更可能とするためにはどうしたら良いだろうか。
The number of repetitions is fixed because the values here are written in a fixed format.
So, what should we do to make the number of repetitions changeable?

ヒントは「ブロックの数値は何に代入されるのか」だ。

先ほども触れていたように、ブロックの数値は変数nに代入される、というのが正解だ。この変数nに代入された数だけ繰り返しするためには、先ほどのJavaScriptのどこを変更すれば良いだろうか。
As was mentioned earlier, the correct answer is that the number of blocks is assigned to variable n. In order to iterate over the number of times assigned to this variable n, what should be changed in the JavaScript mentioned earlier?

繰り返し回数を変数にする

先ほどの決め打ちで書かれていた数値の5の部分を変数nで置き換えることで、ブロックから引き渡された数値が入っている変数n回分繰り返すように変えられることになる。
By replacing the 5 part of the numerical value that was written in the previous definite form with the variable n, it can be changed to repeat for the variable n times, which contains the numerical value passed down from the block.

上記の変更をしてからブロックモードに切り替えて、foo関数の数値部分を50とか100などに書き換えて実行してみて欲しい。
After making the above changes, please switch to block mode, rewrite the numeric part of the foo function as 50, 100, etc., and execute it.

この変更によって連射数は明らかに変わるはずである。
This change should obviously change the number of consecutive shots.

次は「ブロック名」を変更することにチャレンジしてみよう。
Let's try to change the "block name" next.

大人向け研修会での知見について

こちらの記事で紹介している内容は、大人向け研修会で実施した内容に基づいている。その際のアンケート結果についても紹介しておこう。

Findings from the workshop for adults
The information presented in this article is based on content conducted at a training session for adults. The results of the survey conducted at that time are also presented here.

まず、前提知識についての問いとしてMakeCodeでカスタムブロックが作れることについて聞いた。
First, as a prerequisite knowledge question, we asked about the ability to create custom blocks in MakeCode.

前提知識について

回答者の大半は今回の内容は知らないという状況だ。つまり、今回体験する作業は初めての経験となる。
冒頭で触れた仮説がこの研修会を通じてどのように受けとめられのかは追って紹介していく。
The majority of respondents were unaware of the content of this project. In other words, the work they will experience this time is new to them.
How the hypotheses mentioned at the beginning of this report will be received through this workshop will be presented later.

授業・校務活用素材ポータルで資料配布中

教育版マインクラフトでオリジナル MakeCode ブロックをつくろう – 授業・校務活用素材ポータル』で入手可能となっているのでアクセスしてみて欲しい。現時点でのバグの回避方法にも言及している。


この記事が気に入ったらサポートをしてみませんか?