Gwent: Pro Ladder Analysis and National Rankings

Data for on players in Pro Ladder is released on playgwent.com, but it is limited. You get the rank, the score, the country of origin and the number of matches played. Using some fairly basic data analysis tricks there must be more we can do with these data! Using python we’ll scrape data for the top Gwent players on pro-ladder and calculate additional statistics about the current season, popularity of the game in different countries, players’ efficiency, players national rank, … A jupyter notebook with all code can be found on GitHub which you can explore through Binder without installing anything. For those that want to check their own national rank or ladder efficiency index (and don’t care about the code). Download links for the full tables discussed here (in Excel-format) are available here: Player Statistics : Player data for each season, with ladder efficiency and national rank added. Player Summaries : Summary data for each player that made an appearance in pro rank. Includes number of appearances on the leaderboards, min and max MMR, best rank, best national rank, … Seasonal summary : Number of games played each season in Masters 2, minimum and maximum MMR as well as Read more…

Tiny MIDI controller with Raspberry Pi Pico

With a MIDI library available for the Raspberry Pi Pico making a little MIDI “piano” is relatively easy. The MacroPad which I build last month is the perfect little device to play around with this. If you are interested in how to connect buttons and LEDs to a Pi Pico, check out that post here! A MIDI controller behaves different from a USB keyboard; once a key is pressed it generates a MIDI signal that can be picked up by a compatible instrument or software to produce a sound. The signal contains the note that needs to be played, but can also contain the velocity (how fast/hard a key is pressed). Furthermore, it is possible to send signals to bend notes, set the volume of an instrument, … Keys also don’t repeat after being pressed longer. So there are a number of thing to change in the code. Getting started If you want to follow along exactly, first you’ll have to build my MacroPad, though pretty much any Raspberry Pi Pico with a few buttons attached will do. Just make sure to update the code below so that the pins correspond with your hardware. The Raspberry Pi Pico will need Read more…

Minimalist Art Using a Genetic Algorithm

While the genetic algorithm in the previous post worked very well, it didn’t quite produce the style of minimalist artwork I was trying to achieve. Furthermore, it didn’t allow the chromosomes to evolve using duplication and deletion of existing genes (which is very common in biology). So after mulling over these issues a few days, I found a solution using a Voronoi diagram. The final result (shown below) is much closer to what I was aiming for. The painting to re-drawn by the algorithm this time is Vermeer’s Girl with a Pearl Earring. Voronoi diagrams (aka partitions or cells) The plot below illustrates Voronoi diagrams; each blue point is an input point, black edges and orange corners are calculated. Black edges are equidistant between two neighboring points and orange points (endpoints of an edge) are equidistant between three neighbors. This creates a polygon around each input point that is convex and non-overlapping. These polygons can be colored and drawn as solid shapes which creates a cell pattern. (You can find an entertaining explanation with more details here) In Python Voronoi diagrams can easily be created and plotted from a list of points using the Voronoi class and voronoi_plot_2d function which Read more…

Static Site Generators: Jekyll vs Pelican vs Gatsby

There are many static site generators out there! Which one to pick is far from trivial. In this post three generators used in some of my projects are being compared, helping you pick the right one for your next project! On JamStack there is a long list of generators to choose from, making it seem like an impossible task to pick one for your next project. If you feel like it is impossible to make a choice, this blog post is for you! Here three widely different tools, that I used in a few projects this year, are discussed with their strengths and weaknesses. This is based on (and therefore biased by) my experience with these, feel free to share your opinion in the comment section below. Jekyll Jekyll, released in 2008, is one of the first static site generators and has grown in popularity as it has integrated in GitHub. While it is possible to build a wide variety of sites using Jekyll, at the core it is intended for blogs. It is rather opinionated about file structure, post metadata, extensions, … but once you accept these patterns it really allows you to forget the web development aspect and Read more…

DeckLock part 3: How about a game of Gwent?

Gwent support in DeckLock has been on my ToDo list for some time as it currently is my favorite game. The artwork is stunning, it is well balanced and rewards skill. Though it being a digital-only card game makes it somewhat different from KeyForge and Magic: the Gathering. As the latter have printed, physical cards the cards themselves can’t be changed. Occasionally, an errata is issued or cards that are to powerful are banned from competitive play. In Gwent however, there are no physical cards, and cards can change from one update to another making them stronger, weaker or changing them entirely. As the official website does allow users to share their decklists, it only has data for the latest version. Therefore I opted to add decks using a decklist that contains information on the version and get card data from The Voice of Gwent which contains data for all cards for all versions. Adding a deck works very much the same way as for a Magic: the Gathering deck which was described in part 2. Though as there is no standard format to represent a similar one to M:tG was used. The first few lines contain extra information, most Read more…

A Python powered MacroPad/StreamDeck

I decided to put left-over parts from my mechanical keyboard and a Raspberry Pi Pico to good use and build a MacroPad. This is a small keypad, where each switch can be programmed with a certain button or combination of buttons to quickly execute often needed shortcuts. Streamers often have this to change scenes or trigger an animation in OBS, hence these are often referred to as StreamDecks. Requirements For this project I had a lot of the components at hand. Switches, LEDs and keycaps were left over from my keyboard build. If you do want to do this from scratch, here is a list of items to buy. 1x a MacroPad case (3D printed, STL here) 1x a Raspberry Pi Pico 9x Mechanical keyboard switches (Gateron, Cherry MX, Kailh… should all fit) a set of keycaps (e.g. for numpad keys) 9x 1.8 mm 2V LEDs (current 15-20 mA) (optional) 9x 82 Ohm resistors (optional) 1x a switch opener (optional) 4x M3 bolts (14-16 mm long, I cut down 20 mm bolts to fit) some heat-shrink tubing wire, single core and flexible soldering equipment a third hand tool a hot-glue gun a USB-micro cable Designing and printing the case As Read more…

Key2.0: Open Source Bluetooth IoT Door Lock

What is Key 2.0? Key 2.0 (or Key20 for short) is a Bluetooth IoT Door Lock controller. It turns a conventional electric door lock into a smart door lock that can be opened using a smartphone without the need for a physical key. Thus, Key20 is the modern version of a physical key, or, as the name suggests, the key version 2.0 for the Internet of Things (IoT) era. Key20 consists of two parts: Key20 door lock controller device, which is physically connected to the electric door lock and wirelessly via BLE to the mobile app. Key20 mobile app implementing the user interface to unlock the door and communicating with the door lock controller through BLE. [ Mobile Phone w/ ] [ Key20 App ] | | Bluetooth Low Energy (BLE) Connection | |—[ Key20 Door Lock Controller ]—[ Electric Door Lock ]—| | [ Device ] | | | | | | | |———————-(Voltage Source)———————–| ( 12 VAC ) The following image shows the Key20 door lock controller device and the Key20 app running on a smartphone. You can get a quick impression on how Key20 works watching the following video: Key 2.0 Video The main features of Key20 Read more…

25 Fortnights of Code

I have a lot of projects sitting on my hard drive, most of them are half-finished and poorly documented. My resolution for 2020 is to improve this! The 100 Days of Code challenge has been popular for some time now and many people have done their own version of this. I would like to give it a slightly different spin, 25 fortnights of code. Instead of coding one hour a day, I would like to write one post every two weeks for one year. Most posts will be code related, but  I’ll also focus on documenting everything and presenting it in a clear way. Though I will only properly start in January 2020, I put up the first post already to give a glimpse on what to expect. What’s up next is yet decided, however I will tell you I have a few more machine learning related projects in my folder, something with art and genetic algorithms and messing with GPX files. All code related with posts here will be made available on GitHub in the 4DCu.be page. If you have feedback feel free to open issues there, or post comments on the posts directly.

Lights, Camera, GitHub, Actions: My Favorite GitHub Actions

GitHub Actions allow you to automate some workflows directly on GitHub when code is pushed, at regular intervals or triggered manually. While it takes a bit of setup, the advantages are well worth the time required to get acquainted with this advanced feature of GitHub. In this post I’ll outline a few of my favorite workflows to pull in new data periodically, format code, run unit tests, … Links to different repos will be included to see the actions in, …, well, action. These are not the most advanced ones, but a simple bit of automation can go a long way in saving some time and energy. Autoblack – Python code formatting The package black is the de facto standard for formatting python code. Not only will it point out inconsistencies and mistakes in the code-style, black will correct them. So before committing code in a repo, it is a good idea to run black to make sure the style is A-OK. However, I tend to forget to run it … and while you could set up a pre-commit hook (which needs to be configured on each developer’s system) it is even better to let GitHub run black on all Read more…

Bluetooth and Location Services Permission Tips

An iBeacon app relies on an active Bluetooth connection to detect the beacons around it. Without bluetooth, the app wouldn’t know when to trigger certain location related features. Handling bluetooth settings and permissions on the iPhone can sometimes be tricky. If you don’t request permissions correct and check the phone’s status in the right order, development and testing can become more of a frustration than it needs to be. Here’s how each step of the process should be handled: 1 — Is the device capable of Bluetooth Low Energy (BLE)? iBeacons run on the BLE frequency so it’s important that the device is BLE capable. BLE is available on the iPhone 4S & up, on any iPad mini or Air, and on iPad 3rd & 4th generation devices. Check for BLE capability isn’t necessary if you setup your app to require Bluetooth low energy. UIRequiredDeviceCapabilities bluetooth-le Adding the bluetooth-le key to the UIRequiredDeviceCapabilities array in your app’s plist restricts non-BLE capable devices from downloading your app. We restricted downloads of app to only BLE enabled devices since the app relies on iBeacon tech to function. Some apps may not revolve around iBeacon tech, in that case checking for BLE capability is an absolute necessity. Read more…