cover-img

How to Create a Wordle as a Centaur

Use the best available tools wisely

16 October, 2022

4

4

0

Why you should use modern AI programming tools
I've been using Wordle as an analogy for serious software development.
In this article, I will combine the TDD solution that created a good model with an automated code generated using Artificial Intelligence.

TL;DR: Use the best available tools wisely

Divide and Conquer

The Division

I have written several articles on software development.
I will talk about Worlde to represent serious software.
In the first one, I created a backend Wordle using TDD and PHP.
Next, I watched a video on how to fully develop a Wordle using Automatic Code Generation.
Since Wordle is another Kata, I keep practicing it with TDD using Javascript
Now we have an amazing Wordle with a great domain model AND an incredible machine-learning user interface for it.
Let's combine them.

The Conquest

We have two repositories:
1 - The one with the Javascript Wordle made with TDD
2 - The one with the machine-generated code
Playable Version (Live) With Defects

Making it work together

We need to inject the changes into our main file.
Remember the scripted UI version was not modular.
We set up our valid game before building our UI
We create a text field to show status/errors to end users
This is not strictly necessary but it helps keep the UI as simple as possible.
rowIndex variable is no longer global. We compute it tied to the attempts tried on the game.
We are reifing the state into our Game object
And this is when all magic happens.
We replace the algorithmic and error prune letter counts computations with our more robust ones
We put it as a very long function in the same event for clarification.
The model now raises exceptions following the fail-fast principle and we can show them to the final user.
This method requires heavy refactorization in a future article.
Finally, we reset the game.
This was one of the many mistakes corrected from the first version.
There are repeated code at the start of the script.
You can play with the final version here
Source code is here
And a working repl.it here

The Disclaimer

The final code is full of refactoring opportunities and several code smells.
It is a proof of concept, not an elegant and final solution.

Credits

Image credit: A funny Twitter thread asking AIs to draw a Centaur

discord

bot

programming

wordle

artificial

intelligence

host

for

free

4

4

0

discord

bot

programming

wordle

artificial

intelligence

host

for

free

Maxi Contieri

Buenos Aires, Argentina

🎓Learn something new every day.📆 💻CS software engineer 👷coding👨🏽‍🏫teaching ✍🏾writing 🎨Software Design 🏢SOLID 🌉TDD 👴Legacy 💩Code Smells

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

© Copyright 2024. Showcase Creators Inc. All rights reserved.