How to Develop a Wordle Game using TDD in 25 Minutes
6 September, 2022
4
4
1
Contributors
TL;DR: Implementing a working Wordle in a few minutes
TL;DR: With just a few steps we can build a robust Wordle.
Defining a word
Mixing (accidental) implementation details with (essential) behavior is a widespread mistake.
Notice
•
•
•
•
•
•
Error : Class "Wordle\Word" not found
Creating a Word
Notice
•
•
•
OK (1 test, 1 assertion)
Few Letters
Notice
•
Failed asserting that exception of type "Wordle\Exception" is thrown.
Changing current implementation
Notice
•
•
•
Checking Many Too Letters
Failed asserting that exception of type "Exception" is thrown.
OK (3 tests, 3 assertions)
Refactor (or not)
Valid Letter
Failed asserting that exception of type "Exception" is thrown.
OK (5 tests, 5 assertions)
More Invalid
Notice
•
Refactor
Notice
•
•
•
Comparing Words
Notice
•
•
OK (8 tests, 8 assertions)
More Words
Failed asserting that two arrays are equal.
Refactor
English Dictionary
Dictionary Tests
Notice
•
•
•
Count
Failed asserting that 0 matches expected 1.
Notice
•
•
Including Words
Error : Call to undefined method Wordle\Dictionary::includesWord()
Positive Case
Wordle Game
Creating Game Objects
Words tried
Error : Call to undefined method Wordle\Game::addtry()
Notice
•
Has Lost
Failed asserting that false is true.
Integrating the Dictionary
Play to Win
Notice
•
•
Winner Word
OK (8 tests, 10 assertions)
Letter Positions
OK (10 tests, 10 assertions)
Match
OK (23 tests, 25 assertions)
OK (26 tests, 32 assertions)
Future Steps
•
Manage different languages and characters.
•
Import the words from a text file.
•
Add a Visual Engine and host it.
•
Implement an Absurdle
•
Develop a machine-learning algorithm to minimize wordle moves.
Repository
Conclusion
test
tutorial
php
code
clean
tdd
driven
development