Dev Blog #10 – Teaching a computer English
Tony Dorito - January 5, 2017
One of our favorite parts of CURE is the ability to engineer your own units. To do this, while playing CURE you can earn items that will allow you to customize your units in pretty unique ways. These items are called genes. Genes may add to stats, add new abilities, and may change how your unit looks and functions. Some genes may only add these additions if certain circumstances are met. For instance, a pretty typical gene might: “If the gene next to this one adds additional HP, then this gene adds an additional 10 HP”..That is a pretty simple example, but genes can be very complex and can make your units very powerful.
Genes are generated (using a rather long and complex system that I won’t describe for now) and are random to a pretty impressive extent, allowing for countless amounts of genes of varying usefulness, quality, and power. The problem though with randomly generated items while also having complex and complicated requirement and effects, is having a way to coherently explain to a player exactly what a gene does.
Believe it or not, in some instances, it can be harder to describe something to someone else in English, than it is to actually implement it in a video game. It is not uncommon to have an hour long meeting about how something should work, to just turn around and add that change in a line or two of code, spending a whole 5 minutes on it. This type of thing is very true for genes and how they function. Applying a gene to a unit requires a rather complicated amount of logic and defining of concepts,… but it is much easier than having the computer explain in English ‘what’ it is doing and why.
The following code is an example (this is roughly what the current production code in CURE looks like, I have simplified it a bit to try and make it relatively easy to follow, hopefully):
if ( nextGene.has(HP) ) thisGene.HP.add(10);
With a single line of code, with less than 45 letters and numbers, I was able to properly describe to a computer what I want to do. I want to add 10 to hp on this gene only if the next gene has any HP stat on it. In contrast,… for me to explain it to someone in english (and how we want it to show up in game), it may read:
If the next gene has the hp stat, this gene will add an additional 10 to hp.
And that takes about 80 letters and numbers (nearly double), and it is riddled with all sorts of neat gotchas.
—————————————————————-
For instance, by simply changing how many genes you are ‘checking’, you significantly change how the sentence is worded, where this is not the case with programming.
if ( nextTwoGenes.has(HP) ) thisGene.HP.add(10);
The parts in bold are what have changed. As you can see, not much has changed. In reality, we are just checking two genes now, instead of just the one, so the change is just from ‘next gene’ to ‘next two genes’ which isn’t a huge change.
If the next two genes have the hp stat, this gene will add an additional 10 to hp.
The parts in bold are what have changed. As you can see, a few things have changed.
So, with English, if you are talking about one or multiple things, sometimes you will use “has” and “have”. Fluent English speakers make these changes without giving too much thought to it, you can easily know intrinsically what ‘sounds right’.
For instance, if you didn’t make those changes, and just added the ‘two’ genes part, it would read:
If the next two gene has the hp stat, this gene will add an additional 10 to hp.
And that doesn’t sound all that good.
————————————————————-
Or, what if you change how many genes are affected?
if ( nextTwoGenes.has(HP) ) nextTwoGenes.HP.add(10);
Again, the only real thing that is different is which gene is being changed, and in this case, it includes two genes.
If the next two genes have the hp stat, those two genes will gain an additional 10 to hp.
Whereas, in English, you can’t really reference multiple things like we did in the prior example by using the word ‘that’; but ‘those’ works really well to reference multiple things. Also, changing ‘adds’ to ‘gain’ just sounds a little better to me.
Without those changes, it would read:
If the next two gene has the hp stat, that two gene will add an additional 10 to hp.
And that doesn’t sound all that good, either.
—————————————————————–
So, comparing the first and the last examples:
if ( nextGene.has(HP) ) thisGene.HP.add(10);
if ( nextTwoGenes.has(HP) ) nextTwoGenes.HP.add(10);
Not much has changed. You simply say there are two genes that are being checked and affected. Easy peasy!
If the next gene has the hp stat, this gene will add an additional 10 to hp.
If the next two genes have the hp stat, those two genes will gain an additional 10 to hp.
In contrast, to say the same thing but in English, many of the words needed to be changed to make a coherent sentence.
——————————————————————-
And that is just one example of many little English gotchas that we have addressed in creating the gene description generation in CURE. So, at the end of the day if I have done my job correctly, hopefully you won’t ever notice the hours of tedious work that went into getting the descriptions of genes to sound ‘just right’.
To our friends from other countries that speak other languages than English, we fully intend on translating CURE into your language when the demand presents itself. We are already considering translating the game into Russian do to our great Russian fans. ???????!
Tweet