예제 #1
0
파일: Forces.cpp 프로젝트: sabeiro/Allink
Forces::Forces(int argc,char **argv,char *ConfF,char *Snapshot){
  Shout("constructor with intial configuration");
  InitConst();
  if(ReadConfDinamica(ConfF)){
    Dx = 1./(double)(NEdge-1);
  }
  Open(Snapshot,BF_PART);
  if(VAR_IF_TYPE(SysShape,SYS_LEAVES)) IfNano = 2;
  if(VAR_IF_TYPE(SysShape,SYS_PORE)) IfNano = 2;
  AllocMethod();
  PrepareParallel(argc,argv);
  PrepareSys();
 //Interp();
}
예제 #2
0
void VerticalAnimationObj::Init(VerticalAnimationStruct *aVerticalAnimationStruct){
	//read basic info
	theReader->VerticalAnimationObjInfo(Index, width, height, maxFrame, animationColumns, 
		maxAnimationOrientation, collidable, boundX, boundY, usingTexture, textureID, stationary, entranceEffectID);
	
	maxFrame = 100;
	stationary = false;

	//store pointer
	theVerticalAnimationStruct = aVerticalAnimationStruct;

	//first update the center X,Y values in terms of percentage of the 
	centerBottomX = aVerticalAnimationStruct->CenterBottomX;
	centerBottomY = aVerticalAnimationStruct->CenterBottomY;
	centerTopX =  aVerticalAnimationStruct->CenterTopX;
	centerTopY = aVerticalAnimationStruct->CenterTopY;

	//forbid pre-drawing into the visible canvas
	if(centerTopX <= 1 )
		preDrawn = false;

	x = (centerTopX + centerBottomX)/2.0;
	y = (centerTopY + centerBottomY)/2.0;

	startTimeInMS = aVerticalAnimationStruct->StartingTimeInMS;

	xVel = aVerticalAnimationStruct->XVel;
	yVel = aVerticalAnimationStruct->YVel;

	animationOrientation = aVerticalAnimationStruct->AnimationOrientation;
	stationary = stationary && preDrawn;

	////Normalize speed
	//xVel = xVel * TimeStepInSecond;
	//yVel = yVel * TimeStepInSecond;



	//call to set the scale and rotation
	InitConst();

	frameDelay = aVerticalAnimationStruct->FrameDelay;
	depth = aVerticalAnimationStruct->Depth;

	VerticalAnimationObj::ComputeCoordinate();
}
예제 #3
0
/* hmm.... shouldn`t main be moved to the interface routines */
int
main (int argc, char **argv)
{
  char *xwin = 0;
  char *Lang = NULL;
  gsrand (starttime = ((unsigned int) time ((long *) 0)));	/* init urand */
#ifdef ttblsz
  ttblsize = ttblsz;
  rehash = -1;
#endif /* ttblsz */
  if (argc > 2)
    {
      if (argv[1][0] == '-' && argv[1][1] == 'L')
	{
	  Lang = argv[2];
	  argv += 2;
	  argc -= 2;
	}
    }
  InitConst (Lang);
  ColorStr[0] = CP[118];
  ColorStr[1] = CP[119];

  while (argc > 1 && ((argv[1][0] == '-') || (argv[1][0] == '+')))
    {
      switch (argv[1][1])
	{
	case 'a':
	  ahead = ((argv[1][0] == '-') ? false : true);
	  break;
	case 'b':
	  argv++;
	  argc--;
	  if (argc > 1)
	    {
	      bookfile = argv[1];
#ifdef BINBOOK
	      binbookfile = NULL;
#endif
	    }
	  break;
#ifdef BINBOOK
	case 'B':
	  argv++;
	  argc--;
	  if (argc > 1)
	    binbookfile = argv[1];
	  break;
#endif
	case 'h':
	  hash = ((argv[1][0] == '-') ? false : true);
	  break;
	case 's':
	  argc--;
	  argv++;
	  if (argc > 1)
	    strcpy (savefile, argv[1]);
	  break;
	case 'l':
	  argc--;
	  argv++;
	  if (argc > 1)
	    strcpy (listfile, argv[1]);
	  break;
#ifndef GDBM
	case 'S':
	  argc--;
	  argv++;
	  if(argc > 1)booksize = atoi(argv[1]);
	  break;
#endif
	case 'P':
	  argc--;
	  argv++;
	  if(argc > 1)bookmaxply = atoi(argv[1]);
	  break;

#if ttblsz
	case 'r':
	  if (argc > 2)
	    rehash = atoi (argv[2]);
	  argc--;
	  argv++;
	  if (rehash > MAXrehash)
	    rehash = MAXrehash;
	  break;
	case 'T':
	  if (argc > 2)
	    ttblsize = atoi (argv[2]);
	  argc--;
	  argv++;
	  if (ttblsize > 0 && ttblsize < 24)
	    ttblsize = (1 << ttblsize);
	  else
	    ttblsize = ttblsz;
	  break;
#ifdef HASHFILE
	case 't':		/* create or test persistent transposition
				 * table */
	  hashfile = fopen (HASHFILE, RWA_ACC);
	  if (hashfile)
	    {
	      fseek (hashfile, 0L, SEEK_END);
	      filesz = (ftell (hashfile) / sizeof (struct fileentry)) - 1;
	    }
	  if (hashfile != NULL)
	    {
	      long i, j;
	      int nr[MAXDEPTH];
	      struct fileentry n;

	      printf (CP[49]);
	      for (i = 0; i < MAXDEPTH; i++)
		nr[i] = 0;
	      fseek (hashfile, 0L, SEEK_END);
	      i = ftell (hashfile) / sizeof (struct fileentry);
	      fseek (hashfile, 0L, SEEK_SET);
	      for (j = 0; j < i + 1; j++)
		{
		  fread (&n, sizeof (struct fileentry), 1, hashfile);
if(n.depth >MAXDEPTH) {printf("ERROR\n");exit(1);}
		  if (n.depth)
		    {
		      nr[n.depth]++;
		      nr[0]++;
		    }
		}
	      printf (CP[109],
		      nr[0], i);
	      for (j = 1; j < MAXDEPTH; j++)
		printf ("%d ", nr[j]);
	      printf ("\n");
	    }
	  return 0;
	case 'c':		/* create or test persistent transposition
				 * table */
	  if (argc > 2)
	    filesz = atoi (argv[2]);
	  if (filesz > 0 && filesz < 24)
	    filesz = (1 << filesz) - 1 + MAXrehash;
	  else
	    filesz = Deffilesz + MAXrehash;
	  if ((hashfile = fopen (HASHFILE, RWA_ACC)) == NULL)
	    hashfile = fopen (HASHFILE, WA_ACC);
	  if (hashfile != NULL)
	    {
	      long j;
	      struct fileentry n;

	      printf (CP[66]);
	      n.f = n.t = 0;
	      n.flags = 0;
	      n.depth = 0;
	      n.sh = n.sl = 0;
	      for (j = 0; j < filesz + 1; j++)
		fwrite (&n, sizeof (struct fileentry), 1, hashfile);
	      fclose (hashfile);
	    }
	  else
	    printf (CP[50], HASHFILE);
	  return (0);
#endif /* HASHFILE */
#endif /* ttblsz */
	case 'x':
	  xwin = &argv[1][2];
	  break;
	case 'v':
	  fprintf (stderr, CP[102], version, patchlevel);
	  exit (1);
	default:
	  fprintf (stderr, CP[113]);
	  exit (1);
	}
      argv++;
      argc--;
    }
  XC = 0;
  MaxResponseTime = 0;
#if defined CHESSTOOL || defined XBOARD
  signal (SIGTERM, TerminateChess);
  TCflag = true;
  TCmoves = 40;
  TCminutes = 5;
  TCseconds = 0;
  TCadd = 0;
  OperatorTime = 0;
#else
  TCflag = false;
  OperatorTime = 0;
#endif
  if (argc == 2)
    {
      char *p;

      MaxResponseTime = 100L * strtol (argv[1], &p, 10);
      if (*p == ':')
	MaxResponseTime = 60L * MaxResponseTime +
	  100L * strtol (++p, (char **) NULL, 10);
      TCflag = false;
      TCmoves = 0;
      TCminutes = 0;
      TCseconds = 0;
    }
  if (argc >= 3)
    {
      char *p;
      if (argc > 9)
	{
	  printf ("%s\n", CP[220]);
	  exit (1);
	}
      TCmoves = atoi (argv[1]);
      TCminutes = (short)strtol (argv[2], &p, 10);
      if (*p == ':')
	TCseconds = (short)strtol (p + 1, (char **) NULL, 10);
      else
	TCseconds = 0;
      TCflag = true;
      argc -= 3;
      argv += 3;
      while (argc > 1)
	{
	  XCmoves[XC] = atoi (argv[0]);
	  XCminutes[XC] = (short)strtol (argv[1], &p, 10);
	  if (*p == ':')
	    XCseconds[XC] = (short)strtol (p + 1, (char **) NULL, 10);
	  else
	    XCseconds[XC] = 0;
	  if (XCmoves[XC] && (XCminutes[XC] || XCseconds[XC]))
	    XC++;
	  else
	    {
	      printf (CP[220]);
	      exit (1);
	    }
	  argc -= 2;
	  argv += 2;
	}
      if (argc)
	{
	  printf ("%s\n", CP[220]);
	  exit (1);
	}
    }
  Initialize ();
  Initialize_dist ();
  Initialize_moves ();
  NewGame ();

  flag.easy = ahead;
  flag.hash = hash;
  if (xwin)
    xwndw = atoi (xwin);

  hashfile = NULL;
#if ttblsz
#ifdef HASHFILE
  hashfile = fopen (HASHFILE, RWA_ACC);
  if (hashfile)
    {
      fseek (hashfile, 0L, SEEK_END);
      filesz = ftell (hashfile) / sizeof (struct fileentry) - 1 - MAXrehash;
              hashmask = filesz>>1;
	      hashbase = hashmask+1;
    }
#if !defined CHESSTOOL && !defined XBOARD
  else
예제 #4
0
파일: Forces.cpp 프로젝트: sabeiro/Allink
Forces::Forces(int argc,char **argv,int NInEdge,char *ConfFileExt){
  Shout("Constructor/no starting configuration");
  InitConst();
  sprintf(ConfFile,"%s",ConfFileExt);
  char ConfF[40];
  sprintf(ConfF,ConfFile);
  if(ReadConfDinamica(ConfF)){
    Dx = 1./(double)(NEdge-1);
  }
  if(VAR_IF_TYPE(SysShape,SYS_2D)){
    nEdge[0] = NEdge;
    double Ratio = pEdge(1)*pInvEdge(0);
    nEdge[1] = (int)(nEdge[0]*Ratio + 0.0001);
    for(int i=0;;i++){
      if((int)(nEdge[1]/Ratio) == nEdge[0]) break;
      nEdge[0]++;
      nEdge[1] = (int)(nEdge[0]*Ratio + 0.0001);
      printf("using: nEdge[0] %d nEdge[1] %d\n",nEdge[0],nEdge[1]);
      if(i>=10){
	printf("Could not find the appropriate border partition %d %d\n",nEdge[0],nEdge[1]);
	exit(0);
      }
    }
    SetNLink(4);
    ReSetNPart(nEdge[0]*nEdge[1]);
    ReSetNChain(nEdge[1]);
    SetNPCh(nEdge[0]);
  }
  else if(VAR_IF_TYPE(SysShape,SYS_3D)){
    SetNLink(6);
    ReSetNChain(NEdge*NEdge);
    ReSetNPart(NEdge*NEdge*NEdge);
  }
  else if(VAR_IF_TYPE(SysShape,SYS_ROD)){
    SetNLink(1);
    ReSetNChain(1);
    ReSetNPart(NEdge);
  }
  else if(VAR_IF_TYPE(SysShape,SYS_STALK)){
    SetNLink(3);
    ReSetNPart(4*NEdge);
    ReSetNChain(4);
    //    Kf.El[0] *= Gen->NPart;
  }
  else if(VAR_IF_TYPE(SysShape,SYS_LEAVES)){
    SetNLink(3);
    ReSetNPart(NEdge);
    ReSetNChain(1);
    //    Kf.El[0] *= Gen->NPart;
  }
  else if(VAR_IF_TYPE(SysShape,SYS_PORE)){
    SetNLink(3);
    ReSetNPart(NEdge);
    ReSetNChain(1);
  }
  else if(VAR_IF_TYPE(SysShape,SYS_1D)){
    SetNLink(2);
    ReSetNPart(NEdge);
    ReSetNChain(1);
  }
  else if(VAR_IF_TYPE(SysShape,SYS_RIGID)){
    ReSetNPart(0);
    SetNLink(0);
  }
  else if(VAR_IF_TYPE(SysShape,SYS_TRIAL)){
    ReSetNPart(3*3*3);
    SetNLink(0);
    ReSetNChain(1);
  }
  else if(VAR_IF_TYPE(SysShape,SYS_MD)){
    SetNLink(0);
    ReSetNPart(NEdge);
    ReSetNChain(1);
  }
  else if(VAR_IF_TYPE(SysShape,SYS_MC)){
    SetNLink(0);
    ReSetNPart(NEdge);
    ReSetNChain(1);
  }
  else if(VAR_IF_TYPE(SysShape,SYS_ELECTRO)){
    SetNLink(4);
    ReSetNPart(NEdge+NSpline);
    ReSetNChain(1);
  }
  ReSetNPCh(pNPart()/pNChain());
  //SetNPCh(NEdge);
  SetDeltat(Deltat);
  SetStep(0);
  SetNType(2);
  CreateInitial();
  {
    MInt = new MatInt(3,3);
    MInt->SetCoeff(-24.33,0,0);
    MInt->SetCoeff(-7.22,0,1);
    MInt->SetCoeff(-24.33,0,2);
    MInt->SetCoeff(-0.1,1,1);
    MInt->SetCoeff(-7.22,1,2);
    MInt->SetCoeff(0.,2,2);
    MInt->SetCoeff(3.,0,0,0);
    MInt->SetCoeff(3.,0,0,1);
    MInt->SetCoeff(3.,0,0,2);
    MInt->SetCoeff(3.,0,1,1);
    MInt->SetCoeff(3.,0,1,2);
    MInt->SetCoeff(3.,0,2,2);
    MInt->SetCoeff(0.,1,1,1);
    MInt->SetCoeff(3.,1,1,2);
    MInt->SetCoeff(3.,1,2,2);
    MInt->SetCoeff(0.,2,2,2);
  }
  AllocMethod();
  PrepareSys();
  PrepareParallel(argc,argv);
  if(VAR_IF_TYPE(SysShape,SYS_LEAVES)) IfNano = 2;
  if(VAR_IF_TYPE(SysShape,SYS_PORE)) IfNano = 2;
  if(VAR_IF_TYPE(SysShape,SYS_ELECTRO)){
    Pm[NEdge].Typ = 2;
    Pm[NEdge+1].Typ = 2;
  }
  //Pc->PrintCells();
  //for(int p=0;p<pNPart();p++) CheckDomDec(p);
  //Interp();
}
예제 #5
0
//Improved Initialization with struct implementation
void AnimationObj::Init(AnimationObjStruct *AniStruct){	
	//----------------------------------------
	theReader->AnimationObjFrameInfo(Index, width, height, maxFrame, animationColumns, 
		maxAnimationOrientation, collidable, boundX, boundY, usingTexture, textureID, entranceEffectID, stationary, animationTypeID);
	
	//initialize entrance effect parameters
	if(entranceEffectID != NoEffect)
		useEntranceEffextSprite = true;

	switch(entranceEffectID){
	case Diagonal:
			useEntranceEffextSprite = theReader->GetUseDiagonalSprite(Index, maxEntranceEffextSpriteFrame, animationTypeID);
			if(!useEntranceEffextSprite)
				entranceEffectID = NoEffect;
		break;
	default:
		break;
	}
	
	InitConst();
	//timeStep = TimeStep; //time increwment, used in update()

	usingOrientation = true;
	stationary = false;
	//----------------------------------

	//position coordinate
	x =  AniStruct->X;
	y =  AniStruct->Y;

	x1 =  AniStruct->X1;
	y1 =  AniStruct->Y1;
	x2 =  AniStruct->X2;
	y2 =  AniStruct->Y2;

	//error checking at initialization 
	if(x == 0 && y==0){
		x = (x1 + x2)/2.0;
		y = (y1 + y2)/2.0;
	}
	
	//velocity
	xVel = AniStruct->XVel;
	yVel = AniStruct->YVel;
	SetRotate(AniStruct->Rotation);
	
	boundX = AniStruct->BoundX;
	boundY =  AniStruct->BoundY;

	startTimeInMS =  AniStruct->StartingTimeInMS;
	animationOrientation =  AniStruct->AnimationOrientation;
	frameDelay = AniStruct->FrameDelay;

	////Normalize speed
	//xVel = xVel * TimeStepInSecond;
	//yVel = yVel * TimeStepInSecond;

	if(AniStruct->Radius > 0){
		SetCollisionRadius(AniStruct->Radius);
	}

	//call to set the scale and rotation
	ComputeCoordinate();
}