Wednesday, December 5, 2018

Feature Spotlight: Gym Matching

This is the first in a series of blog posts where I break down a feature that is either new or improved in Meowth 3.0, providing details and insights for users and a break from coding for myself. There's no better place to start with the most-requested feature of all time for Meowth: gym matching.


Introduction


For the uninitiated, "gym matching" is what we call the process of matching a location string supplied by a user to an actual gym in our database. For a very long time, Meowth did not have a database at all because I didn't know anything about databases or how to build them. Luckily for us Scragly did a lot of invaluable work in both building a database interface and helping me learn how to use it. As a result Meowth 3.0 does have a database, and one of the tables in that database is for gyms.


Storing the Data


A description of the gyms table

Each gym in the table has, at minimum:
  • a unique ID (generated by a sequence automatically as gyms are added)
  • the gym's name in Pokemon Go (supplied by a server administrator)
  • the gym's latitude and longitude (also supplied by a server administrator)
  • the ID of the Level 10 S2 Cell containing the gym
  • the ID of the Discord server that submitted the gym (note: in the current build this can be NULL, but in the final build it will be required)
There are also currently columns for:
  • a nickname
  • a True/False value indicating whether the gym is an EX Raid Gym or not (this information will have to be included by the server administrator)

Implementation


Building a table including this information is not too difficult. But at Meowth's intended scale there are some possible problems, for instance that there are lots of gyms with the same name (e.g. "Starbucks", "First Baptist Church", and others.) Sometimes there may even be multiple gyms of the same name even in one server's playing area. However, there are lots of ways we can narrow down the list of gyms to only the relevant ones for that area when trying to find a match. One of the important pieces has to do with the reporting channel. In Meowth 3.0, every reporting channel has an associated circular region. The server administrator who configures the channel for reporting must supply a center and radius for the region. Then, when a user reports a raid in that channel, the following steps are taken:
  • Build a query of the gyms table, selecting the 'id', 'name', and 'nickname' columns.
  • Filter out all gyms added by other servers.
  • Generate a covering of Level 10 S2 Cells for the circular region associated with the channel.
  • Filter out all gyms that are not located inside the covering.
  • Retrieve the data for all of the remaining gyms.
  • Check the location argument against the nickname list.
  • If there's not a match, check it against the name list.
  • Pick the best match as judged by a fuzzymatching module.
This is the basic algorithm as it stands right now. Before release, there will be a step added that asks for clarification if there are multiple close matches.

Benefits


Under the old system of locations, Meowth had a very unsophisticated process for guessing where a gym was - take the location string, add it to the "city string" in the configuration for the channel, shove all those words in a Google Maps URL, and hope Google knows about it. This worked sometimes but not all the time - unsurprising given the relative obscurity of some landmarks. So keeping an actual gym database with saved locations is obviously going to improve the directions Meowth gives. But there are other benefits as well. For one, detecting duplicate raids is now actually possible. After determining which gym a user is reporting a raid at, Meowth checks the raids table to see if a raid has already been reported there. If there has, Meowth sends the information for the raid, including the channel it's being coordinated in.

Another benefit is that it is now possible for Meowth to make raid channels that are visible to multiple reporting regions. Raids will be visible to any reporting channel whose circular region contains any part of the gym's Level 10 S2 cell. This means that if you report a raid that is on or near the border of two channels' regions, the resulting raid channel will be visible to users from both regions.

Drawbacks


This system is highly dependent on quality data from server administrators. Since an official gym map tool does not exist, we rely on user reports and have no way of vetting the data that is put in. Because of this, each server has access only to their gyms that they have imported, and only server administrators are capable of adding or removing gyms to that list. If the data is incomplete, the results may be inconsistent. In the event that Meowth cannot find a match to the gym, it will simply fall back to the old way of creating a Google Maps search for the string.

Preparing Your Data


This is a link to a spreadsheet template you can use to gather your server's gym data. You'll need to make a copy of it to use it. When Meowth 3.0 launches, you will be able to import a CSV that matches the template to add your server's gym data in bulk. Thereafter, there will be commands for adding to, removing from, and modifying your server's gym list.

Final Thoughts


This system is not likely to change drastically between now and release. As always, I welcome all constructive feedback! Let me know what you think in the comments or in the Meowth Discord Server!

Wednesday, November 21, 2018

Meowth 3.0 - What to expect, when to expect it, and how to prepare!

Hey everyone! It's been a long time since we've talked about our plans for the next major release of the Meowth bot. I wanted to thank all of you for your patience and give an update on where things stand right now. Let's lead with the big news: I anticipate that Meowth 3.0 will be widely available by the end of January 2019! Now allow me to address some questions you might have.


What is in this version?

Well, I don't want to give everything away just yet, but I can confirm some of the big-ticket features that I think everyone will get excited about, namely:

  • Gym matching!
  • Robust support for various Pokemon attributes, including forms!
  • Lots of backend improvements! (Okay, maybe that one's just exciting for me.)


What has taken so long?

Well, two things mainly. The first thing is Real Life. The second thing is that this version is a complete rewrite of basically everything in Meowth, and as development on this version has progressed there has been a bit of feature creep and reorganization. On the backend we are finally moving to a proper database which is already proving to be very helpful in development. Hopefully, once 3.0 has been released we should be able to develop new features more quickly.

What should we do to prepare for the new version?

There's one thing in particular that you can do to prepare your server to take advantage of the new capabilities of Meowth 3.0, and it has to do with our most-requested feature: gym matching! For us to be able to match gyms for your server, we need data! We will certainly have a way to add gyms one at a time to the database once we've released, but we also want to give you some time to prepare your data so that you can start using gym matching immediately. The easiest way to format the data would be as a spreadsheet with the ability to export to a CSV file. Here's an example showing the format I'd prefer. I can't guarantee support for other file formats at this point, so if you want to be proactive, following this format is what I'd recommend. I suggest making a copy of the following Google Sheet and removing the example gyms to get started.


As there are a lot of you and not many of me, please do your best to validate the data you gather: coordinates should be precise to at least four decimal places, names should be spelled correctly, and double check that the gym displays an "EX RAID GYM" tag before entering "TRUE" in your spreadsheet.

You may notice that there is also a sheet labeled "stops" - feel free to gather data on the Pokestops in your community as well. We hope to use a similar system for research tasks!

OK I gathered all this data, now what?

Holy crap that was fast. Okay. Well, hold onto it for now. You can email it to me if you really want, but I'm hoping to have an import command ready when the bot launches so that you can send Meowth the data yourself.

Anything else?

Nope! Thanks for reading!

Changes to Research

More details on today's changes to the research command are below. A new optional argument has been added to the research command. Thi...