freestyle overall calculator

General footbag-related topics that don't fit elsewhere go in here.
Post Reply
lavix
Circle Kicker
Posts: 7
Joined: 16 Aug 2015 11:20

freestyle overall calculator

Post by lavix » 31 Dec 2023 01:22

I've written freestyle overall calculator to help with calculating scores for overall for tournaments. It's written in bash, as I know bash and bash is portable (can be run inside WSL, on Android using Termux app, probably also on MacOS, but I don't have a Mac to test it). Could be also written in python, but I don't know python much. It has 2 branches currently - "main" uses the same weights for all events, "weighted" cares for different weights. It can be found on my github:
https://github.com/lavix5/footbag_overa ... /tree/main

There are README.md files, but if you have any question, ask in this thread.
Jakub Mościszewski

boyle
Post Master General
Posts: 3148
Joined: 19 Sep 2007 23:42
Location: Canberra, Australia
Contact:

Re: freestyle overall calculator

Post by boyle » 01 Jan 2024 01:51

Sounds like a great idea. I don't know much about the programming side - how could a tournament host access and use this simply?

lavix
Circle Kicker
Posts: 7
Joined: 16 Aug 2015 11:20

Re: freestyle overall calculator

Post by lavix » 01 Jan 2024 04:26

All can be done locally on host computer or even Android smartphone (don't know if bash can be run inside iOS).
The simplest way is to download 2 files from my github: overall_calculator.sh and results_sort.sh from the "main" branch if every event has the same weight or from "weighted" branch if events have different weights. It can be done simply in web browser. Next part depends on the system used.

Windows:

You need to install WSL (Windows Subsystem Linux). Open PowerShell and type

Code: Select all

wsl --install
Installation is only required once. Then every other time follow only steps below.
After installation is complete run WSL (just type wsl in powershell iirc, or search start menu for WSL or Ubuntu). Then change directory to where you've downloaded those 2 files, for example for download folder:

Code: Select all

cd /mnt/c/Users/[i]user_name[/i]/Downloads/
Allow both files to be executed (need to do it just once):

Code: Select all

sudo chmod +x overall_calculator.sh results_sort.sh
If you've chosen weighted calculator, create file "weights" with weights for events, for example using nano:

Code: Select all

nano weights

Code: Select all

Nano editor will open, write there weights with 2 decimal points, for example:

Code: Select all

0.50 0.25 0.25
Then use ctrl+o to save file and ctrl+x to exit nano.
Now invoke overall_calculator.sh script with player name and classification for every player, for example:

Code: Select all

./overall_calculator.sh Jakub 1 3 3

Code: Select all

./overall_calculator.sh Daniel 2 1 2

Code: Select all

./overall_calculator.sh Matthew 3 2 1
After doing so for every player, sort results by invoking results_sort.sh script:

Code: Select all

./results_sort.sh
Now sorted results are in "results.txt". You can print its content to screen with cat, open open it with less:

Code: Select all

cat results.txt

Code: Select all

less results
In less press q to exit less.


Linux:

You can also use Linux booted liveUSB.

Change directory to where you've downloaded those 2 files, for example for download folder:

Code: Select all

cd ~/Downloads/
Allow both files to be executed (need to do it just once):

Code: Select all

sudo chmod +x overall_calculator.sh results_sort.sh
If you've chosen weighted calculator, create file "weights" with weights for events, for example using nano:

Code: Select all

nano weights

Code: Select all

Nano editor will open, write there weights with 2 decimal points, for example:

Code: Select all

0.50 0.25 0.25
Then use ctrl+o to save file and ctrl+x to exit nano.
Now invoke overall_calculator.sh script with player name and classification for every player, for example:

Code: Select all

./overall_calculator.sh Jakub 1 3 3

Code: Select all

./overall_calculator.sh Daniel 2 1 2

Code: Select all

./overall_calculator.sh Matthew 3 2 1
After doing so for every player, sort results by invoking results_sort.sh script:

Code: Select all

./results_sort.sh
Now sorted results are in "results.txt". You can print its content to screen with cat, open open it with less:

Code: Select all

cat results.txt

Code: Select all

less results
In less press q to exit less.

MacOS:

MacOS ships with older bash version, so I don't know if scripts will run correctly, but steps are pretty much similar to Linux. Download folder might have different path (or not) - I don't know Mac folders' tree. I don't have Mac to test it tho.

Android:

First, install Termux app from Google Play or F-Droid Store (I recommend F-Droid, because it's privacy respecting and checks every app before allowing it on the store. Also Google Play halted updates for Termux).
https://play.google.com/store/apps/deta ... com.termux
https://f-droid.org/packages/com.termux/

Then open Termux app. Install bc if you wish to use weighted calcultor:

Code: Select all

pkg install bc
I recommend to create new folder:

Code: Select all

mkdir scripts
Change directory to newly created folder:

Code: Select all

cd scripts/
Open nano and copy contents of both files separetely from github:

Code: Select all

nano overall_calculator.sh
Copy content from github file, save file by ctrl+o, then exit nano by ctrl+x. Do the same for second file:

Code: Select all

nano results_sort.sh
Copy content from github file, save file by ctrl+o, then exit nano by ctrl+x. Allow both files to be executed (need to do it just once):

Code: Select all

chmod +x overall_calculator.sh results_sort.sh
If you've chosen weighted calculator, create file "weights" with weights for events, for example using nano:

Code: Select all

nano weights

Code: Select all

Nano editor will open, write there weights with 2 decimal points, for example:

Code: Select all

0.50 0.25 0.25
Then use ctrl+o to save file and ctrl+x to exit nano.
Now invoke overall_calculator.sh script with player name and classification for every player, for example:

Code: Select all

./overall_calculator.sh Jakub 1 3 3

Code: Select all

./overall_calculator.sh Daniel 2 1 2

Code: Select all

./overall_calculator.sh Matthew 3 2 1
After doing so for every player, sort results by invoking results_sort.sh script:

Code: Select all

./results_sort.sh
Now sorted results are in "results.txt". You can print its content to screen with cat, open open it with less:

Code: Select all

cat results.txt

Code: Select all

less results
In less press q to exit less.

That's the simplest way I could write it. Hope it helps. I know it's not friendly for people, who don't know about programming or linux. Maybe some time in the future I'll create an app with graphical user interface, so it'll be user friendly, but time has not yet come.
Jakub Mościszewski

User avatar
Tjuggles
Flower Child
Posts: 1748
Joined: 27 Mar 2005 20:03
Location: Wellington, NZ
Contact:

Re: freestyle overall calculator

Post by Tjuggles » 04 Jan 2024 20:16

This seems cool, nice work. When I have some time I will check it out.

Speaking of the graphical side, maybe we could integrate as part of the footbag dictionary app I developed? I have plans to add more to the app so it is not just a dictionary but a journal/goal tracking app. Additionally, I have a bunch of notes on etymology of different tricks/concepts I will add, and this calculator would also fit nicely in it...but I suppose that would mean rewriting the code since bash isn't used in the app...
TJ Boutorwick

"You can do anything" -Greg Nelson

lavix
Circle Kicker
Posts: 7
Joined: 16 Aug 2015 11:20

Re: freestyle overall calculator

Post by lavix » 05 Jan 2024 12:31

Sure, let's do it. Spreadsheet-like GUI is what comes to my mind. Either player classification based or event classification based. For later stages maybe also config with user adjustable scoring.

Code is not complicated - just for loop, switch case, while loop and some addition and multiplication. It just uses some shell-specific concepts like positional parameters shift, but array should also do the trick. Rewriting should not be an issue. I definitely could help you with that. But I don't have much experience - it just a hobby for me, so I don't know if I could help you with anything more. But I'm open to new knowledge, so if you decide to do it just email me: jmosciszewski@gmail.com
Jakub Mościszewski

User avatar
Tjuggles
Flower Child
Posts: 1748
Joined: 27 Mar 2005 20:03
Location: Wellington, NZ
Contact:

Re: freestyle overall calculator

Post by Tjuggles » 08 Jan 2024 20:21

Ok sweet, sounds good. I'll contact you sometime in the near future.
TJ Boutorwick

"You can do anything" -Greg Nelson

Post Reply