Difference between revisions of "Experience table generator"

From RogueBasin
Jump to navigation Jump to search
(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...")
 
(return 0 instead of return, and make it a proper graph)
 
Line 30: Line 30:
   int levels = 20;
   int levels = 20;
    
    
  printf("%-10s|  %-13s|  %-13s\n", "Level", "Exp acquired", "Exp until next level");
  printf("-------------------------------------------\n");
   for (level = 1; level <= levels; level++)
   for (level = 1; level <= levels; level++)
   {     
   {     
Line 37: Line 39:
   }
   }


   return;
   return0;
}
}
</source>
</source>


[[Category:Developing]]
[[Category:Developing]]

Latest revision as of 08:06, 12 February 2017

/*
  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;
  
  printf("%-10s|  %-13s|  %-13s\n", "Level", "Exp acquired", "Exp until next level");
  printf("-------------------------------------------\n");
  for (level = 1; level <= levels; level++)
  {    
    printf("Level %2d  |  %-12ld |  %-12ld |\n", level, total, tnl);
    total += tnl;
    tnl = tnl * (1 + pow(factor, level));
  }

  return0;
}