I want to get one thing clear here – this is not a post about The Strange RPG. I have read enough to know that that game uses a thing called recursions which are explained here that are so not what I am discussing. In fact the idea of what is suggested there makes it less of a recursion and more of an expansion. No, I am talking recursive from a computer programmer’s perspective. So, let me try to explain recursion from a computer programmers perspective and then explore how we could use that model in interesting ways to build an adventure, or even a campaign around.
Programmers generally build their programs in a modular fashion, creating methods that can be called several times whenever required. So if I wanted to create a method that returns a number of two values added together it might look like this:
|Return Type (this tells us what is returned with the use of the method)||Method name||Parameter name||Parameter name|
|number||sum||( number1,||number2 )|
That header tells us that the method will give us back a number that will be the sum of number 1 and number 2. The code inside will look something like the following:
return number1 + number 2;
Essentially that is a very simple method, and it is not recursive, yet. What happens is we call this method whenever we want two numbers added together, catch the result and then use it later in the program. But what if we want the sum of all the numbers from 1 through to the number we enter. For example if we wanted to know the value of the sum of all numbers between 1 and 4 we would need either another specific sum method that had four parameters, or a single, simple, recursive sum method that required only one parameter such as this one:
|Return Type (this tells us what is returned with the use of the method)||Method name||Parameter name|
This header shows that we will sum from the 1 up until the number and return the result as a number. The code inside then becomes recursive (and yes advanced programmers there are simpler ways to do this but this illustrates recursion as clearly as possible). Here is the code that would be inside:
number result // this creates a variable that will store the number that we will give back
if(number == 1) // this checks to see if the number put into the method is 1 and does what is on the next line if it is
result = 1;
else //if the number is not 1 do this recursion on the next line instead
result = highestNumber+ sumToNumberFromOne(highestNumber – 1);
OK, do not feel too bad if your head is swimming. I have seen some of the best programmers I know be stumped and clueless with recursion. Let us take it one step at a time and see, if we were using this method how it operates:
Original Call: We call to the method by writing in our code:
number value = sumToNumberFromOne( 3 );
The method then creates a variable called result and checks if the parameter (highestNumber) is 1, which it is not. The program then goes to the else statement and makes the value of result the value of highestNumber (3) + another call to the sumToNumberFromOne( 2 ).
Recursion 1: The original call to this method has resulted in it calling itself again. This is a recursion. So the program starts again by creating another variable called result. Computers can do this and understand that this result applies to this recursion and not the original one. It then checks to see if the parameter (highestNumber) which is now 2 is equal to one. It is not so it goes to the else statement and makes the value of result the value of highestNumber (2) + another call to the sumToNumberFromOne( 1 ).
Recursion 2: The recursion 1 call to this method has resulted in it calling itself again. This is a second recursion. So the program starts again by creating another variable called result. Again the computer understands it belongs to this level of recursion and checks to see if the value of the parameter (highestNumber) is one, which it is now. This activates the next line of code making the variable result become 1. It skips the else statement and then returns the value of result (1) to the next highest step.
Recursion 1: Up until this point this recursion has been waiting for a number to be returned from its call to itself as explained in the block of text above for recursion 1. It now gets a value of 1 returned from that call and therefore it works out its own result value by doing the addition that was set up (result = highestNumber (2) + 1 // the returned amount). This gives result in this recursion the value of 3 and the next return statement gives that value back to the original call.
Original Call: This call has been waiting for the resulting recursions to return a value to it. Now the first recursion has returned its value of three it can complete the method and set the variable value to the result that is handed back. Remember the value of highestNumber at this stage was 3 so (result = highestNumber (3) + 3 // the returned amount) and then hands the result of 6 back to the variable value with the return statement. Thus our original call (listed above) has gone into two recursions and returned the value 6. 6 is equal to 1+2+3. We could enter any number as highestNumber (the parameter) and it would follow this process with the number of recursions created equal to the highestNumber – 1 and it would always give the correct answer.
So for those of you still with me, that is a recursion. Algorithmically speaking they can be very handy in coding BUT very hard to think about! So, how can you apply this to an adventure?
Well, the first situation is one that Super Squadron has taught me about from my very first experiences as a GM in Grade 6 and I encountered a character that had time travel as a power. Now back then the player would only rarely restrict his time jumps to small leaps back to help himself out but sometimes they did. I learnt to record details on a round by round basis so that when they popped out and cried out to themselves “Get Firestorm behind the car, Lupis is about to use a disintegration beam” I would have the details ready so we could play out the alternative future.
So that style of game is an immediate response to a character power, and there are many role playing games out there that mimic this power in one way or another. Because of that you can plot adventures that do the same thing but on a grander scale. Imagine the big bad that is causing all sorts of grief. He could have gone back and eliminated one of the PC’s favourite supporters so that they turn up in town and go see good old Martha for the hints on what has been going around and Martha’s Magic Shop is gone, completely and Bill the Butcher is in there. He has never heard of Martha and has been there for years…
Then there are examples of adventures even bigger than that. Campaigns completely that revolve around this style of play can be fantastic. Playing Doctor Who: Adventures in Time and Space can often become enhanced by these sorts of recursive plot lines and I imagine many games that allow time travel, regeneration, manipulation of planes and the like can all use this idea. There is in one of the recent series of Doctor Who a huge recursive adventure where the Doctor tells his companions that they must follow him to a place in America and whatever they do they must do nothing. An astronaut suit comes up and shoots the Doctor apparently killing him. The shooter is in fact the Doctor himself in a massive plot involving a recursive set of time jumps to build up to this.
Recursions can be built into the same space. A dungeon that has doors that act as portals to the same dungeon but a different time. Or think of a recursive project that does not use time, an action that causes a reordering of the space that you are in (much like the movie The Cube) where you must get the right recursions to create the perfect circumstance for effect.
The secret behind recursions is the idea of working out the logic. This is easier said than done, for example, the simple program above that simply sums some of the details for a single number can still be a confronting piece of logic to think about. If you want to get down to it as well, solutions to mazes are also recursive though I have never played a maze in an RPG that I ever liked 🙂
So, that is it. I hope that one or two of you made it through to the end and have been inspired to give something like this a try. It can take a bit of practice to get it right but when you nail it they can become some awesome adventures. I structured a game of Shadowrun with these concepts once and the players still talk to me about it today (it was in 1993 from memory that I ran it). Give it a go and keep rolling!