Пример #1
0
/* >>>>>>>>>> EXA12_1 <<<<<<<<<< */
void exa12_1 (void)
{ int n = 50 ,i, j;
  static int ixp[4] = {200, 1999, 1999, 200},
             iyp[4] = {2600, 2600, 801, 801};

  double fpi = 3.1415927 / 180., step, x, y;

  step = 360. / (n - 1);
  for (i = 0; i < n; i++)
  { x = i * step;
    for (j = 0; j < n; j++)
    { y = j * step;
      zmat[i][j] = (float) (2 * sin (x * fpi) * sin (y * fpi));
    }
  }

  setpag ("da4p");
  disini ();
  pagera ();
  hwfont ();

  axspos (200, 2600);
  axslen (1800, 1800);

  name   ("X-axis", "x");
  name   ("Y-axis", "y");
  name   ("Z-axis", "z");

  titlin ("Surface Plot (SURMAT)", 2);
  titlin ("F(X,Y) = 2*SIN(X)*SIN(Y)", 4);

  graf3d (0.f, 360.f, 0.f, 90.f, 0.f, 360.f, 0.f, 90.f,
          -3.f, 3.f, -3.f, 1.f);
  height (50);
  title  ();
  shlsur ();
  color  ("green");
  surmat ((float *) zmat, n, n, 1, 1);

  color  ("fore");
  grfini (-1.f, -1.f, -1.f, 1.f, -1.f, -1.f, 1.f, 1.f, -1.f);
  nograf ();
  graf   (0.f, 360.f, 0.f, 90.f, 0.f, 360.f, 0.f, 90.f);
  dashl  ();
  grid   (1,1);
  grffin ();

  grfini (-1.f, -1.f, -1.f, -1.f, 1.f, -1.f, -1.f, 1.f, 1.f);
  graf   (0.f, 360.f, 0.f, 90.f, -3.f, 3.f, -3.f, 1.f);
  grid   (1, 1);
  grffin ();

  grfini (-1.f, 1.f, -1.f, 1.f, 1.f, -1.f, 1.f, 1.f, 1.f);
  shdpat (7L);
  solid  ();
  areaf  (ixp, iyp, 4);
  grffin ();
  disfin ();
}
Пример #2
0
Файл: Graph.cpp Проект: Keeo/PPR
void Graph::load(char* filepath)
{
	std::string line;
	std::ifstream graf(filepath);
	if (!graf.is_open())
	{
		LOG("ERR", "File cannot be opened!");
		return;
	}

	getline(graf, line);
	cnodes_ = std::stoi(line);
	nodes_ = new Node[cnodes_];
	removed_nodes_ = new bool[cnodes_];

	for (unsigned int i = 0; i < cnodes_; ++i) {
		std::stringstream ss;
		ss << "Processing node " << i << " friends: ";
		nodes_[i].init(i);
		getline(graf, line);
		for (std::string::size_type j = 0; j < line.size(); ++j) {
			if (line[j] == '1') {
				ss << j << ", ";
				nodes_[i].addFriend(&nodes_[j]);
			}
		}
		removed_nodes_[i] = false;
		LOG("inf", ss.str());
	}
	graf.close();
}
Пример #3
0
/* >>>>>>>>>> EXA_6  <<<<<<<<<< */
void exa_6 (void)
{ int i, ny, nx;
  static float    x[2] = {3.f, 9.f}, y[2];
  static char *ctyp[8] = {"SOLID",  "DOT",   "DASH", "CHNDSH",
                          "CHNDOT", "DASHM", "DOTL", "DASHL"};

  setpag ("da4p");
  disini ();
  setvlt ("small");
  pagera ();
  center ();
  chncrv ("both");
  hwfont ();

  name   ("X-axis", "x");
  name   ("Y-axis", "y");

  titlin ("Demonstration of Curve", 1);
  titlin ("Line Styles", 3);

  graf   (0.f, 10.f, 0.f, 2.f, 0.f, 10.f, 0.f, 2.f);
  title  ();

  for (i = 1; i <= 8; i++)
  { y[0] = 9.5f - i;
    y[1] = 9.5f - i;
    ny = nyposn (y[0]);
    nx = nxposn (1.0f);
    messag (ctyp[i-1], nx, ny - 20);
    curve  (x, y, 2);
  }

  disfin ();
}
Пример #4
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{

    ui->setupUi(this);
    setWindowTitle(tr("My Progaramm"));
    QObject::connect(ui->openfile, SIGNAL(clicked()), this, SLOT(open()));
    QObject::connect(ui->table, SIGNAL(clicked()), this, SLOT(colum1()));
    QObject::connect(ui->grafbutton, SIGNAL(clicked()), this, SLOT(graf()));
    QObject::connect(ui->interbutton, SIGNAL(clicked()), this, SLOT(interpol());
}
Пример #5
0
/* >>>>>>>>>> EX14_1 <<<<<<<<<< */
void ex14_1 (void)
{ int n = 50, i, j;
  double   fpi = 3.14159 / 180., step, x, y;
  float  zlev;

  step = 360. / (n - 1);

  for (i = 0; i < n; i++)
  { xray[i] = (float) (i * step);
    yray[i] = (float) (i * step);
  }

  for (i = 0; i < n; i++)
  { for (j = 0; j < n; j++)
    { x = xray[i] * fpi;
      y = yray[j] * fpi;    
      zmat[i][j] = (float) (2 * sin (x) * sin (y));
    }
  }

  setpag ("da4p");
  disini ();
  complx ();
  pagera ();

  titlin ("Contour Plot", 1);
  titlin ("F(X,Y) = 2 * SIN(X) * SIN(Y)", 3);

  name   ("X-axis", "x");
  name   ("Y-axis", "y");

  intax  ();
  axspos (450, 2670);
  graf   (0.f, 360.f, 0.f, 90.f, 0.f, 360.f, 0.f, 90.f);

  height (30);
  for (i = 0; i < 9; i++)
  { zlev = (float) (-2. + i * 0.5);
    setclr ((i + 1) * 25);
    if (i == 4)
      labels ("none", "contur"); 
    else
      labels ("float", "contur");

    contur  (xray, n, yray, n, (float *) zmat, zlev);
  }

  height (50);
  color  ("fore");
  title  ();
  disfin ();
}
Пример #6
0
int main ()
{ int n = 100, i, ic;
  double fpi = 3.1415926 / 180.0, step, x;
  float  xray[100], y1ray[100], y2ray[100];

  step = 360. / (n - 1);

  for (i = 0; i < n; i++)
  { xray[i] = (float) (i * step);
    x = xray[i] * fpi;
    y1ray[i] = (float) sin (x);
    y2ray[i] = (float) cos (x);
  }

  metafl ("cons");
  scrmod ("revers");
  disini ();
  pagera ();
  complx ();
  axspos (450, 1800);
  axslen (2200, 1200);

  name   ("X-axis", "x");
  name   ("Y-axis", "y");

  labdig (-1, "x");
  ticks  (9, "x");
  ticks  (10, "y");

  titlin ("Demonstration of CURVE", 1);
  titlin ("SIN(X), COS(X)", 3);

  ic =   intrgb (0.95,0.95,0.95);
  axsbgd (ic);

  graf   (0.0, 360.0, 0.0, 90.0, -1.0, 1.0, -1.0, 0.5);
  setrgb (0.7, 0.7, 0.7);
  grid   (1, 1);

  color  ("fore");
  height (50);
  title  ();

  color  ("red");
  curve  (xray, y1ray, n);
  color  ("green");
  curve  (xray, y2ray, n);
  disfin ();
  return 0;
}
Пример #7
0
int calcMoveBase(CharData *ch) {
    int base = 0;

    base += graf(age(ch).year, 40, 39, 34, 30, 26, 24, 23);

    /* Class/Level calculations */
    if (GET_CLASS(ch) == CLASS_RANGER)
        base += GET_LEVEL(ch);
    else if (GET_CLASS(ch) == CLASS_ASSASSIN || GET_CLASS(ch) == CLASS_THIEF)
        base += GET_LEVEL(ch)*2/3;
    else
        base += GET_LEVEL(ch)/3;
        
    return base;
}
Пример #8
0
/* >>>>>>>>>> EXA_7  <<<<<<<<<< */
void exa_7 (void)
{ int n = 100, i, nx, ny;
  double fpi = 3.1415926/180., step, x;
  char   cbuf[20];

  step = 360. / (n - 1);
  for (i = 0; i < n; i++)
  { xray[i] = (float) (i * step);
    x=xray[i] * fpi;
    y1ray[i] = (float) sin (x);
    y2ray[i] = (float) cos (x);
  }

  disini ();
  hwfont ();
  pagera ();

  axspos (450, 1800);
  axslen (2200, 1200);

  name   ("X-axis", "x");
  name   ("Y-axis", "y");
  labdig (-1, "x");
  ticks  (10, "xy");

  titlin ("Demonstration of Curve", 1);
  titlin ("Legend", 3);

  graf   (0.f, 360.f, 0.f, 90.f, -1.f, 1.f, -1.f, 0.5f);
  title  ();
  xaxgit ();

  chncrv ("both");
  curve  (xray, y1ray, n);
  curve  (xray, y2ray, n);

  legini (cbuf, 2, 7);
  nx = nxposn (190.f);
  ny = nyposn (0.75f);
  legpos (nx, ny);
  leglin (cbuf, "sin (x)", 1);
  leglin (cbuf, "cos (x)", 2);
  legtit ("Legend");
  legend (cbuf, 3);
  disfin ();
}
Пример #9
0
/* >>>>>>>>>> EXA_5  <<<<<<<<<< */
void exa_5 (void)
{ int nya = 2700, i, nx, ny;
  static float
        x[] = { 0.0f,  1.0f,  3.0f,  4.5f,  6.0f,  8.0f,  9.0f, 11.0f, 12.0f,
               12.5f, 13.0f, 15.0f, 16.0f, 17.0f, 19.0f, 20.0f},
        y[] = { 2.0f,  4.0f,  4.5f,  3.0f,  1.0f,  7.0f,  2.0f,  3.0f,  5.0f,
                2.0f,  2.5f,  2.0f,  4.0f,  6.0f,  5.5f,  4.0f};
  static char 
       *cpol[6] = {"SPLINE", "STEM", "BARS", "STAIRS", "STEP", "LINEAR"},
       *ctit    = "Interpolation Methods";

  setpag ("da4p");
  disini ();
  hwfont ();
  pagera ();
  incmrk (1);
  hsymbl (25);
  titlin (ctit, 1);
  axslen (1500, 350);
  setgrf ("line", "line", "line", "line");

  for (i = 0; i < 6; i++)
  { axspos (350, nya - i * 350);
    polcrv (cpol[i]);
    marker (0);

    graf   (0.f, 20.f, 0.f, 5.f, 0.f, 10.f, 0.f, 5.f);
    nx = nxposn (1.f);
    ny = nyposn (8.f);
    color  ("yellow");
    messag (cpol[i], nx, ny);
    curve (x, y, 16);
    color ("fore");

    if (i == 5)
    { height (50);
      title  ();
    }
    endgrf ();
  }

  disfin ();
}
Пример #10
0
/* >>>>>>>>>> EXA_4  <<<<<<<<<< */
void exa_4 (void)
{ int nya, i;
  static char    ctit[]  = "Logarithmic Scaling", cstr[60],
                *clab[3] = {"LOG", "FLOAT", "ELOG"};

  setpag ("da4p");
  disini ();
  pagera ();
  hwfont ();

  axslen (1400, 500);
  name   ("X-axis", "x");
  name   ("Y-axis", "y");
  axsscl ("log", "xy");

  titlin (ctit, 2);

  for (i = 1; i <= 3; i++)
  { nya = 2650 - (i - 1) * 800;
    labdig (-1, "xy");
    if (i == 2)
    { labdig (1, "y");
      name   (" ", "x");
    }

    axspos (500, nya);
    color  ("yellow");
    strcpy (cstr, "Labels: ");
    strcat (cstr, clab[i-1]);
    messag (cstr,600,nya-400);
    color  ("fore");
    labels (clab[i-1],"xy");
    graf   (0.f, 3.f, 0.f, 1.f, -1.f, 2.f, -1.f, 1.f);

    if (i == 3)
    { height (50);
      title  ();
    }

    endgrf ();
  }
  disfin ();
}
Пример #11
0
int main()
{
    Persona lista[C];
    char cont='N';
    int i;

    for(i=0; i<C; i++)
    {
        lista[i].estado=0;
        lista[i].edad=0;
    }

    do
    {
        switch(menu())
        {
        case '1':
            system("cls");
            alta(lista);
            break;
        case '2':
            system("cls");
            baja(lista);
            break;
        case '3':
            system("cls");
            ordAlfa(lista);
            break;
        case '4':
            system("cls");
            graf(lista);
            break;
        case '5':
            cont=salir();
            break;
        default:
            notOp();
        }
    }while(cont=='N');

    return 0;
}
Пример #12
0
/* >>>>>>>>>> EXA_1  <<<<<<<<<< */
void exa_1 (void)
{ int n = 100, i;
  double fpi = 3.1415926 / 180., step, x;

  step = 360. / (n-1);

  for (i = 0; i < n; i++)
  { xray[i] = (float) (i * step);
    x = xray[i] * fpi;
    y1ray[i] = (float) sin (x);
    y2ray[i] = (float) cos (x);
  }

  disini ();
  pagera ();
  hwfont ();
  axspos (450, 1800);
  axslen (2200, 1200);

  name   ("X-axis", "x");
  name   ("Y-axis", "y");

  labdig (-1, "x");
  ticks  (10, "xy");

  titlin ("Demonstration of CURVE", 1);
  titlin ("SIN(X), COS(X)", 3);

  graf   (0.f, 360.f, 0.f, 90.f, -1.f, 1.f, -1.f, 0.5f);
  title  ();

  color  ("red");
  curve  (xray, y1ray, n);
  color  ("green");
  curve  (xray, y2ray, n);

  color  ("fore");
  dash   ();
  xaxgit ();
  disfin ();
}
Пример #13
0
/* Hitpoint gain pr. game hour */
int hit_gain(struct char_data * ch)
{
  int gain;

  if (IS_NPC(ch)) {
    /* Neat and fast */
    gain = GET_LEVEL(ch);
  } else {

    gain = graf(age(ch)->year, 8, 12, 20, 32, 16, 10, 4);

    /* Class/Level calculations */

    /* Skill/Spell calculations */

    /* Position calculations    */

    switch (GET_POS(ch)) {
    case POS_SLEEPING:
      gain += (gain / 2);	/* Divide by 2 */
      break;
    case POS_RESTING:
      gain += (gain / 4);	/* Divide by 4 */
      break;
    case POS_SITTING:
      gain += (gain / 8);	/* Divide by 8 */
      break;
    }

    if (IS_MAGIC_USER(ch) || IS_CLERIC(ch))
      gain /= 2;	/* Ouch. */

    if ((GET_COND(ch, FULL) == 0) || (GET_COND(ch, THIRST) == 0))
      gain /= 4;
  }

  if (AFF_FLAGGED(ch, AFF_POISON))
    gain /= 4;

  return (gain);
}
Пример #14
0
/* >>>>>>>>>> EX14_2 <<<<<<<<<< */
void ex14_2 (void)
{ int    n = 50, i, j;
  float zlev[12];
  double step, x, y;

  step = 1.6 / (n - 1);
  for (i = 0; i < n; i++)
  { x = 0.0 + i * step;
    xray[i] = (float) x;
    for (j = 0; j < n; j++)
    { y = 0.0 + j * step;
      yray[j] = (float) y;
      zmat[i][j] = (float) ((x * x - 1.) * (x * x - 1.) + 
                            (y * y - 1.) * (y * y - 1.));
    }
  }

  setpag ("da4p");
  disini ();
  pagera ();
  hwfont ();

  mixalf ();
  titlin ("Shaded Contour Plot", 1);
  titlin ("F(X,Y) = (X[2$ - 1)[2$ + (Y[2$ - 1)[2$", 3);
  name   ("X-axis", "x");
  name   ("Y-axis", "y");

  shdmod ("poly", "contur");
  axspos (450, 2670);
  graf   (0.0f, 1.6f, 0.0f, 0.2f, 0.0f, 1.6f, 0.0f, 0.2f);

  for (i = 1; i <= 12; i++)
    zlev[12-i] = (float) (0.1 + (i - 1) * 0.1);

  conshd (xray, n, yray, n, (float *) zmat, zlev, 12);

  height (50);
  title  ();
  disfin ();
}
Пример #15
0
/* >>>>>>>>>> EX10_3 <<<<<<<<<< */
void ex10_3 (void)
{ char cbuf[80];
  float x[5]  = {2., 4., 6., 8., 10.},
        y1[5] = {0., 0., 0., 0., 0.},
        y2[5] = {3.2, 1.5, 2.0, 1.0, 3.0};

  int ic1ray[5]  = {50, 150, 100, 200, 175},
      ic2ray[5]  = {50, 150, 100, 200, 175};

  setpag ("da4p");
  disini ();
  pagera ();
  hwfont ();

  titlin ("3-D Bar Graph / 3-D Pie Chart", 2);
  htitle (40);

  shdpat (16L);
  axslen (1500, 1000);
  axspos (300, 1400);

  barwth (0.5);
  bartyp ("3dvert");
  labels ("second", "bars");
  labpos ("outside", "bars");
  graf   (0., 12., 0., 2., 0., 5., 0., 1.);
  title  ();
  color  ("red");
  bars   (x, y1, y2, 5);
  endgrf ();

  shdpat (16L);
  labels ("data", "pie");
  chnpie ("none");
  pieclr (ic1ray, ic2ray, 5);
  pietyp ("3d");
  axspos (300, 2700);
  piegrf (cbuf, 0, y2, 5);       
  disfin ();
}
Пример #16
0
// manapoint gain pr. game hour
int mana_gain(CHAR_DATA * ch)
{
	int gain = 0, restore = int_app[GET_REAL_INT(ch)].mana_per_tic, percent = 100;
	int stopmem = FALSE;

	if (IS_NPC(ch))
	{
		gain = GET_LEVEL(ch);
	}
	else
	{
		if (!ch->desc || STATE(ch->desc) != CON_PLAYING)
			return (0);

		if (!IS_MANA_CASTER(ch))
			gain =
				graf(age(ch)->year, restore - 8, restore - 4, restore,
					 restore + 5, restore, restore - 4, restore - 8);
		else
			gain = mana_gain_cs[GET_REAL_INT(ch)];

		// Room specification
		if (LIKE_ROOM(ch))
			percent += 25;
		// Weather specification
		if (average_day_temp() < -20)
			percent -= 10;
		else if (average_day_temp() < -10)
			percent -= 5;
	}

	if (world[IN_ROOM(ch)]->fires)
		percent += MAX(50, 10 + world[IN_ROOM(ch)]->fires * 5);

	if (AFF_FLAGGED(ch, AFF_DEAFNESS))
		percent += 15;

	// Skill/Spell calculations


	// Position calculations
	if (ch->get_fighting())
		percent -= 90;
	else
		switch (GET_POS(ch))
		{
		case POS_SLEEPING:
			if (IS_MANA_CASTER(ch))
			{
				percent += 80;
			}
			else
			{
				stopmem = TRUE;
				percent = 0;
			}
			break;
		case POS_RESTING:
			percent += 45;
			break;
		case POS_SITTING:
			percent += 30;
			break;
		case POS_STANDING:
			break;
		default:
			stopmem = TRUE;
			percent = 0;
			break;
		}

	if (!IS_MANA_CASTER(ch) &&
			(AFF_FLAGGED(ch, AFF_HOLD) ||
			 AFF_FLAGGED(ch, AFF_BLIND) ||
			 AFF_FLAGGED(ch, AFF_SLEEP) ||
			 ((IN_ROOM(ch) != NOWHERE) && IS_DARK(IN_ROOM(ch)) && !can_use_feat(ch, DARK_READING_FEAT))))
	{
		stopmem = TRUE;
		percent = 0;
	}
	if (!IS_NPC(ch))
	{
		if (GET_COND(ch, FULL) == 0)
			percent -= 50;
		if (GET_COND(ch, THIRST) == 0)
			percent -= 25;
		if (GET_COND(ch, DRUNK) >= CHAR_DRUNKED)
			percent -= 10;
	}

	if (!IS_MANA_CASTER(ch))
		percent += GET_MANAREG(ch);
	if (AFF_FLAGGED(ch, AFF_POISON) && percent > 0)
		percent /= 4;
	percent = MAX(0, MIN(250, percent));
	gain = gain * percent / 100;
	return (stopmem ? 0 : gain);
}
Пример #17
0
int calcHitBase(CharData *ch) {
    int base = 0;

    if(IS_NPC(ch))
        base += 18;
    else {
        base += graf(age(ch).year, 37, 38, 43, 46, 40, 34, 32);
    }

    /* Level/Class bonuses */
    switch(GET_CLASS(ch)) {
        case CLASS_WARRIOR:
            base += GET_LEVEL(ch)*5/3;
            break;
        case CLASS_RANGER:
        case CLASS_SOLAMNIC_KNIGHT:
        case CLASS_DEATH_KNIGHT:
            base += GET_LEVEL(ch)*4/3;
            break;
        case CLASS_THIEF:
        case CLASS_ASSASSIN:
            base += GET_LEVEL(ch);
            break;
        case CLASS_SHOU_LIN:
        case CLASS_CLERIC:
        case CLASS_SHADOW_DANCER:
            base += GET_LEVEL(ch)*2/3;
            break;
        case CLASS_MAGIC_USER:
        case CLASS_NECROMANCER:
            base += GET_LEVEL(ch)/3;
            break;
        default:
            mudlog(NRM, LVL_IMMORT, TRUE, "ERROR calcManaBase: %s's class not recognized!", GET_NAME(ch));
            break;
    }

    if(affected_by_spell(ch, SKILL_ADRENALINE)) {
        struct affected_type *af;
        for (af = ch->affected; af; af = af->next) {
            if(af->type == SKILL_ADRENALINE)
                base += af->modifier;
        }
    }

    /* Position calculations    */
    switch (GET_POS(ch)) {
        case POS_MEDITATING:
            if(IS_CHI_WARRIOR(ch) && GET_ADVANCE_LEVEL(ch) >= SECOND_ADVANCE_SKILL)
                base += GET_LEVEL(ch)/10;
        case POS_SLEEPING:
            base += 20;    /* Divide by 2 */
            break;
        case POS_RESTING:
            base += 12;	/* Divide by 4 */
            break;
    }

    // Naturalist hunters get 1% bonus regen to pets per advance level.
    if (affected_by_spell(ch, SPELL_CALL_OF_THE_WILD) && ch->master && IS_NATURALIST(ch->master))
        base += GET_MAX_HIT(ch)*GET_ADVANCE_LEVEL(ch->master)/100;
    
    return base;
}
Пример #18
0
int main ( int argc, char *argv[] )

/******************************************************************************/
/*
  Purpose:

    CIRCLE_INOUT uses DISLIN to draw points in and out of a circle.

  Licensing:

    This code is distributed under the GNU LGPL license.

  Modified:

    01 May 2011

  Author:

    John Burkardt

  Reference:

    Helmut Michels,
    The Data Plotting Software DISLIN - version 10.4,
    Shaker Media GmbH, January 2010,
    ISBN13: 978-3-86858-517-9.
*/
{
  int i;
  int j;
  int m;
  int n_circle = 100;
  int n_in;
  int n_out;
  int pat;
  float pi = 3.14159265;
  float r;
  float s;
  float t;
  float *x;
  float *xy_in;
  float *xy_out;
  float *y;

  printf ( "\n" );
  printf ( "CIRCLE_INOUT:\n" );
  printf ( "  C version\n" );
  printf ( "  Use DISLIN routines to make a scatterplot.\n" );
/*
  Read the data.
*/
  r4mat_header_read ( "circle_in.txt", &m, &n_in );

  xy_in = r4mat_data_read ( "circle_in.txt", m, n_in );

  r4mat_header_read ( "circle_out.txt", &m, &n_out );

  xy_out = r4mat_data_read ( "circle_out.txt", m, n_out );
/*
  Specify the format of the output file.
*/
  metafl ( "png" );
/*
  Indicate that new data overwrites old data.
*/
  filmod ( "delete" );
/*
  Specify the name of the output graphics file.
*/
  setfil ( "circle_inout.png" );
/*
  Choose the page size and orientation.
  'USA' is 2160 plot units wide and 2790 plot units high.
  'P' requests PROFILE rather than LANDSCAPE orientation.
*/
  setpag ( "usap" );
/*
  For PNG output, use reverse the default black background to white.
*/
  scrmod ( "reverse" );
/*
  Open DISLIN.
*/
  disini ( );
/*
  Plot a border around the page.
*/
  pagera ( );
/*
  Use the COMPLEX font.
*/
  complx ( );
/*
  Set the axis origin 230 plot units to the right, and 2560 plot units DOWN.
*/
  axspos ( 230, 2560 );
/*
  Define the X and Y sizes of the axis system in plot units.
*/
  axslen ( 1700, 1700 );
/*
  Label the X and Y axes.
*/
  name ( "<--- X --->", "X" );
  name ( "<--- Y --->", "Y" );
/*
  Relate the physical coordinates to the axes.
*/
  graf ( 0.0, 1.0, 0.0, 0.1, 0.0, 1.0, 0.0, 0.1 );
/*
  Define axis system titles.
*/
  titlin ( "Random points inside/outside the unit circle", 1 );
/*
  Draw the title.
*/
  title ( );
/*
  Add a grid, with one grid line for every tick mark in the X and Y axes.
*/
  grid ( 1, 1 );
/*
  Select the shading pattern.
*/
  pat = 16;
  shdpat ( pat );
/*
  Set the color to blue.
*/
  color ( "blue" );
/*
  At every data point, draw a circle of radius 0.01.
*/
  for ( i = 0; i < n_in; i++ )
  {
    rlcirc ( xy_in[0+i*2], xy_in[1+i*2], 0.01 );
  }
/*
  Set the color to red.
*/
  color ( "red" );
/*
  At every data point, draw a circle of radius 0.01.
*/
  for ( i = 0; i < n_out; i++ )
  {
    rlcirc ( xy_out[0+i*2], xy_out[1+i*2], 0.01 );
  }
/*
  Draw a red circle.
*/
  x = ( float * ) malloc ( n_circle * sizeof ( float ) );
  y = ( float * ) malloc ( n_circle * sizeof ( float ) );

  for ( i = 0; i < n_circle; i++ )
  {
    t = pi * ( float ) ( i ) / ( float ) ( n_circle - 1 );
    x[i] = cos ( t );
    y[i] = sin ( t );
  }
  thkcrv ( 10 );
  curve ( x, y, n_circle );
/*
  End this plot.
*/
  endgrf ( );
/*
  Free memory.
*/
  free ( x );
  free ( xy_in );
  free ( xy_out );
  free ( y );
/*
  Close DISLIN.
*/
  disfin ( );
/*
  Terminate.
*/
  printf ( "\n" );
  printf ( "CIRCLE_INOUT:\n" );
  printf ( "  Normal end of execution.\n" );

  return 0;
}
Пример #19
0
int calcManaBase(CharData *ch) {
    int base = 0;

    /* Set base regeneration */
    if (IS_NPC(ch)) {
        base += GET_LEVEL(ch) * 2;
    }
    else {
        base += graf(age(ch).year, 34, 32, 24, 26, 30, 41, 42);

        /* Class bonuses */
        switch(GET_CLASS(ch)) {
            case CLASS_MAGIC_USER:
            case CLASS_NECROMANCER:
                base += GET_LEVEL(ch);
                break;
            case CLASS_CLERIC:
            case CLASS_SHADOW_DANCER:
                base += GET_LEVEL(ch)*2/3;
                break;
            case CLASS_SOLAMNIC_KNIGHT:
            case CLASS_DEATH_KNIGHT:
                base += GET_LEVEL(ch)/2;
                break;
            case CLASS_SHOU_LIN:
            case CLASS_RANGER:
                base += GET_LEVEL(ch)/3;
                break;
            case CLASS_WARRIOR:
            case CLASS_THIEF:
            case CLASS_ASSASSIN:
                break;
            default:
                mudlog(NRM, LVL_IMMORT, TRUE, "ERROR calcManaBase: %s's class not recognized!", GET_NAME(ch));
                break;
        }
        
        /* Race bonuses*/
        if(IS_DROW(ch))
            base += (GET_LEVEL(ch)/8);

        /* Position calculations    */
        switch (GET_POS(ch)) {
            case POS_MEDITATING:
                if(IS_CHI_WARRIOR(ch) && GET_ADVANCE_LEVEL(ch) >= SECOND_ADVANCE_SKILL)
                    base += GET_LEVEL(ch)/10;
            case POS_SLEEPING:
                base += 16;
                break;
            case POS_RESTING:
                base += 8;	/* Divide by 2 */
                break;
        }
    }

    /* Int/wis bonus */
    base += (GET_WIS(ch) + GET_INT(ch) - 30);
    
    if(!IS_NPC(ch) && IS_VAMPIRE(ch) && IS_SUNLIGHT(IN_ROOM(ch)) && !IS_AFFECTED(ch, AFF_SHADOW_SPHERE))
        base = 0;

    return base;
}
Пример #20
0
int main ( int argc, char *argv[] )

/******************************************************************************/
/*
  Purpose:

    MAIN demonstrates the use of bar graphs.

  Modified:
 
    09 April 2011

  Reference:

    Helmut Michels,
    The Data Plotting Software DISLIN - version 10.4,
    Shaker Media GmbH, January 2010,
    ISBN13: 978-3-86858-517-9.
*/
{
  static char cbuf[25];
  static char *ctit = "Bar Graphs (BARS)";
  int i;
  int nya = 2700;
  static float x[9]  = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 };
  static float y[9]  = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
  static float y1[9] = { 1.0, 1.5, 2.5, 1.3, 2.0, 1.2, 0.7, 1.4, 1.1 };
  static float y2[9] = { 2.0, 2.7, 3.5, 2.1, 3.2, 1.9, 2.0, 2.3, 1.8 };
  static float y3[9] = { 4.0, 3.5, 4.5, 3.7, 4.0, 2.9, 3.0, 3.2, 2.6 };

  printf ( "\n" );
  printf ( "DISLIN_EX05:\n" );
  printf ( "  C version:\n" );
  printf ( "  Demonstrate the display of data in bar graphs.\n" );
/*
  Specify the format of the output file.
*/
  metafl ( "png" );
/*
  Specify that if a file already exists of the given name,
  the new data should overwrite the old.
*/
  filmod ( "delete" );
/*
  Specify the name of the output graphics file.
*/
  setfil ( "dislin_ex05.png" );
/*
  Choose the page size and orientation.
*/
  setpag ( "usap" );
/*
  For PNG output, reverse the default black background to white.
*/
  scrmod ( "reverse" );
/*
  Open DISLIN.
*/
  disini ( );
/*
  Plot a border around the page.
*/
  pagera ( );
/*
  Use the COMPLEX font.
*/
  complx ( );
  ticks ( 1, "x" );
  intax ( );
  axslen ( 1600, 700 );
  titlin ( ctit, 3 );

  legini ( cbuf, 3, 8 );
  leglin ( cbuf, "FIRST", 1 );
  leglin ( cbuf, "SECOND", 2 );
  leglin ( cbuf, "THIRD", 3 );
  legtit ( " " );
  shdpat ( 5L );

  for ( i = 1; i <= 3; i++ )
  {
     if ( 1 < i )
     {
       labels ( "none", "x" );
     }
    axspos ( 300, nya-(i-1)*800 );

    graf ( 0.0, 10.0, 0.0, 1.0, 0.0, 5.0, 0.0, 1.0 );

    if ( i == 1 )
    {
      bargrp ( 3, 0.15 );
      color ( "red" );
      bars ( x, y, y1, 9 );
      color ( "green" );
      bars ( x, y, y2, 9 );
      color ( "blue" );
      bars ( x, y, y3, 9 );
      color ( "fore" );
      reset ( "bargrp" );
    }
    else if ( i == 2 )
    {
      height ( 30 );
      labels ( "delta", "bars" );
      labpos ( "center", "bars" );
      color ( "red" );
      bars ( x, y, y1, 9 );
      color ( "green" );
      bars ( x, y1, y2, 9 );
      color ( "blue" );
      bars ( x, y2, y3, 9 );
      color ( "fore" );
      reset ( "height" ); 
    }
    else if ( i == 3 )
    {
      labels ( "second", "bars" );
      labpos ( "outside", "bars" );
      color ( "red" );
      bars ( x, y, y1, 9 );
      color ( "fore" );
    }

    if ( i < 3 )
    {
      legend ( cbuf, 7 );
    }
    else
    {
      height ( 50 );
      title ( );
    }

    endgrf ( );
  }
/*
  Close DISLIN.
*/
  disfin ( );
/*
  Terminate.
*/
  printf ( "\n" );
  printf ( "DISLIN_EX05:\n" );
  printf ( "  Normal end of execution.\n" );

  return 0;
}
Пример #21
0
int main ( int argc, char *argv[] )

/******************************************************************************/
/*
  Purpose:

    ORBITAL uses DISLIN to display a contour plot of Z(X,Y) data.

  Licensing:

    This code is distributed under the GNU LGPL license. 

  Modified:

    20 May 2011

  Author:

    John Burkardt

  Reference:

    Helmut Michels,
    The Data Plotting Software DISLIN - version 10.4,
    Shaker Media GmbH, January 2010,
    ISBN13: 978-3-86858-517-9.
*/
{
  int i;
  int j;
  int k;
  int level;
  int level_num;
  float level_value;
  int m;
  int n;
  int nn;
  float *x;
  float xmax;
  float xmin;
  float *xyz;
  float *y;
  float ymax;
  float ymin;
  float *z;
  float zmax;
  float zmin;

  printf ( "\n" );
  printf ( "ORBITAL:\n" );
  printf ( "  C version:\n" );
  printf ( "  Use DISLIN to make a contour plot of Z(X,Y) data.\n" );
/*
  Read the data.
*/
  r4mat_header_read ( "orbital.txt", &m, &nn );

  xyz = r4mat_data_read ( "orbital.txt", m, nn );
/*
  Split the data.
  The contouring routine expects that data is along fixed X and Y coordinates,
  and so the X and Y data is to be given as vectors, not arrays.
*/
  n = 101;
  x = ( float * ) malloc ( n * sizeof ( float ) );
  y = ( float * ) malloc ( n * sizeof ( float ) );
  z = ( float * ) malloc ( n * n * sizeof ( float ) );

  k = 0;
  for ( i = 0; i < n; i++ )
  {
    x[i] = xyz[0+k*3];
    k = k + 1;
  }
  xmin = r4vec_min ( n, x );
  xmax = r4vec_max ( n, x );

  k = 0;
  for ( i = 0; i < n; i++ )
  {
    y[i] = xyz[1+k*3];
    k = k + n;
  }
  ymin = r4vec_min ( n, y );
  ymax = r4vec_max ( n, y );
/*
  Z is a table.
  The first dimension should contain values for constant Y.
*/
  k = 0;
  for ( i = 0; i < n; i++ )
  {
    for ( j = 0; j < n; j++ )
    {
      z[i+j*n] = xyz[2+k*3];
      k = k + 1;
    }
  }
  zmax = r4mat_max ( n, n, z );
  zmin = r4mat_min ( n, n, z );
/*
  Specify the format of the output file.
*/
  metafl ( "png" );
/*
  Indicate that new data overwrites old data.
*/
  filmod ( "delete" );
/*
  Specify the name of the output graphics file.
*/
  setfil ( "orbital.png" );
/*
  Choose the page size and orientation.
  'USA' is 2160 plot units wide and 2790 plot units high.
  'P' requests PORTRAIT orientation.
*/
  setpag ( "usap" );
/*
  For PNG output, reverse the default black background to white.
*/
  scrmod ( "reverse" );
/*
  Open DISLIN.
*/
  disini ( );
/*
  Plot a border around the page.
*/
  pagera ( );
/*
  Use the SIMPLX font.
*/
  simplx ( );
/*
  Set the axis origin in plot units to the right, and plot units DOWN.
*/
  axspos ( 230, 2500 );
/*
  Define the X and Y sizes of the axis system in plot units.
*/
  axslen ( 1700, 1700 );
/*
  Label the X and Y axes.
*/
  name ( "X axis", "X" );
  name ( "Y axis", "Y" );
/*
  Relate the physical coordinates to the axes, and specify tick marks.
*/
  graf ( xmin, xmax, xmin, 1.0, ymin, ymax, ymin, 1.0 );
/*
  BEGIN LEVEL 2 COMMANDS.
*/

/*
  Define the title.
*/
  titlin ( "Orbital contour plot", 1 );
  title ( );
/*
  Set color to "blue".
*/
  color ( "blue" );
/*
  Draw the contour plot.
*/
  level_num = 10;

  for ( level = 1; level <= level_num; level++ )
  {
    level_value = ( ( float ) ( level_num + 1 - level ) * zmin   
                  + ( float ) (                 level ) * zmax ) 
                  / ( float ) ( level_num + 1         );

    contur ( x, n, y, n, z, level_value );
  }
/*
  End this graph.
*/
  endgrf ( );
/*
  RETURN FROM LEVEL 2 TO LEVEL 1.
*/

/*
  Close DISLIN.
*/
  disfin ( );
/*
  Free memory.
*/
  free ( x );
  free ( xyz );
  free ( y );
  free ( z );
/*
  Terminate.
*/
  printf ( "\n" );
  printf ( "ORBITAL:\n" );
  printf ( "  Normal end of execution.\n" );

  return 0;
}
Пример #22
0
/* >>>>>>>>>> EX10_1 <<<<<<<<<< */
void ex10_1 (void)
{ int nya = 2700, i;
  static char   *ctit = "Bar Graphs (BARS)", cbuf[25];

  static float x[9]  = {1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f},
               y[9]  = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f},
               y1[9] = {1.f, 1.5f, 2.5f, 1.3f, 2.0f, 1.2f, 0.7f, 1.4f, 1.1f},
               y2[9] = {2.f, 2.7f, 3.5f, 2.1f, 3.2f, 1.9f, 2.0f, 2.3f, 1.8f},
               y3[9] = {4.f, 3.5f, 4.5f, 3.7f, 4.0f, 2.9f, 3.0f, 3.2f, 2.6f};

  setpag ("da4p");
  disini ();
  pagera ();
  hwfont ();
  ticks  (1, "x");
  intax  ();;
  axslen (1600, 700);
  titlin (ctit, 3);

  legini (cbuf, 3, 8);
  leglin (cbuf, "FIRST", 1);
  leglin (cbuf, "SECOND", 2);
  leglin (cbuf, "THIRD", 3);
  legtit (" ");
  shdpat (5L);
  for (i = 1; i <= 3; i++)
  { if (i >  1) labels ("none", "x");
    axspos (300, nya - (i - 1) * 800);
    graf   (0.f, 10.f, 0.f, 1.f, 0.f, 5.f, 0.f, 1.f);

    if (i == 1)
    { bargrp (3, 0.15f);
      color  ("red");
      bars   (x, y, y1, 9);
      color  ("green");
      bars   (x, y, y2, 9);
      color  ("blue");
      bars   (x, y, y3, 9);
      color  ("fore");
      reset  ("bargrp");
    }
    else if (i == 2)
    { height (30);
      labels ("delta", "bars");
      labpos ("center", "bars");
      color  ("red");
      bars   (x, y, y1, 9);
      color  ("green");
      bars   (x, y1, y2, 9);
      color  ("blue");
      bars   (x, y2, y3, 9);
      color  ("fore");
      reset  ("height"); 
    }
    else if (i == 3)
    { labels ("second", "bars");
      labpos ("outside", "bars");
      color  ("red");
      bars   (x, y, y1, 9);
      color  ("fore");
    }

    if (i != 3) legend (cbuf, 7);

    if (i == 3)
    { height (50);
      title  ();
    }

    endgrf ();
  }
  disfin ();
}
Пример #23
0
// Hitpoint gain pr. game hour
int hit_gain(CHAR_DATA * ch)
{
	int gain = 0, restore = MAX(10, GET_REAL_CON(ch) * 3 / 2), percent = 100;

	if (IS_NPC(ch))
		gain = GET_LEVEL(ch) + GET_REAL_CON(ch);
	else
	{
		if (!ch->desc || STATE(ch->desc) != CON_PLAYING)
			return (0);

		if (!AFF_FLAGGED(ch, AFF_NOOB_REGEN))
		{
			gain = graf(age(ch)->year, restore - 3, restore, restore, restore - 2,
				restore - 3, restore - 5, restore - 7);
		}
		else
		{
			const double base_hp = std::max(1, PlayerSystem::con_total_hp(ch));
			const double rest_time = 80 + 10 * GET_LEVEL(ch);
			gain = base_hp / rest_time * 60;
		}

		// Room specification    //
		if (LIKE_ROOM(ch))
			percent += 25;
		// Weather specification //
		if (average_day_temp() < -20)
			percent -= 15;
		else if (average_day_temp() < -10)
			percent -= 10;
	}

	if (world[IN_ROOM(ch)]->fires)
		percent += MAX(50, 10 + world[IN_ROOM(ch)]->fires * 5);

	// Skill/Spell calculations //

	// Position calculations    //
	switch (GET_POS(ch))
	{
	case POS_SLEEPING:
		percent += 25;
		break;
	case POS_RESTING:
		percent += 15;
		break;
	case POS_SITTING:
		percent += 10;
		break;
	}

	if (!IS_NPC(ch))
	{
		if (GET_COND(ch, FULL) == 0)
			percent -= 50;
		if (GET_COND(ch, THIRST) == 0)
			percent -= 25;
	}

	percent += GET_HITREG(ch);

	// TODO: перевоткнуть на apply_аффект
	if (AFF_FLAGGED(ch, AFF_POISON) && percent > 0)
		percent /= 4;

	percent = MAX(0, MIN(250, percent));
	gain = gain * percent / 100;
	if (!IS_NPC(ch))
	{
		if (GET_POS(ch) == POS_INCAP || GET_POS(ch) == POS_MORTALLYW)
			gain = 0;
	}
	return (gain);
}
Пример #24
0
// move gain pr. game hour //
int move_gain(CHAR_DATA * ch)
{
	int gain = 0, restore = GET_REAL_CON(ch) / 2, percent = 100;

	if (IS_NPC(ch))
		gain = GET_LEVEL(ch);
	else
	{
		if (!ch->desc || STATE(ch->desc) != CON_PLAYING)
			return (0);
		gain =
			graf(age(ch)->year, 15 + restore, 20 + restore, 25 + restore,
				 20 + restore, 16 + restore, 12 + restore, 8 + restore);
		// Room specification    //
		if (LIKE_ROOM(ch))
			percent += 25;
		// Weather specification //
		if (average_day_temp() < -20)
			percent -= 10;
		else if (average_day_temp() < -10)
			percent -= 5;
	}

	if (world[IN_ROOM(ch)]->fires)
		percent += MAX(50, 10 + world[IN_ROOM(ch)]->fires * 5);

	// Class/Level calculations //

	// Skill/Spell calculations //


	// Position calculations    //
	switch (GET_POS(ch))
	{
	case POS_SLEEPING:
		percent += 25;
		break;
	case POS_RESTING:
		percent += 15;
		break;
	case POS_SITTING:
		percent += 10;
		break;
	}

	if (!IS_NPC(ch))
	{
		if (GET_COND(ch, FULL) == 0)
			percent -= 50;
		if (GET_COND(ch, THIRST) == 0)
			percent -= 25;
		if (!IS_IMMORTAL(ch) && affected_by_spell(ch, SPELL_HIDE))
			percent -= 20;
		if (!IS_IMMORTAL(ch) && affected_by_spell(ch, SPELL_CAMOUFLAGE))
			percent -= 30;
	}

	percent += GET_MOVEREG(ch);
	if (AFF_FLAGGED(ch, AFF_POISON) && percent > 0)
		percent /= 4;
	percent = MAX(0, MIN(250, percent));
	gain = gain * percent / 100;
	return (gain);
}