تمرين ممارسة متعمد.
يمكن استخدام التمرين لممارسة تقنيات تطوير البرمجيات ، وتعلم تقنيات جديدة ، وإيجاد طرق جديدة للعمل ، وما إلى ذلك.
تقليديا ، يتم لعب اللعبة باستخدام:
لوحة فك التشفير ، مع درع في نهاية واحدة تغطي صفًا من أربعة ثقوب كبيرة ، واثني عشر صفًا إضافيًا يحتوي على أربعة ثقوب كبيرة بجوار مجموعة من أربعة ثقوب صغيرة
أوتاد رمز من ستة ألوان مختلفة ، والتي سيتم وضعها في الثقوب الكبيرة على السبورة
أوتاد رئيسية صغيرة ، بعض اللون الأسود الملون ، وبعضها أبيض ، والذي سيتم وضعه في الثقوب الصغيرة على اللوحة
المصدر: ويكيبيديا
في لعبة العقل المدبر التقليدي ، يوجد لاعبان:
Codemaker - يختار نمطًا من أربعة أوتاد رمز ويضعها في الثقوب الأربعة التي يغطيها الدرع. هذا الرمز السري مرئي فقط لصانع الترميز.
CodeBreaker - يحاول تخمين الرمز السري الذي تصل إلى اثني عشر منعطفًا ، بالترتيب واللون. يتم تصنيع كل تخمين عن طريق وضع صف من الأوتاد الرمز على لوحة فك التشفير. بمجرد وضعها ، يوفر Codemaker ملاحظات عن طريق وضع صفر إلى أربعة أوتاد رئيسية في الثقوب الصغيرة للصف مع التخمين.
يتم توفير ردود الفعل مع أوتاد رئيسية:
يتم وضع ربط مفتاح أسود لكل ربط رمز من التخمين الذي هو صحيح في كل من اللون والموضع
يتم وضع ربط مفتاح أبيض لكل ربط رمز من التخمين الذي هو صحيح في اللون ولكن في وضع خاطئ
إذا كانت هناك ألوان مكررة في التخمين ، فلا يمكن منحها سوى ربط رئيسي إذا كانت تتوافق مع نفس عدد الألوان المكررة في الرمز السري
يتم وضع أوتاد المفتاح الأسود قبل أوتاد المفتاح الأبيض
الناس هم رواة القصص. لذلك ، يعد استخدام أمثلة للحديث عن قواعد العمل وتوثيقها تقنية قوية للغاية لبناء فهم مشترك بسرعة.
اخترنا استخدام 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