SO retro... that makes us cool, right..?
Play the game (insecure connection) here:
Ratings (show detail)
Release with more in the README.rst
The client working with the server..!
This entry is going to be interesting. In addition to whatever the theme will be, we have determined two further requirements for our entry:
* It's going to be retro... oh so retro.
* We're going to invite ideas and suggestions "from the internet".
Also, PyWeek during Brexit week (subject to article 50 extensions)..? What could possibly go wrong with an entry 50% sourced from the UK..? :-D
TextSmith - a multi-user text based adventure game
Both members of our team love words, writing and telling stories with text. That's how we came up with the idea for our game... an old school MUD/MOO-ish platform but reimagined for today.
We're going to call this platform "TextSmith" because we're forging, beating out and carefully crafting new interactive text based worlds with creative heat and imaginative fire. We hope it plays to our strengths..!
Our server will be a Python/asyncio application with perhaps a Redis data store, probably running somewhere like Heroku (which seems to be the simplest / cheapest [free] option at the moment). We'll use websockets and some static HTML/CSS/JS to provide a user friendly browser based client.
Our intention is to make the world "programmable", so players are able to help build the game themselves and take ownership of the world they imagine and inhabit.
As for the theme, I (Nicholas) wonder about initially creating six distinct literary worlds within the game (e.g. Jane Austen, SciFi, Tolkien etc...). Players build and interact within each world in the literary style of that world. In each 24 hour period a player has some arbitrary number of points to give away to other players as rewards for building or interacting in particularly appropriate, entertaining or otherwise epic ways. Perhaps the more points you get, the more stuff you can build, or you level up to new abilities..? I'm not sure how this may work, and I'm waiting on feedback from my team mate, Andrew (this time we're only 7 hours away in terms of time zone). So this idea may change or become something completely different.
The first task (probably tomorrow) will be to get a simple websocket app running so we can check the client works properly, after which we'll be in full-on platform building with a view to world / game building with the help of anyone else who cares to join in towards the end of the week.
Let the fun begin..!
Argh DNS/SSL Heroku and Gandi
We have a basic ("Hello World") website here: https://www.textsmith.org/
Setting up Heroku: easy peasy
Domain registration at Gandi: easy peasy
Getting Gandi to point to the Heroku app correctly: ARGH
It turns out that Gandi only do "A" records for naked domains (textsmith.org) and Heroku require "CNAME" records. I've tried to setup a web redirect so http://textsmith.org/ and https://textsmith.org/ always point to https://www.textsmith.org/ (which has the required "CNAME" record pointing to the Heroku app), but while https://textsmith.org/ redirects to https://www.textsmith.org/ the unencrypted http://textsmith.org/ redirects to http://www.textsmith.org/ (which isn't what I configured, it should be https since I don't want to receive unencrypted traffic). Something's gone wrong (at Gandi?). Support ticket raised and here's hoping they can shed some light on it.
It's not really THAT important for a hacked-together-game-in-a-week-for-PyWeek, but I like things to work as advertised. ;-)
Day 1, progress report
Sunday was an "off" day (busy doing family things), so today was the proper day 1.
I managed to make a start on the Quart app along with some endpoints and associated templates and CSS. Realising I needed to work on the data models I've spent work on that side of things too and created a bunch of utility functions. It's starting to feel a lot like an MVC architecture (Quart is the view, utility functions the controller, and the data work the model). I'm also working via (mostly) functional programming.
I've also started to create a comprehensive (but incomplete) test suite. Who knows, I may even write docs..! :-)
Lots of Code (but not much to show for it -- yet)
I just checked in almost 2000 lines of Python. Much of this is test code for the game logic layer, which is more-or-less finished (pending user testing). Next stop of the parser which connects the messages coming in via websockets into calls into the game logic layer.
Hmm... writing a parser from scratch.... what could possibly go wrong..? :-)
Testing, Testing, 1, 2, 3....
So the parser is written. The Game logic is done. We're storing the game state "in memory" and dumping it every 5 minutes as a JSON file (on restart, if such a dump exits, it's automatically loaded). Given more time I'd remove all my shonky data related code and just use REDIS.
Unlike previous PyWeeks I've been WRITING TESTS... my god this has been both a positive and negative.
Midweek, I was almost ready to press the "sod it" button, just hack code and forget about tests. It felt I was writing three times as much code as was needed and I wasn't sure anything would be finished in time.
However, I persisted with the tests and I'm so pleased for it. I *know* my parser works because the tests demonstrate it. It feels good to refactor the code as I realise things need to change because the tests feel like a safety net to give me confidence I've not broken anything else.
What's left to do? Connect the websocket code to the actual game, finish the simple JS client and (hopefully) add some simple notion of scripting to the game.
In any case, I've **loved** working on this game, and the team chats with team-mate Andrew have been a huge amount of fun. No matter what, I think I'll still keep refining this game once PyWeek is over (e.g. Redis and a bunch of refactoring I don't have time to do now).
No matter the result, this PyWeek has been the best so far. Thanks Dan for organising it!
So, there's still lots to do, but I've done the metaphorical plumbing of the minimum things to make sure all the layers talk to each other. As a result I've been playing around with the game as a test server on my laptop. It's very simple, but the important thing is that the damn thing appears to work. As always, I've spent HOURS faffing about with CSS then given up.
Also, Quart (the Python aynscio library we're using to serve the application via websockets) is both really very good but not fantastically documented. What documentation that exists, is quite good, although the examples could be more comprehensive. However, many parts of the system remain not-documented enough. Anyway.... Quart is cool and I'll be using again if need be, so thanks to the developers for making something which (once figured out) is really simple and powerful.
Our entry is this release on GitHub: https://github.com/ntoll/textsmith/releases/tag/0.0.1
You can play our game here: https://textsmith.org/
Finishing Line Hosting Shenanigans
To play the game, you'll need to connect to http://textsmith.org.
There's not a lot there at the moment, but we'll be building out the six literary worlds over the coming days... and you're welcome to contribute too. We've written some simple documentation to get you started, although we totally concede that the TextSmith "engine" still needs plenty of refinement.
After some rather subtle problems with Heroku, Gandi based A records and websockets (connections were getting dropped after 55 seconds), I've migrated to a small EC2 instance running on AWS, so please treat it with care. If you get errors please ping me via Twitter (@ntoll). The side-effect is we don't automagically get HTTPS connections, so (sadly) your password will be transmitted in the clear. Please just use a throw away password for connecting to the game for testing purposes.
This has been my favourite PyWeek (my third so far). I'm definitely going to continue with the TextSmith code, it needs refactoring and there are a bunch of gremlins I want to fix. It'll probably be a complete re-write with copious amounts of code-reuse from this original version, but without this first draft, I wouldn't be in a position to understand and see where improvements can be made.
Finally, all the other entries I've submitted in previous PyWeeks have built upon some sort of existing library (e.g. the amazing PyGameZero). This entry was completely written from scratch. The only third party modules are Quart (used for very basic web-facing stuff like static templates and the websockets) and the Python Markdown module (for rendering user generated content).
My favourite part of PyWeek comes next, exploring, playing, enjoying and commenting on all the other entries. This is a source of joyful silliness.
As always, thanks to Dan Pope for making all this happen.