Clickr
Clickr is a minigame redstone contraption. A lectern faces the player showing a written book containing one hundred pages. The player’s goal is to flip through that book as fast as possible. After reaching the last page the player’s score is readable from the number of items in the hopper.
Formulating the Game
Finding an Item
The original idea was to create a game about clicking as fast as possible0.
Objects like …
- noteblocks
- levers
- trapdoors
Were evaluated for allowing quick, readable inputs (by redstone signal or observer). One flaw of using these blocks though is that, like the backspace key, they repeat input on their own. This happens 5 times per second1 with the mouse button down.
While it’s possible to click faster than this auto rate (I could do 7 times per second2) it is not by a fair margin. With too high a floor performance players might not feel compelled to compete.
The project’s saving grace came in the form of a BlockEntity, or rather the item in that BlockEntity. The buttons to change page in written books take discrete clicks.
Substituting lecterns in place of levers and trapdoors revealed a greater issue. Observers can only make so many observations per second.3
Clicks Per Second | Clicks Observed4 | Trial 2 | Trial 3 |
---|---|---|---|
5.00 | 64 | 64 | 64 |
6.00 | 64 | 64 | 64 |
6.0625 | 63 | 63 | 63 |
6.125 | 62 | 62 | 62 |
6.25 | 60 | 60 | 60 |
6.50 | 55 | 58 | 55 |
7.00 | 49 | 48 | 49 |
barrel
< dropper < observer < lectern
. This program clicked an exact number
of times per second using the
java.awt.Robot class.
One solution to this limitation is to think about the point of measuring clicks. Instead of counting each one it’s enough to track progress towards a clicking goal. A lectern’s redstone signal by comparator or surprisingly without one5 gives just that.
How It Works
Hoppers
Only two hoppers lie at the center of this machine.
- The display hopper is visible to the player.
- The feed feeds items into the display hopper. These two hoppers form a stopwatch.6
|---------------|----------|
| | |
| | |
| | |
| | |
| | |
| | |
| |⇓| | v feed |
| |⇑| | ^ display|
| | |
| | |
| | |
| | |
| | |
| | |
|---------------|----------|
States
The stopwatch has four desired states.
- The playing state.
- Display hopper is disabled (preventing items flowing backwards).
- Feed hopper is enabled (trickling items like an hourglass).
- The finished state. The stopwatch
stopped and the player has a chance to check their time.
- Display hopper is still disabled.
- Feed hopper is now disabled (it would be a shame to add to the time)
- The clean-up state. The stopwatch is
unwound back to 0.
- Display hopper is enabled for the first time, pushing items back into the feed.
- Feed hopper is still disabled.
- The init state7. The
stopwatch is now ready to time again.
- Display’s enabled-ness doesn’t matter. If we are here, there are no items in it.
- Feed hopper is disabled (but ready to enable at a moment’s notice!)
(7) The init state isn’t necessary. The state IS useful for simple input protection. It was desired to …
- stop the player from starting a game mid-clean-up (score artificially high).
- stop the player from starting a game from the middle of the book in the lectern (score artificially low). Checking both of these from the same state complicates the redstone (logical AND gate).
Four different states requires at least two bits of memory. This is best achieved with RS latches. These can be set (turning the bit ON), and reset (turning the bit OFF).
- There is the freeze bit.
- And the ready bit. These names come from how they control the hoppers, and the conditions that set and reset them.
|---------------|----------|
| | |
| | |
| ┋-o ┋ | ready SR |
| ┋ o-┋ | |
| | |
| | |
| |⇓| | |
| |⇑| | |
| | |
| ┋-o ┋ | freeze SR|
| ┋ o-┋ | |
| | |
| | |
| | |
|---------------|----------|
Here is how the freeze and ready bits interpret to stopwatch states. The table includes reminders for which state requires what from hoppers.
READY TRUE8 | READY FALSE | |
---|---|---|
FREEZE FALSE | INIT | CLEAN-UP |
FEED OFF | FEED OFF | |
DISPLAY N.A | DISPLAY ON | |
FREEZE TRUE | PLAYING | FINISHED |
FEED ON | FEED OFF | |
DISPLAY OFF | DISPLAY OFF |
(8) NOTE two things about this table …
- The freeze bit disables the display hopper. The ready bit doesn’t matter.
- The feed hopper is only enabled when both the freeze bit and ready bit read true.
This is possible in redstone by …
- running the positive end of the freeze bit into the display hopper.
- running both the negative end of both the freeze and ready bits into the feed hopper.
|---------------|----------|
| | |
| | |
| ┋-o ┋ | ready SR |
| ┋ o-┋ | |
| ┋ | |
| ┋ | |
| ┏ ┅|⇓| | |
| ┋ |⇑| | |
| ┋ ┋ | |
| ┋-o ┋ | freeze SR|
| ┋ o-┋ | |
| | |
| | |
| | |
|---------------|----------|
Transitions
The stopwatch is only useful if its state can changed.
There are four desired transitions9.
- From init to playing.
- After the player flips past the starting-line page.
- From playing to
finished.
- After the player reaches the end of the book.
- From finished to
clean-up.
- After the player leaves the last page.
- From clean-up to init.
- After the display hopper is emptied out.
This is possible in redstone by …
- A
rising-edge detector.
- The detector will watch for the lectern increasing in power (to power 2).
- The detector will set the freeze bit to TRUE.
- A direct line redstone line of lectern power.
- This line of redstone will snake out to increase its length10.
- It will reset the ready bit to false exactly at max power 15. If the line is shorter than 15 blocks it will reset the bit too early.
- A
falling-edge detector.
- The detector will watch for the lectern decreasing in power (to power 14).
- It will reset the freeze bit to FALSE.
- A NOT gate on the comparator output of the display
hopper.
- This will set the ready bit to true (when there are 0 items in the display hopper).
These redstone choices also mirror the transitions to the other side of the state table. In each case the effect is rare if not impossible to trigger11.
For example, the transition from finished back to playing if the display hopper is empty is OK. Players are not expected to finish the game with zero items in display. In fact, it would be incredible! Zero items indicates a stopwatch time of zero.
Ignoring this issue enables the simplicity of this contraption.
state | transition | state |
---|---|---|
INIT | → book power is 15 → | CLEAN-UP |
INIT | ← display hopper mt ← | CLEAN-UP |
↓ book power past 2 | ↓ book power past 2 | |
book power off 15 ↑ | book power off 15 ↑ | |
PLAYING | → book power is 15 → | FINISHED |
PLAYING | ← display hopper mt ← | FINISHED |
|---------------|----------|
| ┏┅┅┅┅┅┅┅┓| |
| ┋ ┋| |
| ┋-o ┋ ┋| |
| ┋ o-┋ ┋| |
| ┋ ┋ ┋| |
| ┋ ┋ ┋| |
| ¡ |⇓| x┅┅┅┫| note new |
| █┅<|⇑| ┋ ┋| redstone |
| old ┋ |↓| ┋| ontop |
| ┋-o ┋ |⇑| ┋| old in |
| ┋ o-┋ ∇ ┋| this pic |
|┏┅┛ ┗┅┅┅█ ┋| |
|∆ ┋| |
|⇒⇐┅┅┅┅┅┅┅┅┅┅┅┅┛| |
|---------------|----------|
In edge detectors using hoppers the item used is a sword.12
The Book Itself
The current page (P) and total number of pages (M) determines the signal strength of a book in a lectern.
- In Java Edition, the formula used is
FLOOR(1 + 14 (P - 1) / (M - 1) )
13. - NOTE there is a max to the total number of pages. 100 pages in Java Edition.
(13) I read this formula like this …
M - 1
Number of clicks to get to start to end (start on page 1).P - 1
Number of clicks so far.(P - 1) / (M - 1)
Percentage progress made.FLOOR(14 (P - 1) / (M - 1))
Amount of progress made so far, counted in fourteenths, and rounded down.- I ignore that 1. 😂
This formula has some effects …
- The “first fourteenth” of progress through the book will produce lectern power 1. Remember, the lectern reaching power 2 activates the playing state. That makes the “first fourteenth” of progress dead space.
- Only the last page produces signal power 15
(
FLOOR(1 + 14 (M - 1) / (M - 1)) = FLOOR(1 + 14) = FLOOR(15)
). No dead space at the end of the book.
To make a long game the book needs to be long. At the same time, a round number of clicks to complete the game is desirable as well. For example, a race to the fastest 100 clicks is easy to advertise. A race to the fastest 94 isn’t.
100 clicks is off limits since there can only be 100 pages total. The next round number is 90.
TOTAL PAGES | FIRST POWER 2 PAGE14 | TOTAL CLICKS |
---|---|---|
M | S = CEIL((M - 1) / 14) + 1 | M - S + 1 |
90 | 8 | 83 |
91 | 8 | 84 |
92 | 8 | 85 |
93 | 8 | 86 |
94 | 8 | 87 |
95 | 8 | 88 |
96 | 8 | 89 |
97 | 8 | 90 |
98 | 8 | 91 |
90 | 8 | 92 |
100 | 9 | 92 |
(14) This is how I derived the first power 2 page from the total number of pages.
- Which
P
is the first to makeFLOOR(1 + 14 (P - 1) / (M - 1) )
equal 2? - In other words, the smallest
P
whereFLOOR(14 (P - 1) / (M - 1))
equals 1. - Smallest P such that
(P - 1) / (M - 1)
is greater than or equal to1/14
. (P - 1) = CEILING((M - 1) / 14)
P = CEILING((M - 1) / 14) + 1
The written book placed in the lectern should have exactly 97 pages. The “starting line” then is page 7. The stopwatch starts when the player reaches page 8.
Bugs
Cropping out a piece of the state transition diagram …
CLEAN-UP |
↓ book power past 2 |
book power off 15 ↑ |
FINISHED |
It is possible for players to stop clean-up and set the machine to the finished state.
If during clean-up players flip from page 7 to 8, then they must flip backwards from page 97 to 96 to restart clean-up.
Extra Modifications and Extensions
Here are some ideas for future builders.
Competition
Instead of filling a display hopper, the feed could fill chest minecarts. A vertical stack chest minecarts would make a good leaderboard. And wouldn’t it be cool to make redstone to sort that leaderboard?
Simplification
Trusting players to move items back into the feed hopper would simplify the redstone.
- The display could become a chest or barrel.
- There would be only two states: finished and playing.
- The playing to finished transition could stay.
- The finished to playing transition could be the rising edge detector from power 1 to power 2.
Book Art
97 pages is a lot to decorate. These pages will likely be blank without help from robots. The medium shade and full block characters can combine to make a cool progress bar15. The java.awt.Robot class can write them.
The attached program also does a little extra on the first page. Random formatting codes and random elements combine to something resembling art.
The art on the first page looks like this.16
▖▗▞▖▝▜▞▟▞▞▝▙
▝▟▜▗▙▚▟▙▝▖▝▝
▝▙▞▟▖▖▙▘▛▖▘▟
▟▜▞▛▛▛▟▝▝▝▞▞
▘▜▙▛▞▝▖▛▗▞▙▜
▞▟▚▜▝▗▖▜▞▛▙▚
▞▗▖▛▙▟
<span>
’s.
The progress bars look like this.
████████████
████████████
████████████
██████▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒
Gameplay
A few notes on Clickr gameplay itself.
Reception
I deployed this game on my homeserver of Thugcraft.
I noticed that players wanted to …
- improve their score after their first run.
- leave tips after playing.
Some players aren’t ready to spam-click. Keep two stacks of items in the feed for slower first-timers.
Tips and Tricks
To play the game effectively …
- Use more than one finger to click. I alternate my pointer fingers.
- When resetting the game take the book out and put it back in. This saves time.