mastermind
1.0.0
故意練習。
該練習可用於練習軟件開發技術,學習新技術,尋找新的工作方式,等等。
傳統上,遊戲是使用:
一個解碼板,一端的屏蔽板覆蓋了一排四個大孔,還有十二行,包含四個大孔,旁邊有四個小孔
六種不同顏色的代碼釘,將放置在板上的大孔中
小鑰匙釘,一些彩色的黑色,一些白色,將放在板上的小孔中
資料來源:維基百科
在傳統的策劃遊戲中,有兩個玩家:
CODEMAKER-選擇一個四個代碼釘的圖案,然後將它們放入盾牌覆蓋的四個孔中。此秘密代碼僅對編號製造商可見。
CodeBreaker-試圖以順序和顏色猜測具有十二個轉彎的秘密代碼。每個猜測都是通過在解碼板上放置一排代碼釘來進行的。放置後,Codemaker通過猜測將零至四個鍵PEG放置在行的小孔中,提供反饋。
反饋帶有鑰匙釘:
從猜測中放置一個黑色鑰匙釘,每個代碼釘在顏色和位置上都是正確的
從猜測中放置一個白色鑰匙釘,每個代碼釘的顏色正確,但位置錯誤
如果猜測中有重複的顏色,則只有在秘密代碼中與相同數量的重複顏色相對應,才能將其授予鑰匙釘。
黑色鑰匙釘放在白色鑰匙釘之前
人們是講故事的人。因此,使用示例談論業務規則並記錄它們是一種非常有力的技術,可以快速建立共享的理解。
由於我們喜歡它的結構,因此我們選擇使用小黃瓜,但是任何格式都可以很好地工作。
筆記 | 小黃瓜是一種具有簡單結構的純文本語言。小黃瓜方案中顯示的示例旨在說明業務規則。 小黃瓜可以由非程序員使用,同時它的結構足以簡要說明業務規則及其自動化。 |
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