意図的な練習演習。
この演習は、ソフトウェア開発技術の実践、新しいテクノロジーの学習、新しい作業方法を見つけるために使用できます。
従来、ゲームは以下を使用して再生されます。
4つの大きな穴の列を覆う一方の端にシールドがあり、4つの小さな穴のセットの横にある4つの大きな穴を含む12列の追加の列を備えたデコードボード
ボード上の大きな穴に配置される6つの異なる色のコードペグ
小さなキーペグ、いくつかの色の黒、いくつかの白、ボード上の小さな穴に配置される白いもの
出典:ウィキペディア
従来の首謀者ゲームには、2人のプレイヤーがいます。
CodeMaker- 4つのコードペグのパターンを選択し、シールドで覆われた4つの穴にそれらを配置します。この秘密のコードは、コーデマーにのみ表示されます。
CodeBreaker-順序と色の両方で12回転を伴う秘密のコードを推測しようとします。各推測は、デコードボードにコードペグの列を配置することによって行われます。 CodeMakerは、列の小さな穴にゼロから4つのキーペグを推測で配置することにより、配置されたらフィードバックを提供します。
フィードバックにはキーペグが提供されます。
色と位置の両方で正しい推測からコードペグごとに黒いキーペグが配置されます
色が正しいが間違った位置にある推測からのコードペグごとに白いキーペグが配置されます
推測に重複した色がある場合、秘密コードの同じ数の重複色に対応する場合にのみ、キーペグを授与することができます
黒いキーペグは、白いキーペグの前に配置されます
人々はストーリーテラーです。したがって、例を使用してビジネスルールについて話し合い、それらを文書化することは、共有された理解を迅速に構築するための非常に強力なテクニックです。
Gherkinはその構造が気に入っているため、Gherkinを使用することを選択しましたが、どんなフォーマットも同様に機能します。
注記 | Gherkinは、単純な構造を持つ単純なテキスト言語です。 Gherkinのシナリオに示されている例は、ビジネスルールを説明するためのものです。 Gherkinは、ビジネスルールとその自動化の簡潔な説明を可能にするのに十分なほど構造化されている間、非プログラマーで使用できます。 |
Feature : Playing mastermind
As a code breaker
I want to practice breaking codes
In order to have fun
Scenario : Joining the game
Given a decoding board of 12 attempts
And the code maker has placed a secret on the board
When I join the game
Then the game should be started with an empty board
And I should have 12 attempts available
Scenario Outline : Making a guess
Given a decoding board of 12 attempts
And the code maker placed the "<Pattern>" code pattern on the board
When I try to break the code with "<Guess>"
Then the code maker should give me "<Feedback>" feedback on my guess
Examples :
# Feedback legend:
# B - Black - Correct colour and position
# W - White - Correct colour but wrong position
| Pattern | Guess | Feedback |
| Red Green Blue Yellow | Red Purple Purple Purple | B |
| Red Green Blue Yellow | Purple Purple Purple Purple | |
| Red Green Blue Yellow | Purple Red Purple Purple | W |
| Red Green Blue Yellow | Red Purple Green Purple | B W |
| Red Green Blue Yellow | Red Green Blue Purple | B B B |
| Red Green Blue Yellow | Red Yellow Blue Green | B B W W |
| Red Green Blue Yellow | Yellow Blue Green Red | W W W W |
| Red Green Blue Yellow | Red Green Blue Yellow | B B B B |
| Red Green Blue Yellow | Red Red Red Purple | B |
| Green Red Blue Yellow | Green Yellow Red Blue | B W W W |
| Green Red Blue Yellow | Red Green Yellow Blue | W W W W |
| Green Red Blue Yellow | Green Red Yellow Blue | B B W W |
| Red Green Red Yellow | Red Red Purple Purple | B W |
| Red Red Red Yellow | Red Green Purple Purple | B |
| Red Red Blue Yellow | Purple Purple Red Purple | W |
| Red Blue Blue Yellow | Purple Purple Red Red | W |
Scenario : Winning a game
Given a decoding board of 12 attempts
And the code maker placed the "Red Green Blue Yellow" secret on the board
When I try to break the code with an invalid pattern 11 times
But I break the code in the final guess
Then I should win the game
And I should no longer be able to make guesses
Scenario : Losing a game
Given a decoding board of 12 attempts
And the code maker placed the "Red Green Blue Yellow" secret on the board
When I try to break the code with an invalid pattern 12 times
Then I should lose the game
And I should no longer be able to make guesses