プリンキピア

第2章計算論的思考と設計の再利用性

CONCEPTS IN PRACTICE概念を実践する
Computational Thinking for Chess Problem-Solvingチェスの問題解決における計算論的思考
Computers can be used to help us solve problems. However, before a problem can be tackled, the problem itself and how it could be solved need to be understood. Computational thinking transcends mere programming; it doesn’t equate to thinking in the binary fashion of computers, as they fundamentally lack the capacity for thought. Rather, while programming is the craft of instructing a computer on the actions to execute, computational thinking empowers you to meticulously determine what those instructions should be. Take, for instance, the strategic gameplay involved in chess. To excel in a chess match, a player must:
英語のヒント
コンピューターは問題解決を助けるために使える。ただし、問題に取り組む前に、問題そのものと、その解き方を理解する必要がある。計算論的思考は、単なるプログラミングを超えるものである。コンピューターは根本的に思考する能力を持たないため、コンピューターのような二進法的な考え方をすることと同じではない。プログラミングがコンピューターに実行する動作を指示する技術であるのに対して、計算論的思考は、その指示が何であるべきかを注意深く見定める力を与える。たとえば、チェスの戦略的な駒の動かし方を考えよう。試合で優れた成績を収めるには、プレイヤーは次のことを行う必要がある。
• Understand the unique movements and strategic values of each piece, recognizing how each can be maneuvered to control the board.
英語のヒント
• 各駒に固有の動き方と戦略的価値を理解し、それぞれをどう動かせば盤面を支配できるかを見極める。
• Visualize the board’s layout, identifying potential threats and opportunities, and planning moves several steps ahead to secure an advantageous position.
英語のヒント
• 盤面の配置を思い描き、起こりうる脅威と好機を見つけ、有利な位置を確保するため、数手先まで計画する。
• Recognize patterns from previous games, understanding common tactics and counters, to formulate a robust, adaptable strategy.
英語のヒント
• 過去の対局からパターンを見いだし、よくある戦術とその対抗策を理解して、堅実で状況に適応できる戦略を立てる。
In devising a winning strategy, computational thinking is the underpinning framework:
英語のヒント
勝つための戦略を考案するとき、計算論的思考が土台となる枠組みを提供する。
• The complex game is dissected into smaller, more manageable components (e.g., the function of each chess piece, the state of the board)—this is decomposition.
英語のヒント
• 複雑なゲームを、各駒の機能や盤面の状態など、より小さく扱いやすい構成要素に切り分ける。これが分解である。
• Attention is concentrated on pivotal elements that influence the game’s outcome, such as the positioning of key pieces and the opponent’s tendencies, sidelining less critical factors—this is an abstraction.
英語のヒント
• 重要な駒の位置や相手の傾向など、勝敗を左右する決定的な要素に注意を集中し、重要度の低い要素は脇に置く。これが抽象化である。
• Drawing from prior knowledge and experiences in similar scenarios, a step-by-step approach is developed to navigate through the game—this is algorithmic thinking.
英語のヒント
• 似た状況での知識や経験をもとに、ゲームを進めるための段階的な方法を作る。これがアルゴリズム的思考である。
Should you venture into developing your own chess program or strategy, these are precisely the types of considerations you would deliberate on and resolve before actual programming.
英語のヒント
自分のチェスのプログラムや戦略を作ってみるなら、実際にプログラミングを始める前に、まさにこのような点をじっくり考え、解決することになる。
Testing and Debuggingテストとデバッグ
Testing and debugging are techniques used to identify flaws in algorithms and defects in code to be able to correct them. Test cases rely on providing specific input data to check whether a software program functions correctly and meets its designed requirements. Test cases need to be identified to drive tests. If a test associated with a test case fails, debugging needs to be conducted to identify the source of the problem and correct it. In other words, debugging is about locating and fixing defects (i.e., bugs) in algorithms and processes to make them behave as expected. In programming, everyone makes mistakes, they are part of the learning process. The important thing is to identify the mistake and work out how to overcome it. There are those who feel that the deepest learning takes place when mistakes are made.
英語のヒント
テストとデバッグは、アルゴリズムの欠陥やコードの不具合を特定し、修正できるようにする技法である。テストケースでは、特定の入力データを与えて、ソフトウェアが正しく動作し、設計上の要件を満たすかを確かめる。テストを進めるには、テストケースを特定する必要がある。テストケースに対応するテストが失敗した場合は、デバッグで問題の原因を突き止め、修正しなければならない。言い換えれば、デバッグとは、アルゴリズムや処理にある欠陥、すなわちバグを見つけて直し、期待どおりに動くようにすることである。プログラミングでは誰でも間違える。それは学習過程の一部である。重要なのは、間違いを特定し、それを乗り越える方法を考えることだ。最も深い学びは間違えたときに起こると考える人たちもいる。
In the jam sandwich algorithm, testing can be facilitated by taking turns to play the role of the programmer who gives instructions as well as the robot. If you are a programmer, your job is to read out the instructions and follow each step. You can choose to follow your pseudocode or your flowchart. Each instruction becomes a test case, and the test succeeds if the robot can follow every instruction exactly and successfully. In the alternative, you will need to debug the instruction to identify the source of the problem and correct it. Table 2.2 can be used to record problems encountered and improvements that need to be made.
英語のヒント
ジャムサンドイッチのアルゴリズムでは、指示を出すプログラマー役とロボット役を交代で演じると、テストをしやすい。プログラマーになったら、指示を声に出して読み、各手順に従うのが役目である。疑似コードに従うか、フローチャートに従うかは選べる。各指示がテストケースとなる。ロボットがすべての指示に正確に従い、うまく実行できれば、テストは成功する。そうでなければ、その指示をデバッグし、問題の原因を特定して直す必要がある。表2.2を使えば、見つかった問題と必要な改善を記録できる。
Test Case
テストケース
Input
入力
Problem
問題
Expected Outcomes
期待する結果
Observed Outcomes
観察された結果
Improvement
改善
Responsible User
担当する利用者
1.
2.
Table 2.2 Sample Table for Recording Test Problems and Improvements
表2.2 テストで見つかった問題と改善を記録する表の例
INDUSTRY SPOTLIGHT産業の現場から
DNA SequencingDNA塩基配列の決定
Computational thinking is important in every industry today. In DNA sequencing, computational thinking helps manage the massive and complex data involved. It starts by breaking the large DNA sequence into smaller pieces. Then, it involves identifying patterns or sequences within these pieces, which might indicate genetic information like the presence of certain genes. The focus is on the most relevant parts of the sequence, discarding unnecessary data to concentrate on potentially significant genetic regions. Finally, refined algorithms process and reconstruct the original sequence to identify genetic variations. This approach is used for efficiently handling massive datasets in DNA sequencing and extracting meaningful insights. The parts of computational thinking (CT) can be identified and highlighted in the process of DNA sequencing, a complex task within the field of genomics:
英語のヒント
計算論的思考は、今日のあらゆる産業で重要である。DNAの塩基配列決定では、膨大で複雑なデータの管理に役立つ。まず、長いDNA配列を小さな断片に分ける。次に、その断片の中にあるパターンや配列を見つける。それらは、特定の遺伝子の存在など、遺伝情報を示しているかもしれない。不要なデータを捨て、重要な可能性のある遺伝領域に集中することで、配列の最も関連性の高い部分に注目する。最後に、洗練されたアルゴリズムで元の配列を処理し、再構成して、遺伝的な違いを特定する。この方法は、DNA配列決定において膨大なデータセットを効率よく扱い、意味のある知見を取り出すために使われる。ゲノミクス分野の複雑な作業であるDNA配列決定の過程には、次のように計算論的思考(CT)の各要素を見いだし、示すことができる。
• Decomposition: Break down the DNA sequencing process into specific steps such as sample collection and DNA extraction.
英語のヒント
• 分解:試料の採取やDNAの抽出など、具体的な手順にDNA配列決定の過程を分ける。
• Pattern recognition: Identify similarities in DNA sequences that could indicate genetic traits or anomalies.
英語のヒント
• パターン認識:遺伝的な特徴や異常を示す可能性のある、DNA配列の類似点を見つける。
• Abstraction: Focus on the essential parts of the genetic information that are relevant for the study at hand.
• 抽象化:現在の研究に関係する、遺伝情報の不可欠な部分に注目する。
• Algorithms: Create step-by-step protocols for each part of the sequencing process.
英語のヒント
• アルゴリズム:配列決定の各工程について、段階的な実施手順を作る。
• Logical thinking: Determine the most accurate methods for sequencing based on the type of sample and the required depth of sequence analysis.
• 論理的思考:試料の種類と、求められる配列分析の深さに基づき、最も正確な配列決定方法を選ぶ。
• Evaluation: Assess the quality and accuracy of the sequencing data obtained.
• 評価:得られた配列データの品質と正確さを評価する。
• Debugging: Identify issues that may arise during the sequencing process.
英語のヒント
• デバッグ:配列決定の過程で起こりうる問題を特定する。