Month: August 2020

Trying to go schemaless

Trying to go schemaless

3.5" Floppy disks
Image by PublicDomainPictures from Pixabay

In my post SQL or NoSQL two days ago, I was dancing around the problem which is I am trying to avoid using a schema for the game’s database tables. NoSQL allows this, whereas a relational database of fixed schema tables (SQL) s more restrictive.

One reason for this is to make it easy to add new features without having to run an upgrade every time I want to add say a column in a table. I’m moving towards some key of key-value store.  This is not a real-time game but a more traditional data-processing engine which reads in a lot of data then process it and then writes out the altered data.

The data quantities are not really that big, a maximum of 10,000 players in one game using 10 KB each so maybe 100 MB of data so it could all be managed say by storing the data in JSON files rather than a database.

In the past I might have used a SQL database and I have used SQLite in a desktop application. It is fast, but if I can hold everything in RAM it will be faster still.  JSON does bulk up data a bit but nothing like as bad as XML which can be five-six times bigger.

Back when I programmed something comparable to this in 1989-1990, these (in the picture) were the standard media. Hard disks had not been around long and were quite expensive! These could hold a whopping 1.44 MB each.. CDs for data did n’t even exist then.


The fun of game design

The fun of game design

Image by Pexels from Pixabay

My new side project is a free to play multi-player mobile game about living the life of a celebrity. It’s brutally competitive and will accommodate up to 10,000 players in one game. It scales horizontally so multiple games can be run at the same time. It’s an idea I’ve had for years and now I’m on it.

The idea is that you start moving to the big city. A city where your dreams can come true by becoming famous in some field. Whether breaking into film,  or sport, on TV, a famous writer and so on.  But first as a wannabe, you have to get a job, whether its pumping gas, waiting on or one of a dozen jobs.  And try to make your way up the greasy pole to the top of the A-List.

I have devised mechanisms for this. But there’s way more depth to the game than what I’ve said. The game is basically about decision making. Every action has consequences. If you go to this party, you might make friends with someone who can open doors that will give you more public exposure and earn celebrity points.

The game server generates events that you can attend. It’s a busy life attending openings, first nights, filming of videos, commercials, going to auditions, making guest appearances, signing books, partying, going to concerts, balls, awards ceremonies, opening fayres, launching ships, or more mundane things like product launches, endorsements, appearing in TV adverts and more.

All this has to take place in a game city. So the game server has to create a city populated with buildings, with jobs. Celebrities actually do jobs. Those books don’t write themself, or films make themself. Musicians have to record songs, go on tours. But you are also interacting with other players, helping them and helping yourself.

As a game designer and programmer I have to translate all this into code. In the past I programmed postal games. These were games where orders were sent by post, processed, results printed out and then mailed back. In this case, they’re entered on mobile and uploaded to a game server. Here a program will run at regular intervals and process a day’s activities. All those parties etc. have to be processed and the consequences determined. Did you make friends, did you get any new job offers? Have you accumulated some more celebrity points and moved up in the league table? Did you escape from being a wannabe to C-lister yet?

Then after that’s all done, the results and new decisions can be fetched onto mobiles and players decide what their next decisions will be…  That’s what I’m designing and programming. Both the game server engine and the mobile clients.

Completely off-topic but how to tether an iPhone to Windows 10

Completely off-topic but how to tether an iPhone to Windows 10

A PC tethered by two phonesThanks to an apparent hardware failure in my internet modem (power light remains stubbornly off), I found myself without internet except on my iPhone which has 20 GB of 4G data allowance.

Normally in a month I use less that 0.25 GB of the 20 GB $G monthly allowance data because of fast WiFi at home and at work but I do use it for phones and messages.  It’s convenient on rare occasions when I’m out though to have internet access ability on a phone.

Unfortunately for reasons best known to Microsoft or Apple or both, iPhones no longer seem to tether with Windows 10.  They did for Windows 7 and it’s a real PITA.

But there is a way to manage it. Just use an Android phone as well. If the Android phone had mobile data then no problem but even if it doesn’t, it can tether to my iPhone over WiFi. And my PC can tether to the Android phone using a USB cable and that is how this is being brought to you.

NoSQl or SQL?

NoSQl or SQL?

Image by Gerd Altmann from Pixabay

I’m still continuing C# development but no longer on MonoGame. My needs have now switched to Flutter. If you haven’t come across it, it’s a cross-platform mobile development system from Google and uses their Dart language.  This is a modern language originally created back in 2011 as a potential replacement for JavaScript. That didn’t work out as other browser creators (Microsoft, Apple and Opera) didn’t go for it.

So Dart sort of languished until three years ago when Flutter emerged as an alternative to POA (Plain old Android development in Java/Kotlin). Flutter is the UI technology- interestingly it redraws the screen controls at 60 times per second, a bit like MonoGame. But this is no game.

The UI is programmed in Dart and it has one unique feature: You can make a change and see it live in one second. It’s called Hot Reload and compared to the old Compile, redeploy and run cycle is quite amazing., Also Flutter is cross-platform and has controls for iOS that look like Apple native controls.

Now my big decision is whether to use SQL or NoSQL to store data. The data isn’t exactly ordered like a schema, more like each database record has a variable number of name=value pairs. Which certainly suggests something NoSQLish.


So no response to the programming challenge

So no response to the programming challenge

Pen and paper
Image by Karolina Grabowska from Pixabay

A month ago I set a programming challenge but have had no response.  This could be not enough visitors (about 15-20 a day), or the nature of me posting daily on a WordPress blog where entries vanish.

That challenge was to identify the 100,000th number in a sequence of nine digits numbers that start at 1234567879 and finish at 987654321 where each digit only appears once. It’s relatively easy to program.

It’s also not that difficult to do manually if you think of factorials. As each digit appears once there 9! different numbers possible. There are 9 possibilities for the first digit then 8 for the second and so on. 362,880 in total. (I think…).

So of all the numbers in the range the first 8! (40,320) must start with 1, the 2nd 8! with 2, the 3rd 8! with 3. So the 100,000th is going to start with a 3 as it occurs somewhere between the 80,640th and the 120,960th. You can then apply the same logic to work out where the 2nd digit is going to lie and so on. I did it on a piece of paper and it took me about 20 minutes to figure.

You don’t need maths (or math as US readers will be familiar with) to program computers but on occasions it can come in handy. Especially with games and random numbers, combinations and so on.

Consider entering a game jam

Consider entering a game jam

Game jamsMuch as I like creating games, game jams are not really my thing as I like to spend time polishing and making them look good and that’s not really how you want to spend your 24-72 hours.

But clearly they are for others as the GMTK Game Jam in 2020 had over 5,000 entries! Here’s a GitHub staff pick of their favourite top ten entries.

What is a game jam? Well Wikipedia helps out “A game jam is a contest where participants try to make a video game from scratch. Depending on the format, participants might work independently, or in teams. The contest duration usually ranges from 24 to 72 hours. Participants are generally programmers, game designers, artists, writers, and others in game development-related fields.”

There are probably more game jams going on than you imagine. The website has a list of forthcoming game jams plus links to past ones.

How I track ideas

How I track ideas

About twelve years ago I came across WOAS (= Wiki on a Stick). It was a single HTML file notebook with built in JavaScript and you opened it in a browser. It showed a simple interface and you could switch it into edit mode and start adding in text in markdown format. It was very easy to create links to pages in the document and add new pages.

And it was all saved in the document. Also very easy to find the text. It had one excellent feature which I miss, You could have a page self-encrypt using AES-256. Great for holding passwords etc.

I used WOAS to deign software and had at least one very detailed design with several hundred pages each with links to other pages. Sadly WOAS was eventually killed by the browsers themselves, preventing files writing to disk. It’s not the only example of a single-file Wiki but they all suffered the same problem. I think someone came up with a Java shim that did the file writing but it was never the same.

Now I use WikidPad, it’s written in Python and I think just runbs on Windows, (though you wouldn’t know it) which works like WOAS but internally it uses SQLite to hold the Wiki pages.  You can even use their website WikidPad but you have to register first.  That picture is a screenshot of WikidPad.

An example of a game idea

An example of a game idea

Sometimes I wake up in the middle of the night and my brain is bursting with ideas. I’ve just finished reading Shaman by Kim Stanley Robinson that’s set 30,000 years ago and came up with ideas for a tribes game very loosely based on that (Absolutely nothing to do with the plot of the book!) .  I opened up my iPhone around 3:00 a.m. and these are the notes I wrote down in the Notes app.

I opened my email (Gmail) which picks up notes from my phone automatically, so I have the notes now here in my PC.  They are as I wrote them so they are quite rough.

“Tribe game. All players start with a small village and 50 tribes people.
Can relocate, hunt, plant etc. Can raid other tribes. Can split tribes spread over land. Have children. Found religion. Use animals. New options as tribe progresses. Discover and trade gold, furs. Tribes can move to other places or settle and form villages.
Raids build up resentment between tribes. Enough resentment leads to war. But can reduce resentment by gifts of women, food, furs etc st festivals.
Can do crafts, paint, culture, spirituality, warfare, building. Each has 1-10 levels with names. Orders focus on an area.
Better food means stronger, smarter.
Periodic festivals. Tribes get together and share attributes.
Run for 1,000 years. 100 turns x 10 years. “

And that’s how they go into WikidPad. Then I start fleshing them out into a fuller multi-player game.  Of course I come up with lots of ideas and few will make it into an actual game creation but its always a good idea to keep them. In the future it may yet become a game…

And how was the book? Very good.

How to create an Alphabet bitmap in CSharp

How to create an Alphabet bitmap in CSharp

Letters generated by the programHere’s another short utility. I have been looking for a decent alphabet to look in my next game (called HogWash) . As before, I want to create a sprite sheet with letters. But every alphabet set that I found had issues with kerning. I kid you not, usually but not always with M, W, or even Q.

Even when I put together a sprite sheet manually, the editor didn’t quite get it right and letters didn’t quite fit the grid. So to simplify it, here;’s a 50 line C# program that takes the letters you supply in a string, combined with a font (Liberation Mono- from Red Hat) and a brush (black solid). It does a double loop that I exit with a goto (shock horror!) when it reaches the a terminating * in the string I supplied.

That is the graphic file above that the program below generated. As you can see the letters are far enough apart so no overlapping. Just put in your path where I have for the source and dest consts. You can use this technique for building sprite sheet.

// Author D. Bolton You are free to use and copy this program as you wish but please leave this line in.
using System;
using System.Drawing;
using System.Drawing.Imaging;

namespace buildfont
    class Program
        const int LetterWidth = 100;
        const int LetterHeight = 120;
        const string source = "Your path"
        const string dest = @"YourPath\letters.png";

        static Bitmap allLetters = new Bitmap(LetterWidth * 8,LetterHeight * 5);

        static void Main(string[] args)

        private static void BuildOneImage()
            var font = new Font("Liberation Mono",95);
            var brush = new SolidBrush(Color.Black);
            var str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ*";
            Console.WriteLine("Creating letters.png");
            var aty = 0.0f;
            using (Graphics g = Graphics.FromImage(allLetters))
                var strindex = 0;
                for (var y = 0; y < 5; y++)
                    var atx = 0.0f;
                    for (int x = 0; x < 6; x++)
                        string aLetter = str[strindex++].ToString();
                        if (aLetter == "*") goto Done;
                        g.DrawString(aLetter, font, brush, atx, aty);
                        atx += LetterWidth;
                    aty += LetterHeight;
            allLetters.Save(dest, ImageFormat.Png);
A spot of market research

A spot of market research

Image by Benjamin Nelan from Pixabay

This is market research for a side-project I’m working on. I’m developing a server and mobile clients to play multi-player games over WiFi. The server software would cost about $15/£12 and 1$ for the game client on Android/iOS. It will come with 8-10 games including card games such as Texas Holdem, and a board game or two. All games will be single-player as well (well not poker!). If it takes off I’d like to licence popular board games.

There will also be an SDK for creating new games and some financial arrangements for games to be sold through a “Pi bakery” i.e. app store. Games can either be included in the standard package or low cost add-ons.

I’m just trying to assess if there would be demand for it. If you have any comments or thoughts, I’ve posted this on the Raspberry Pi forums. as well.

It is often said that you shouldn’t give away ideas but I’ve decided to anyway. I really need to find out if anybody would buy this. If not then I have a plan B side-project waiting in the wings. But I do like this and I’ve already gone down the implementation route a bit.


Sadly I have decided to ditch this side-project. I didn’t get great response; although there are 31 million Pis out there, getting people together especially with Covid is not easy. So I’m mothballing this for now. There is a B2B commercial possibility but I’ll come back to that in a year or two. Instead I am going onto my next project a mobile MMO.