Package: skrate
SkrateUse data mining to measure your skateboarding progression, and playSKATEagainst your past self.David Lenkner
c. 2019Server InstructionsInstallationInstalldocker, used for running the
Skrate database service. InstallPython 3.6 or later.Install the Skrate Python package and executable viapython3 -m pip install skrateRunning ServerStart the local Skrate database service viarun_skrate database-runIf you are running the server for the first time, also create necessary tables by runningrun_skrate database-setupThis not only creates the model tables but also populates thetricktable with some common
skateboarding tricks. New ones may be added, see "Adding New Tricks" below.Finally to start the Skrate web service,run_skrate serve [-h 0.0.0.0] [-p <port-number>]The-hoption will start the server on your local network as opposed to your machine only.
Default flask port is 5000.Verbose output may be seen by adding the--debugargument afterskrate.pyfor any command. Log
messages go to stdout and/tmp/skrate_service.log. For further help seerun_skrate --helpSkatingPick any username, and browse tohttp://<your-server>:5000/<anyusername>to log in (security is not a
thing in Skrate yet).You don't have to start a game of SKATE - any time you miss or land trick, click "Miss" or "Land" by
the appropriate trick in the list to record the attempt and update your stats.If you want to play SKATE against your past self, click the "New Game" button. After that, updates
and instructions on what to do will appear in the game feed above the "New Game" button.Opponent Logic - SKATE Against YourselfSKATEis a common game in skateboarding, with rules
analogous to HORSE in basketball. For context seeBATB,
a widely-followed tournament with many top pro skateboarders playing SKATE against eachother.In this app, your opponent in a game of SKATE is your past self, to measure whether you've progressed
(whether you land more tricks more reliably than you used to). Your opponents' likelihood of landing
any trick is determined by your own history of tries on that trick. The app algorithm takes a fixed
window of most recent tries of the trick, so as you progress your opponent also "gets better". The history
window length is defined in_RECENT_ATTEMPTS_WINDOW_OLDESTingame_logic.py-
roughly, increasing that means including "older versions" of oneself in a progression measure (have I
gotten better since last year, vs. better since last week).If your AI opponent is challenging (choosing a trick to try), they will pick the trick with the best
probability of landing, with a randomization factor to sometimes take less reliable tricks and "mix up"
the game a bit, to get a different game every time. That randomization factor is controlled by_TRICK_RANDOM_SKIPingame_logic.py.DevelopmentPull the repo, install requirements inrequirements.txt, and have at it!Unit tests can be run viapytest tests/test_skrate.pyAdding New TricksTrick definitions are intricks.py. Each base trick is also labeled with whether it should be
duplicated in nollie/switch/fakie form. Most things should be but not everything. For instance,
we should have "Kickflip" as well as "Nollie Kickflip", "Switch Kickflip", and "Fakie Kickflip"
but we don't want to have both "Ollie" and "Nollie Ollie".After adding totricks.py, you can simply rerunrun_skrate database-setupin order to load the changes. It will respect existing data and only add the new tricks.Getting at "Raw Data"If you are inclined to further analyze Skrate data on tricks, attempts, and games, or
inspect the schema auto-generated by SQLAlchemy, you may be interested in the raw SQL interface
to Skrate data. One way to access that is viapsqlinside the docker container,docker exec -it skrate-persistence psql postgresql://postgres:postgres_password@localhost:5432/postgresMigrating DataThe PostgreSQL docker container is run using a mounted docker volume called skrate-vol for postgres
data. Thus, the database is persisted between docker runs in a host directory, and can be easily
copied or migrated (e.g. switching to new host machine w/o losing data).You can view the actual disk location of this data by runningdocker inspect skrate-voland noting theMountpointentry. You can then explore this directory (root permissions needed
since docker owns this location). The volume nameskrate-volis default, any volume name may
be used by setting non-default--volumeargument torun_skrate database-run.AcknowledgementsSkrate relies onFlaskfor web service,Flask-SQLAlchemyfor model management,Flask-Testingwithpytestfor unit testing.Also appreciated is the convenientPostgres Docker imageused for the Skrate data persistence layer.