如何调整风险规则会影响游戏?

时间:2013-06-26 22:03:29

标签: c probability dice

我在此处发布此内容以链接到RPG.stackexchange.

我正在进行一个探路者游戏,它将会让大型军队互相攻击。我看到加快速度的建议之一就是使用来自桌面游戏风险的规则。

但风险规则假设单位价值相等。如果将其中一支军队的骰子从d6改为d8,会发生什么?

Answerssimilar questions虽然经过了深思熟虑,但却不适合使用小规则更改的“假设”问题。而且我怀疑数学家会欣赏这种纠缠。

(另外,另外,如果你对统计学没有扎实的掌握,试图学习用R编程是很难的。这并不像知道R的语法告诉你如何拟合线性模型。)< / p>

所以,stackoverflow,给我一个风险(棋盘游戏)模拟器,我可以摆弄规则集,直到我满意它的计算。

1 个答案:

答案 0 :(得分:1)

先生,先生,先生,先生,先生。

//Experimenting with Risk variant
//Because figuring out the actual mathmatics behind this is hard.

#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))

//#define DISTRUSTRAND 1
//#define VERBOSE 1


int g_rollArray[100];

int compare (const void * a, const void * b)
{
  return ( *(int*)b - *(int*)a );
}



int diceRoll(int dieSize)
{
  int roll = rand()%(dieSize-1);
  g_rollArray[roll]++;
  return roll+1;
}


// MAIN!
int main( int argc, char* args[] )
{
  int seed;
  int maxRound=100000;  //Some arbitrarily large number.
  int round=0;
  int i;

  memset(g_rollArray,0,sizeof(int)*100);

  //Hmmm, there could be a mix of troops, but right now, let's say it's uniform.
  const int numAtt = 3; //How many troops they bring into the fight, that's how many dice they roll
  const int powAtt = 8; //The size of the dice they roll. Like d4, d6, d8.  
  int rollAtt[numAtt];

  const int numDef = 2; //How many troops they bring into the fight, that's how many dice they roll
  const int powDef = 6; //The size of the dice they roll. Like d4, d6, d8.  
  int rollDef[numDef];

  int lossAtt=0;  //Assuming a big-ass pool of troops behind them. Whoever runs out of a pool first loses.
  int lossDef=0;


  seed = time(0);
  srand(time(0));
  printf("seed: %d\n",seed);

  #ifdef DISTRUSTRAND
  for(i=0; i<10; i++)
  {
    printf("%d: %d\n",i, rollArray[i]);
  }
  #endif

  for(round=0; round<maxRound; round++)
  {
    for(i=0; i<numAtt; i++)
    {
      rollAtt[i] = diceRoll(powAtt);
    }
    for(i=0; i<numDef; i++)
    {
      rollDef[i] = diceRoll(powDef);
    }

    qsort (rollAtt, numAtt, sizeof(int), compare);
    qsort (rollDef, numDef, sizeof(int), compare);

    #ifdef VERBOSE
      printf("sort Att: ");
      for(i=0; i<numAtt; i++)
      {
        printf("%d ",rollAtt[i]);
      }
      printf("\n");

      printf("sort Def: ");
      for(i=0; i<numDef; i++)
      {
        printf("%d ",rollDef[i]);
      }
      printf("\n");
    #endif


    //The MIN here decrees that armies can only lose the forces they commit to a fight
    for(i=0; i<MIN(numDef,numAtt); i++)
    {
      #ifdef VERBOSE
        printf("Comp: %d Vs %d \n",rollAtt[i], rollDef[i]);
      #endif
      //Defenders win ties
      if(rollAtt[i] > rollDef[i])
      {
        lossDef++;
      }
      else
      {
        lossAtt++;
      }
    }
  }


  printf("Att losses: %d \n",lossAtt);
  printf("Def losses: %d \n",lossDef);

  if(lossAtt > lossDef)
  {
    printf("Odds to win: Defender \nKill ratio: %f\n", (float)lossAtt/(float)lossDef);
  }
  else
  {
    printf("Odds to win: Attacker \nKill ratio: %f\n", (float)lossDef/(float)lossAtt);
  }

  #ifdef DISTRUSTRAND
  for(i=0; i<10; i++)
  {
    printf("%d: %d\n",i, rollArray[i]);
  }
  #endif
  return 0;
}  


/* meh, unneeded, mingw's rand()%whatnot works well enough.
int betterRand(int n)
{
  return rand() / (RAND_MAX / n + 1);
}

float betterFRand(float n)
{
  return (float)rand()/((float)RAND_MAX/n);
}
*/

虽然最初的风险规则集只能让攻击者获得大约8%的优势,这相当于大约1:1.06的杀伤率,但事实证明,如果你改变骰子大小,则几率很快就会发生变化。给攻击者d8,给他们1:3的杀伤率。也就是说,一支以1-8战斗的军队甚至有可能击败一支只有1-6级的军队,但却是其规模的3倍。

如果你将骰子大小保持在军队之间,但是增加它,那么随着关系的影响减少,攻击者的几率会略有变化

增加模具辊的数量会产生更微妙的影响,从而增加模具辊的尺寸。 3 d6的后卫略胜于2 d8的攻击者。

所有这一切对于任何希望玩风险规则并看看结果如何的DM来说都是一个不错的起点。

希望一旦我把头包裹在R周围,我会用图表和东西得到更好的答案。