## For Calculating a Whole-Numbered Grocery Bill

This is a little piece I wrote in 2014.

Here’s the formula for calculating an even amount for your groceries at the supermarket.

Let ”T” be the total price of the order, ”P” be the price of a non-taxable item, ”G” be the price of a taxable item, ”t” be the tax on a taxable item (usually a percentage), ”n” is the number of non-taxable items in the order, and ”m” is the number of taxable items in the order. For the bill of your groceries to be an even amount, the following must be satisfied:

All one needs to do is find an item Pn or Gm which makes ”T” a whole number. To put it in another way, you must satisfy this condition:

Where equals a whole number.

So the next time someone at the checkout stand looks at their total and says, ”I can’t do that again even if I tried,” show them this article and explain to them that it can be done.

## How to Add C# Assemblies to a Godot Engine Project

With the release of version 3.0 of the Godot Engine, C# was added as a supported programming language. Due to other engines like Unity, there is a large number of C# assemblies which can help in developing a game. However, there isn’t an easy way to add assemblies in the editor. Therefore, this tutorial was created to help with that problem.

In this tutorial, we’ll use the Godot Engine, version 3.0, along with the assembly for Rant. Note that while a C# assembly can be added to the editor, the assembly cannot be exported to a self-contained executable just yet.

1. Create project as normal. Where necessary, add a C# script. At first, the engine will generate the necessary C# files (i.e. the “*.csproj” and “*.sln” files).

2. Add in the C# code. After this, close the editor for the moment.

3. Ensure that the correct assembly is in the Godot project working directory.

4. Go into a desirable IDE and open up the “*.csproj” file which was created when the C# script was added. Monodevelop will be used in this tutorial. At this point, ensure that the Godot editor isn’t running. Otherwise, key files may be overwritten.

5. In Monodevelop, right-click on the References node in the tree view for the project and click on Edit References... Be sure to first expand the project so as to reveal References. Then click on the .NET assembly tab and click “Browse…”.

6. Select the desired assembly for the project and then click “Open”.

7. It should then be added as a reference for the project. Click “OK” and save the project (“Ctrl + S” or “File -> Save”). Exit out of the IDE and go back into the Godot editor.

8. Add in a GDscript which makes use of the assembly.

9. If all goes well, the engine should use the assembly in the resulting game.

If you have any comments or questions, please ask them below, or get in touch with me.

## Using Rant in my Python program because I’m a glutton for punishment

Over the past few months, I have been researching and developing a little procedurally generated game which will eventually be created in the Godot engine. This game will have a story that’s procedurally generated for the players. A part of this game is the dialogue, which will also be procedurally generated. To accomplish this, I set out to find a library of some kind which can create procedurally generated dialogue (or at least the dialogue that I want) and is written in my programming language of choice, Python. From the looks of it, there isn’t one, and so I had to look elsewhere. That’s when I stumbled upon something called Rant. This is billed as a library which can procedurally generate dialogue. At first I thought I had found what I was searching for. Sadly, though, it is written in  the least open source-friendly language I have ever seen: C#. This can be used on Linux (with the Mono runtime). But I’m looking for a solution where I don’t have to use a bunch of programming languages to achieve what I want.

At first, I tried making some kind of dialogue scheme that would suit my needs. I threw in some sentences of what may define the NPC, and mashed it all together. From the looks of it, though, the scheme is getting out of hand. I have several lines of dialogue, and I’m not even finished. I don’t entirely know how I’ll fit it all together, considering this is just for a simple demo of the full game. It looks like I’m going to have to get creative.

I went digging and searching around I came upon several possible ways of integrating C# code into Python code. There’s IronPython, a fully implemented version of Python in C#. The big problem with this was that it didn’t look very portable to me, as I would have to bundle the .NET libraries with the game for each platform, and that’s a royal pain the ass. Then I looked at Python.NET, which looked very promising: you can call some C# code from Python, and you can call some Python code from C#. It looked like the best of both worlds. Now, actually making it work is a bigger problem.

When I tried to use the Rant.dll assembly in my Python program, I found that I can’t do that because, well, it’s C# code, and the regular old CPython (which comes with many Linux distributions) can only import C or C++ code. Then I looked into using the clr module from Python.NET, but I couldn’t find a version built for Linux. Through a lot of hand wringing, brow beating, and code cracking, I found that I had to use the latest version of Mono (version 5.0.1) along with an unstable version of Python.NET. This one built with the suggested command: python setup.py build_ext --inplace. The built shared object library file, “clr.so”, and the “clr” module load in Python.  Heck, I was even able to load the pre-built “Rant.dll”. But this is nothing compared what I must do now: actually making some procedurally generated dialogue with Rant. And I don’t know where to begin with that.

## So I Did a Panel at a Convention

Last Friday, I did a panel at A-Kon 28 about starting out with Gimp. I had been wanting to do a panel for a while, so I prepared for this one. I followed the advice of the dynamic duo that is Vitamin H, and planned out what I was going to say, along with practice. While I did write out an outline, along with the practice, that didn’t really prepare me for the panel.

I practiced the panel at a local community college. While that served to focus what needed improving, I couldn’t get proper feedback on what was missing from the panel. I don’t know any artists, and friends of mine couldn’t take time off to come see it. Even when I recorded the practices, I couldn’t get people to look at it, nor critique it. So I had to just think of how the audience would react to it. I did this each Friday, for a few weeks, up until the convention.

Before I started the panel, I was nervous. I thought of how to properly show the panel, including the video set-up. I also looked at how few people were in line, so I thought that it would not be a big crowd. Then, when they allowed people in, the room quickly filled. At that point, I knew I was screwed.

I led off by introducing myself, talking about the program, and possibly where you can get it. Then I showed off some of my pictures. I showed one I made for Kirby’s Epic Yarn, along with a parody of a movie poster. When they laughed at the joke, I thought, “Nailed it.” But then it went downhill from there.

I kept trying to show the audience some of the finer details of Gimp, but I couldn’t exactly talk about the tools. The settings for the paintbrush tool were pretty self explanatory, so maybe I shouldn’t have gone in that direction. Also, the picture that I used for an example didn’t really seem to work for the audience. I had already inked it out, so I couldn’t show the full capabilities of the ink tool. I did talk about the “dynamics” feature, and I think they got that. But talking about how to use the bucket tool, and the selection tools just fell apart. Heck, I couldn’t even tell whether the audience was learning something.

Near the end of the panel, half the audience left. Those who did asked questions, and I was able to answer a few of them. One guy asked about the blending capabilities of Gimp, and so I tried to answer his question to the best of my abilities. I couldn’t understand whether he was talking about the blend modes of the layers, or the blending capabilities of the brush tool. Still, he kept his interest. Other people asked about the settings, but I couldn’t really answer that. From the looks of it, only a handful of the audience learned something.

The next time I do this, I’ll have to get people to give me feedback on what I’m planning. Also, I’ll have to define exactly for whom this panel is targeted.

## Trying My Hand at Making a System for Procedurally Generating Stories

Last year, I got the idea of making a game where a group of friends could get together, have a game scenario generated for them, and they could start playing.  This is something called procedural generation, wherein game settings, mechanics, assets, and other components are created from an alogorthim, and a bit of randomness.  I thought I would just research this, since creating any sort of video game takes a lot of time and skill.  In this case, I was looking into a system for creating stories.

I’ve read a few things about procedurally generating stories (for instance, Tail-Spin and Minstrel) and I stumbled upon one that may be in my reach.  From a paper titled “Random Word Retrieval for Automatic Story Generation” I found out about something called ConceptNet.  This is a commonsense knowledge database for finding the relations between concepts via semantics.  So you can find one concept (like “dog”) and find corresponding concepts for it (such as “animal”).  The paper talks about the intent of making a system for using ConceptNet to find the relations between words (in a process called “Concept Correlation”) and make a story out of it.  Sadly, they haven’t yet implemented the system.  So what I’m trying to do is make something that will, uh, sort of make a story.

In the paper, they talk about how the system requires a Knowledge-Based System.  Unfortunately, this system is quite tedious and difficult to create (or so the paper says).  So I’m just trying to find the connections between words and concepts.  All that I’ve been able to do, though, is mess with the Python interface to the ConceptNet website, and maybe find some related terms.  Finding the connection between two dis-similar terms is difficult, because the concepts have many branching nodes which connect to other nodes.  Finding the right nodes which connect the two concepts would take a while, because the system would have to iterate over the nodes until they find a match.

The examples I’ve been using have been “dog” and “snow”.  So the system would have to go through each node in the “dog” concept until it found a node which connects to “snow”.  It could be any connection from “dog” -> hasA-> “nose”  -> RelatedTo-> “wet” -> PropertyOf -> “snow”.  Please note that these aren’t actual connections in ConceptNet, but something like this can be found in the database.

So I don’t know how I’m going to tackle this monster, let alone make a story out of it.

## MyCroft, AI, and how I’m trying to help it

The other day, I saw that a version of MyCroft was released for the Raspberry Pi.  I have been following MyCroft for a while now (mostly through the Linux Action Show) and have tried using it.  The software is still in beta, so I found some bugs with it, namely I can’t really use it.  I have tried pairing it, then talking into it with my microphone.  But it can’t understand what I’m saying.  At first, I thought it had something to do with getting a secure connection to the MyCroft backend servers.  Now it could be a problem with my microphone.

I’ll admit that my desktop microphone isn’t the best.  But how much clarity does the microphone require?  Apparently, a lot.  The microphones on the Amazon Echo, for instance, can pick up a bunch of channels of sound.  So it looks like I’m going to have to get a better microphone.

What I’ve also seen is that MyCroft uses Google’s backend for the speech recognition.  It looks like they’ll go to something such as Kaldi, but that doesn’t have a large enough speech model to get the job done.  While it has a model based upon over a thousand hours of speech, it may require thousands of more hours of speech just to get better results.  I’ve been donating to Voxforge and trying to help with their speech corpus.  However, they’ve barely got enough for half of their first release.  So I was wondering how to speed things up and get them more samples.

What they could do is make it fun and interesting to donate.  I was thinking of something like a badge system on the Voxforge website, or even leaderboards.  Then again, would this make it fun to donate?  I need to think more on this.

## Made My Own NES Classic Console

It looks like the NES Classic is sold out every where, and there are scalpers on eBay trying to bilk old fans out of their hard-earned coins.  Now, I don’t want to get an NES Classic on account of owning a couple of the featured games, as well as owning them on the Virtual Console.  But since the lack of want doesn’t stop me from tinkering, I made my own.

It’s quite easy to make a tiny device which can emulate and play NES games; it’s already been a reality for a long time.  In my case, I took a Raspberry Pi 3, got the official Raspberry Pi touchscreen, a case to contain these parts, an old SD card with an install of RetroPie on it, and a Classic USB NES controller.  And just for shits and giggles, I also hooked up the whole thing to a 20Ah battery so that I can play it on the go.

This was a fun little project, but it does have its setbacks.  The Raspberry Pi, along with the other attachments, draws a good amount of current, and so has a problem with voltage (that’s the reason it has two USB connectors).  Also, if you want good sound, you’ll have to use a different sound output; the on-board audio jack is terrible.  Then there’s the price: this little beauty set me back around $200. So while the NES Classic will set you back$60, at least that’s an official machine, and has a few bells and whistles.  Still, this device is easily configurable, and I can add as many games as I want.  So it not just plays NES games, but also SNES games.

## The Nintendo Switch™: Is this the success Nintendo needs?

So Nintendo has shown off their next console: the Nintendo Switch™.
This machine is a touchscreen with detachable controllers called Joy-Cons.  What a user can do is either play it while the device is connected to the TV, or take it out of the dock, and play games on the go.  The device has a number of controller options, including using the Joy-Con controllers, using a Nintendo Switch Pro controller, and just using the touchscreen.  The whole display will  be in full high-definition, and will probably support multi-touch capabilities.  It has been reported that the device has an nVidia Tegra GPU in it, so Nintendo has switched (no pun intended) to a new graphics card maker, and has moved on from ATI/AMD. It also looks as though the device supports cards similar to those used in the 3DS, but I’m sure it has on-board storage, as well. Now I need to ask the question: why should I care about this device?  I already have a PC which can play a number of games quite easily (maybe not the most recent games at the highest settings), as well as a good mobile phone and tablet. So for the most part, I’m not interested. There is a good number of publishers who are saying they will support the Switch. But what will they actually release on the device?  My guess is that, at first, they will release ports for the device (or games that have been remastered). But then what?  Would Bethesda release the next Elder Scrolls game on the Switch? It’s unlikely, considering that they’ll probably release it for the PS4 and Xbone, and of course they’ll have a PC version.  Maybe they’ll make a smaller version, or perhaps they’ll release the mobile version on the Switch.  If that were to happen, though, why would anyone care?  Couldn’t a user just play the mobile version on their phones or tablets?  How would that version be different? Bethesda may release an Elder Scrolls game on the Switch, but it won’t be a version that’ll be found on the other consoles, that’s for certain.

How about other parts of the device?  Will it have specs comparable to the PS4 and the Xbone?  Probably, however those two consoles already have upgraded versions on the way.  It’s true that they won’t be huge improvements over the originals (supposedly, the PS4k will have support for 4k televisions and be capable of running most games at 60FPS.  But that’s it), but they still have
specs that some big developers will like.  How about the development environment for the Nintendo Switch?  Can one easily take their Steam game and port it over to the Switch?  There were a big number of indie developers who really wanted to port their games over to the Wii U.  But the hardware was just too foreign from their familiar hardware to justify a port.  Thankfully, a number of games (such as Axiom Verge) did make it to the Wii U.  But is this enough to keep the new console afloat?

Among other big developers who have pledged support include the old vanguard of Sega, Capcom, and Square-Enix.  These three are laughable, as they have been hemorrhaging money for years.  Sega has lost millions over the past few years (though more recently they have rebound), Capcom has only been kept afloat by Street Fighter, as well as old re-releases of Mega Man and Resident Evil, and Square-Enix has seen marginal return on their mobile phone offerings (don’t even get me started on Final Fantasy).  What are they going to release on the Nintendo Switch?  How are they going to take advantage of the device?  Probably in the same way as the Wii: release only a small number of games, some re-releases, as well as “test” games, and see whether they are a success.  So it’s unlikely we’ll see some big games from these developers (although the remake of Final Fantasy 7 does not seem far-fetched.  Twenty years too late, is what I think).  Other developers include Konami, Activision, and Electronic Arts, but I really doubt they will release anything worthwhile on the Switch.

There are other developers who do look promising.  Platinum Games is making something, and with their track record with Nintendo, they’ll probably make some great content.  Others include From Software, but my guess is that they’ll port over Dark Souls or Bloodborne, so nothing new there.  Another developer on the list is Nippon Ichi, most famous for their Disgaea games.  What they’ll have is anyone’s guess.  Then there’s Epic Games.  That one is a bit of an enigma: why would they develop for the device?  Why would they care?  I have not a clue what they would make for the Nintendo Switch.

All of this information is wonderful, but the public needs to know other things. As I have mentioned, it needs to have specs similar to the competition, so what the final specs will be is unknown.  How will the games be played on it?  Will they all use cards, or will discs be supported?  What are the online capabilities for the Switch?  Since this is Nintendo we’re dealing with, we know it won’t be as good as the competition (probably little voice support, a gimped messaging system, and no online friends group support).  I’m sure the Switch will be region-free (even Iwata talked about this), so that will be a welcomed addition. But all of this will mean nothing if the software and feature support is solid.

We’ve seen the list of developers who are supporting the Switch, but what other features will it have?  In time, those will be revealed.  But is this something that Nintendo is showing that they are different, that they will listen to their fans, and possibly make the games that some of their fans want?  It’s impossible to please all of the fans, but there has been huge criticism for major Nintendo games over the past year.  Star Fox Zero was critically panned and Super Paper Mario: Color Splash was also criticized.  Let’s not forget how different Metroid Prime: Federation Force is from other Metroid games. So how is management going to be different for the Switch?  Will they be more willing to support third party developers (and I’m talking about actually throwing
money at them to develop exclusive content for the Switch, as well as helping them with developing the games)?  Will they make their online system more open to those consumers who just want to freely converse and play with other, different users? Will they allow for the users a little bit of freedom in Miiverse, to show content that may be a bit more grown-up?  Of course, there will still be moderators. It is doubtful, as Nintendo’s management has changed little since Iwata’s passing.

I feel that, if Nintendo really wants to recapture the consumers they lost to the competition, they will have to change some of the leadership at the top.  Even though they got a new president, mostly what has changed was what departments the current management looks over (most of the titles changed to “deputy <title>”, so they have a deputy director of marketing.  I guess they became deputies when they got a new sheriff in town).  It’s true that Nintendo has been getting younger developers into their company, and did try to find a younger president.  But their leadership cannot be made up of people who haven’t not been able to turn around their sales over the past few years. “A problem cannot be solved with the same level of thinking that created it,” as Einstein once said.

Is it too early to say whether this will be a big-selling machine?  Possibly.  But if Nintendo’s track record, their current corporate structure, and the list of developers is anything to go by, it’s doubtful that the Switch will be a best-selling machine five years down the line.

## So I wrote a cute screensaver

A few months ago, I found a GIF of Kirby (or rather a bunch of Kirbys) dancing. I thought, This would be even cooler if it was set to music. So I set about writing a simple, little HTML5 screensaver.

In the Cinnamon Desktop for Linux Mint, you can write screensavers in HTML5 (technically, it uses Webkit, but we all know that’s a fancier version of KHTML). So I wrote this, chose some dance music, and had it play said dance music randomly every time the computer screen is locked.

If you wish to see a video of it in action, here it is: