Home | About | Tournament Winning Decklists | Forums

R&D random access: stats and plots


So, just for fun I have been developing some python code to analyse decks and get (useful?) numbers out of them.

I started by focusing on R&D access. In particular I wanted to check how the average number of R&D accesses required to score 7 points changes depending on the corp archetype we are playing against. To this purpose I wrote some code that essentially does a Monte Carlo experiment and returns the frequencies of the required number of accesses to win a game. The procedure is as follows:

  • take a deck, shuffle and remove the top 6 cards (5 cards of starting hand + 1 mandatory draw)
  • look at the remaining cards and count how many cards I have to see to arrive at 7 agenda points, record that number. In term of games, this would correspond to a strict R&D lock where the runner runs and see one card every turn. If it is an Agenda he//she scores it and runs again. If it is not an Agenda, the corp draws it.

Repeating the above points 105 times (or playing 105 games) results in an array containing 10**5 numbers each quantifying how many accesses were necessary to ‘win’ a game. I then proceeding essentially by binning these numbers to produce a normalised histogram (area=1, width of each bin=1), i.e. counting how many times I had to run 1, 2, 3, …n times in order to win the game.

The histogram therefore shows you the (probability) distribution of the number of R&D accesses required to win a game against a particular corp: the height of the n-th bar corresponds to the fraction of games that have been won on the n-th access. The number of games won, on average, with a number of accesses n* or less is given by the integral (i.e. the area) under the histogram up to n*. As the the bins (each bar) is large one, the area simply equals the sum of the heights of the bars up to the one of n* included.
This running sum or, if you prefer, the cumulative distribution function, is also plotted in the form of cumulative histogram against the number of accesses performed. From the cumulative distribution function it is easy to read off the number of accesses necessary to win, always on average, a certain percentage of the games: just pick the y value matching the percentage you are interested in (0.25, 0.5 and 0.75 are shown with dashed lines) and read off the corresponding number of accesses on the x axis.

Enough of talking, now I’ll show some results for popular decks which I took from NetrunnerDB.

The first is @Cerberus Crusade mk2

then I picked the NEH which was 1st seed at worlds after the Swiss

and some popular Government Takeover deck.

I also analysed a blast form the past: @PeekaySK’s CI deck

Now, all of this is still quite rough, in terms of game the corp is simply drawing one card per turn. However knowing more or less how many accesses you have to have gives you an idea of how many credits you need to generate to support the corresponding runs.

If you are curios to see the histogram for some specific corp deck just let me know.


I’d like to see RP but I’m not sure how you should handle TFP


Randomly pick 2 numbers [0,1,2] obviously :wink:


I actually might implement it by picking two random numbers in [0, 2] and if they are the same score, otherwise it is lost


Honestly, it wouldn’t feel very appropriate because you might, knowing its there run back in a bunch of times while its on top of R&D.

I’ve dome some basic analysis on basic agenda competitions using some probabilistic functions that exist; but this sort of thing gets harder to calculate as extenuating circumstances occur.

One I think is worth modeling though, would be keyhole + jackson timeliness. Just program jackson to be greedy on the archives run. And program the keyhole player to always trash jackson when given the option.


I feel like any modern model of this sort of thing has to consider Jackson Howard to be of very much use. Corps Jackson away agendas in the vast majority of games, leading to situations where HQ gets better and better and then all of a sudden R&D gets a lot better than it has been for the entire game up to that point. I think if you could find a way to model the situation with the assumption that the Corp Jacksons away some amount of agendas based on what they have drawn somewhere around turn 4-7 it would be a lot more useful. In reality, there are many games where your best option is to barely or never run R&D until you’re very close to the end of the game.

Perhaps it would be simplest to say that the runner gets 1 or 2 R&D accesses only up until some jackson turn, and then continue the distribution with the higher postjackson agenda density.


Awesome! Let’s tinker with this :stuck_out_tongue:

I’d love to see the graph for a 6x3 Harmony Medtech build. For bonus points, maybe assume a Shi-Kyu fires from RnD accesses (sounds like a reasonable simplification for what I’d like to find out) and do a second graph with 3 of those in the deck.


@V01d: this is great! Any community in which someone can post CDFs and not be shouted down is a community I’m proud to be a part of.

What you’ve done is great. I’m going to make a ton of suggestions, and please ignore all of them. You can read what follows as, “what you’ve done is awesome…it is inspiring me to think about the possibilities” much more than, “ahhh, it needs all of these improvements, please do!”.

@mediohxcore makes a great point about Jackson. Instead of hard-coding any fixed number of accesses pre-Howard, I’d imagine it shouldn’t be too difficult actually simulate Howard draws, and the subsequent dilution of R&D (or increase in agenda density if flooded). A few observations:

  • Doing the simulation assuming that the Corp draws one past the lock each turn would also be interesting. This information can help understand the actual positive impact of the decision to draw past the lock in an actual game.
  • Jacksons can be simulated the same as agendas. A simple hard-coded behavior with the corp trashing Jacksons on R&D when seen would slightly change the curves in the case where the corp doesn’t draw past lock.
  • When simulating drawing past lock, the corp can draw into Jacksons. In that case, you can add any jacksons that have previously been trashed, and up to 3 other non-agenda cards into R&D, and continue the simulation.
  • You can do the same, simulating drawing 2 cards past lock. This will yield interesting information into the impact of R&D lock vs. occasional accesses.
  • This can be complicated by one additional condition: When the crop draws into a Howard and has drawn more than X agendas (for some reasonable value of X), min(X-1,3) agendas (X-1 as we’ll keep one in hand) are shuffled back into R&D. Now we’re starting to BS on the value of X (i.e. the number of agendas scored, plus the number we’re OK with in hand), but this might be interesting.

In short, we can’t simulate actual human behavior, but we can do a sensitivity analysis in these simulations to vary the different variables to simulate different actions, and see the results of those actions.

As this will generate a lot more data (or any other future enhancements you make), you might consider just using horizontal candlestick plots which give information about average, stddev, and max/min. They would enable you to represent a reasonable summary of the distributions you have, in a compact way. Given this, you could compare different decks in the same plot without it being too busy, or compare the different actions above with Jackson, or different values of drawing N past lock in the same plot. I think this would give useful information as to how the probabilities change when you have a total vs. a light lock, and can inform player behavior during games (i.e. is it worth running on R&D now?).

Anyway, sorry for the brain dump. I think what you’ve already done is great.

My simulator is also python. If you keep developing this, we might want to merge at some point. I haven’t had any time to improve my simulator (too much OS code to write!), but time will ail this.


Yes, Jackson messes things up a bit and, sadly, it is quite a pain in the ass to model.
Determining when the corp sees the first JH is not a problem: you can simply find it out after you shuffle the deck at the beginning of every simulated game. However, I have really no idea as to how to implement an ‘average’ use of the card (how many clicks spent to draw? when is he popped?). Should somebody have a nice idea, please let me know.

This being said, I however don’t expect major changes in the histograms if the runner suspends his/her accessing R&D while Jackson is on the table. I think this could be a fair approximation given that the general reaction to JH is starting to probe HQ (which as you said becomes better and better) and/or trying to get rid of it as soon as possible.
Provided that the runner returns to probe R&D only after corp popped JH, I don’t expect big deviations.
Sure, JH can dilute R&D by shuffling back 3 non-agenda cards, however most of the times the card is used to shuffle back agendas that were previously dumped in the archives. Obviously this increases the agenda density so things might even be a bit better than how they look like from my plots.

I’d love to see the graph for a 6x3 Harmony Medtech build. For bonus points, maybe assume a Shi-Kyu fires from RnD accesses (sounds like a reasonable simplification for what I’d like to find out) and do a second graph with 3 of those in the deck

@PeekaySK: Sure, I can do that but I have to implement Shi.Kyu first. As I am already there I can even try to implement the psy game for TFP. What’s a good maximum number of times that a runner will try the psygame in a raw? I’d say 3 at most.


Thanks! Now I have too little time to reply in detail to the points you made, I promise I’ll do that tomorrow.

The first plot is for grail RP. At the moment I assume the runner scores TFP but yes, I am going to improve the implementation of this Agenda by perform 2 or 3 psy games.


This is exactly what I was saying. R&D tends to get A LOT better after Jackson, not worse, and it’s super significant. If the runner can keep the corp from scoring for a long time, they can wait and wait and wait and eventually R&D gets twice as good as it was in the beginning of the game.


That’s usually how I win with Kate :stuck_out_tongue:


If you wanted to be super sophisticated, you could probably use a Bayesian model to estimate the number of agendas in HQ and R&D at any given point in the game.


At the moment I would assume flat priors for everything, so not much to gain :stuck_out_tongue:

Sure, but as you said the runner has to wait and wait and wait. I thought this was an uncommon strategy and supposed that runners would try to get rid of JH ASAP. In the opposite case, how many clicks of JH do you reckon that runners allow before trying to force the corp to pop him? This number would be a good starting point for modelling JH.


The runner doesn’t have to wait very long at all. Assume for the sake of argument the corp is playing 11 agendas. Lets say they’ve drawn 12/49 cards and take a turn to pitch the 3 agendas they have drawn back into their deck with Jackson. The turn before they use Jackson, their deck is 8/37 (21.6%) agendas. After they shuffle 3 more in and have drawn, say, 3 extra cards or something, their deck is 11/37 (29.7%) agendas. It’s like you’ve installed half an RDI without doing anything.


Couldn’t they have drawn an agenda in those 3 cards? 29.7% seems like the best case (for the runner), but neither guaranteed nor average.


Yes, I agree this could be interesting. When I have some time I’ll modify my code to implement the option of drawing n cards behind the lock, as well as accessing more than one card on the runner’s side.

At the moment I am assuming that runner has a complete lock and trashes all the Jackson. I would like to understand what’s an average use of JH to code it down but it seems tricky. What @mediohxcore was suggesting in his last post seems reasonable but I don’t know how to code it in because it necessarily requires some deviation from R&D lock in the early stages of each simulated game. If you are interested to bring this further I can share the code and whoever is willing can join in the effort.

Sure, we should give a ‘shuffle-back’ priority to each card. At the moment my script reads in an OCTGN deck file and gives you the histograms. Here we have to compile a huge table which depending on the deck archetype assigns different weights to different cards.

I’ll put a flexible option of corp drawing x and runner accessing y, or something like that.

Yes, this is interesting but we have to solve first the problem of deviation from R&D lock. Once that is done we Have to understand how fast the runner can achieve R&D lock (maybe simulating some runner draw) and then we can code in Jacksons and stuff.

Sure, I know nothing about GUI and stuff so I am running the thing within an ipython notebook. My hope is that one day we could see some similar analysis on something like NetrunnerDB. For instance beside producing this plot I can calculate the probability of having say 1 specific card in your starting hand (which is already implemented on NetrunnerDB) but I can also plot how this probability evolves as a function of the cards drawn. This is quite useful in general, for instance to see how much economy/ICE you can expect to see within n draws.

As I was saying to @YCombinator, I believe this is actually a reasonable behaviour. I will try to code this down but I have first to understand how to deviate form the R^D lock regime.

If I was corp I would draw at least 2 agendas, that’s guaranteed.


It’s a good case for the runner in that example, but I’ve played plenty of games where I soft locked out a remote server and only ran R&D when there were like, 15-20 cards left, with about 35-40% agendas.


Start with a (multinomial) hypergeometric distribution and Kalman filter from there.