The Abacus has been an important business tool for thousands of years. Its practice can be an important mental exercise, or a pleasant distraction.
Introduction
The origins of the Abacus are unknown, but it has been used in East Asia thousands of years ago. This app reproduces the Chinese Abacus, known as the suanpan, and can be used as an efficient calculator, or practice for the challenge and mental exercise.
The App
In the screen capture above, the app is in Calculator
mode, as the red/yellow button center-right indicates, and the values of displaced beads are equivalent to 1400
.
In the screen capture below, the app is in Exercise
mode where the user is expected to add/subtract a random value from the running-tally.
- Press the Exercise/Calculator button to toggle mode.
- Press the Reset button to reset to zero (calculator) or reset to last running-tally (exercise)
- Click on beads to slide them along their respective poles
It can be great fun...
The Code
There are two important classes:
classAbacusBeadsRack
classAbacus_BeadsOrderOfMagnitude
The classAbacusBeadsRack
Every column (order of magnitude) of the abacus has two divisions - the upper half called 'heaven beads' and the lower half called 'earth beads'. Each half is made up of one bead-rack that keeps tracks of its own Max
number of beads, Value
(number of counted beads), eType
(heaven
, earth
), Base
and Worth
.
Type
- Heaven
/ Earth
Max
- max number of beads in rack is determined by Type
(2 or 5) Value
- current number of beads 'counted' Base
- unit value of each counted bead1
Worth
- Value*Base
(number of beads counted * base value of bead)
classAbacus_BeadsOrderOfMagnitude
The columns each represent one order of magnitude starting from least significant (far right) to most significant (far left). They consist of upper/lower Heaven
& Earth
beads racks. The sum of all the columns is the Abacus-Value, or final tally.
SweepAndPrune
The DrawAbacus()
method draws each column in sequence from right-to-left and creates a SweepAndPrune
data-set of the locations of each button in a var
call cSP
. The pic_MouseMove()
and pic_MouseClick()
event handlers poll the cSP is polled under the mouse location and returns the element found (button
or bead
) located under the mouse on the screen.
History
- 7th March, 2023: Originally published
- 11th March, 2023: the Random was not seeded - puzzle solutions were falling below zero or above 1 billion
- 14th March, 2023 - added a minimum size so that it doesn't fail to appear when destroyed while minimized - fixed the random exercise generator - added a better '?' solution button
- 16th March, 2023 - added game play levels of difficulty that increase with player score - improved button graphics