Experience table generator

From RogueBasin
Revision as of 15:27, 20 November 2014 by HappyPonyLand (talk | contribs) (Created page with "<source lang="c"> /* This is a utility for generating experience point tables. Each line printed will display a level number, the number of points required to reach tha...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
/*
  This is a utility for generating experience point tables.

  Each line printed will display a level number, the number of points
  required to reach that level and finally the gap to the next level.

  Compile with something like: gcc -lm xptable.c -o xptable

  ulf.astrom@gmail.com / happyponyland.net, 2014-11-20
*/

#include <math.h>
#include <stdio.h>

int main()
{
  long total = 0;
  int level;

  // You probably want to change these!
   
  // Points required to go from level 1 -> 2
  long tnl = 100;

  // How quickly the curve flattens out
  double factor = 0.95;

  // The number of levels to display
  int levels = 20;
  
  for (level = 1; level <= levels; level++)
  {    
    printf("Level %2d  |  %-12ld |  %-12ld |\n", level, total, tnl);
    total += tnl;
    tnl = tnl * (1 + pow(factor, level));
  }

  return;
}