Add a dash of luck to your coding lessons with this playful CodeX project! Students design clovers using graphics and shapes, then mix in probability and random numbers to build an interactive game of chance. Perfect for beginners, they can start with guided code or create their own clovers from scratch.
Want to take it further? Optional extensions let students level up their game with variables, tougher odds, and custom intro and ending screens, making this a creative, hands-on way to connect math, coding, and design.
For full project details visit the Firia Labs Learning Portal, and join the conversation in the Code Collective to tell us how your students did!
My students loved this activity. They liked the game aspect. There were a couple of students that expanded the lesson with building in averages and graphing a distribution graph. AI helped come up with some code for the extra ideas. It is nice that these activities give the stronger students the ability to extend the goals of lesson and experiment.
One thing that I would let people know: the starter code when copy and paste done may skip lines so the numbers of the lines of code may not be exactly lined up with the slides. Also, when the clover_3 and clover_4 with the sleep is deleted, many of my students missed that part.
I have one student that keeps having the 4 leaf clover show up behind the 3 leaf clover and it keeps spinning in the game until we see a full 4 leaf clover. The code looks like it matches the slides. What should I look at to debug? I need to relook.
Hi, Erin:
I’m glad your students are enjoying the project. And I really appreciate your feedback. Always looking for ways to improve and to know what is working. The use of AI as an extension is a great idea.
As for the 4-leaf clover thing. I’m having trouble picturing what is happening. The only thing I can think of that may cause this to happen is if there isn’t a display.clear() at the beginning of the code inside the button press. If that isn’t it, maybe send me the code as a text file and I’ll take a look.