SOFTWARE ARCHITECTURE is a tricky subject at the best of times, often mitigated by following a framework. However, when you find yourself in the wilds of Prolog, there's not much guidance out there, and not many templates to follow. In this post, I'll provide some guidance built on the principal of substitution.
SIMPLE, CLASSIC games like Rock, Paper, Scissors are good to code when learning a new language. The lovely thing about making this game in Prolog is you're just encoding what it is, not how it is. It's a subtle difference, but I'll point it out during this explanation.
SOME FOLKS don't make their data available through RDF formats, or nice SPARQL endpoints, instead they provide a (REST/RESTFUL) API and will return JSON data for your request. It can be a little tricky figuring out how to get this data into your SWI-Prolog program. So in this post I demonstrate with a simple example.
READING THE docs for plunit, it can be quite tricky to figure out how to setup a nice unit testing environment and actually run those tests. In this post I demonstrate how I do it, keeping my tests separate from my code, and running them with a handy command.
VIM IS a cruel learning curve, it's a long way from modern text editors, and yet it is still a popular choice for programmers. Why?! Because it's worth it. There are many things Vim does well, many things that I could use to show it off. But for this post, I had to choose only one thing, which is evaluating commands.
THERE WAS a time, long ago, before SVMs and Neural Nets, when AI was all rule based. Nowadays, with the prevalence of "curve-fitting" AI, these techniques are known as GOFAI, or "Good Old Fashioned Artificial Intelligence". In this post we look at a super simple example and consider why you'd use this instead of a more modern method.
ANOTHER LITTLE known Python feature that deserves more love. This time we're looking at the send function that lets you input values into your generator as it's running. It works through yield and is awesome!
A KEY idiom in Prolog is the idea that it runs both forwards and backwards. If you've never programmed in Prolog before, this can be mind-blowing! You can write one function and get many different uses out of it. In this post we'll take a look at what this means as a teaser that might tempt you into giving Prolog a go.
IT'S TRICKY to find out how to set up RDFLib Graph to use a RDBS backend, but it can be done using SQLAlchemy and RDFLib-SQLAlchemy. This means it'll support all the engines SQLAlchemy does, including MySQL and Postgres. I'll highlight two gotchas to look out for when using RDFLib-SQLAlchemy and walk you through getting setup using a wrapper class to RDFLIB Graph.
PYWEEK CHALLENGE 25: Two Worlds, Complete. My entry is submitted, it works, now my real work begins. I intended to create a game similar to the original Rogue, but divided into normal and magical realms. I feel I have achieved this. Now it's time to make it better.
DAY 5 of the PyWeek TwoWorlds challenge, and we have a game. It's not perfect, but it is complete. I still have lots to do, and I'll keep working on it before the challenge ends, but it is in a state where it could be submitted. We have monsters, traps, scrolls, potions, wands, weapons, armour, normal levels, magic levels, and the Amulet of Yendor!
DAY 4 of PyWeek. If it looks like a game, and plays like a game, it's a game! Rogue: Through The Veil is starting to look and play like a game now. It's got monsters, combat, potions, scrolls, weapons and armour. Plus we can now go "through the veil" and pass between magic and normal worlds.
DAY 3 of the PyWeek 25, Two Worlds challenge, and progress is being made. Today we've got more monsters, weapons, armour, scrolls, menus and an improved melee combat system. Lots done, some incomplete and lots still to do. Feeling rushed, worrying about code getting messy.
DAY 2 of the PyWeek Challenge. Combat and creativity was harder than anticipated, but we've got monster generation, they move and melee combat is implemented. Plus there's a nicer GUI with basic HUD. We can also go down the dungeon through the normal world, and to make testing easy, you can never die!
BEGINNING A PyWeek25 entry. The theme is "Two Worlds" and I'm loving Rogue at the moment, so I decided to make a roguelike with a distinction between normal dungeons and magic dungeons. On day 1 I've made a dungeon generator and can explore it with a player. Making use of the tcod Python library.
GOOGLE MAKES extensive use of Semantic Web technologies, although they prefer the term Knowledge Graph. In this post I'll show you how to add structured data to a Flask Blog app, with JSON-LD and Jinja2 templates to help Google understand your content, which in turn should improve SEO.
TWITTER USE the Semantic Web. More specifically they use RDFa markup to define Twitter Cards, which they use to make your website look good when someone tweets it. In this post I'll show you how to include this in a Flask blog application with a Jinja2 template.
FACEBOOK USE the Semantic Web. They have an ontology called "Open Graph" that links your webpage into their social graph. This means when someone shares your webpage on Facebook, it'll look how you've specified. In this post I'll show you how to include this in a Flask blog application with a Jinja2 template.
AN INTRODUCTION to programming the Semantic Web using Python and Flask. We'll make an RDF file to describe ourselves, serve it via Flask, use data from it in a template, encode it into our HTML, and link to it from our HTML.
PYTHON HAS support for lambda functions, Haskell is built upon lambda calculus. The two are not the same and this is the reason why lambda should have been removed in Python3. This post examines the differences, reviews the use in Python, and offers a more pythonic, honest syntax.
OF ALL the functional programming inspired features in Python, partial application must be the best kept secret that you really need to know. Partial application lets you create highly abstract functions and make them more specific for use, pass a function arguments without calling it yet, and so much more.
MAKE USE of functional programming techniques to improve your iteration in Python. By abstracting the function from the iteration you'll have greater code reuse, easier parallelisation, and lower memory usage.