Project

Last Pencil (Java)

Hard
834 completions
~ 14 hours
4.0

Learn how to build a simple but engaging game and practice the Java basics.

Provided by

JetBrains Academy JetBrains Academy

About

Playing with friends is pure fun but getting ahead of them is even more enjoyable. Invite a friend to play the Last Pencil, a game where you decide who wins. In this project, your opponent is a computer that is an expert in the game. But it's up to you to choose who wins.

Training project icon

Training project

This project allows you to practice and strengthen your coding skills, helping you get ready for more advanced tasks ahead.

What you'll learn

Once you choose a project, we'll provide you with a study plan that includes all the necessary topics from your course to get it built. Here’s what awaits you:
It was a boring day, so your friend came up with the idea of creating a simple game.
Let's change the game a little bit and add new conditions.
You've decided to try out new game mechanics and take turns until no pencils remain.
You took all the pencils in one turn. Your friend decided that it was unfair and somehow took a negative number of pencils! Who is the winner? Let's add the winning condition!
You've played several games and found out that there's only one winning strategy. Your friend suggested implementing a bot to add a certain degree of randomness to the game.

Reviews

Mohammed Alarkoubi avatar
Mohammed Alarkoubi
7 days ago
I have learned how winning and losing positions work in the Last Pencil game using the modulo-4 strategy. I now understand how to code a bot that always wins when possible by forcing the opponent into losing positions. This really helped me connect game theory with practical Java implementation.
Pavel švarc avatar
Pavel švarc
4 weeks ago
This project was tough. That 5th part took me almost half day. What I can say is that logic of continously increasing difficulty in one example is pretty good. It teach you think about things differently with increasing difficulty ... I like that.
Tatiana Soldatova avatar
Tatiana Soldatova
1 month ago
Really loved this small project. Learned a lot of new concepts. Tryed to apply OOP. It was also quite challenging toward the end, so that I'm pretty proud of the result :)

4.0

Learners who completed this project within the Introduction to Java course rated it as follows:
Usefulness
4.3
Fun
4.0
Clarity
3.8