แบบฝึกหัดการฝึกฝนโดยเจตนา
แบบฝึกหัดสามารถใช้ในการฝึกเทคนิคการพัฒนาซอฟต์แวร์การเรียนรู้เทคโนโลยีใหม่ ๆ ค้นหาวิธีการทำงานใหม่ ๆ ฯลฯ
ตามเนื้อผ้าเกมเล่นโดยใช้:
กระดานถอดรหัส ที่มีโล่ที่ปลายด้านหนึ่งครอบคลุมแถวของรูขนาดใหญ่สี่แถวและแถวเพิ่มเติมสิบสองแถวที่มีสี่รูขนาดใหญ่ถัดจากชุดของสี่หลุมเล็ก ๆ
หมุดรหัส หกสีที่แตกต่างกันซึ่งจะวางไว้ในรูขนาดใหญ่บนกระดาน
หมุดคีย์ ขนาดเล็กสีดำบางสีขาวบางสีซึ่งจะวางไว้ในรูเล็ก ๆ บนกระดาน
ที่มา: Wikipedia
ในเกมผู้บงการทั่วไปมีผู้เล่นสองคน:
Codemaker - เลือกรูปแบบของหมุดสี่รหัสและวางไว้ในสี่หลุมที่ปกคลุมด้วยโล่ รหัสลับนี้สามารถมองเห็นได้สำหรับผู้สร้าง 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