コード例 #1
0
ファイル: McAngus.24.03.15.c プロジェクト: thiago6196/ED
void ex2(){
	int arrA[n], arrP[n], arrN[n], nSize = 0, pSize = 0;
	randNum(arrA, n, 100, -100);
	printArray(arrA, n);
	separate(arrA, arrP, arrN, n, &pSize, &nSize);
	selecCre(arrP, pSize);
	selecDec(arrN, nSize);
	printArray(arrP, pSize);
	printArray(arrN, nSize);
}
コード例 #2
0
ファイル: McAngus.24.03.15.c プロジェクト: thiago6196/ED
void ex1(){
	int arr[n];
	/* for(int i = 0; i < n; i++){
		printf("Digite o %d numero: ", i + 1); scanf("%d", &arr[i]);
	} */
	randNum(arr, n, 100, 0);
	printArray(arr, n);
	selecDec(arr, n);
	printArray(arr, n);
}
コード例 #3
0
ファイル: benchmark_tbb.cpp プロジェクト: asmodehn/fcmm
void threadFunction(int threadNo, int numOperationsPerThread, double insertOperationsPercent,
                    std::function<void(const Key& key)> find, std::function<void(const Key& key)> insert) {

    std::default_random_engine generator(threadNo);
    std::uniform_int_distribution<std::uint16_t> randNum(0, KEY_FIELD_MAX_VALUE);
    std::uniform_real_distribution<double> randDouble(0.0f, 100.0f);

    for (int i = 0; i < numOperationsPerThread; i++) {
        std::uint16_t a = randNum(generator);
        std::uint16_t b = randNum(generator);
        std::uint16_t c = randNum(generator);
        Key key(a, b, c);
        if (randDouble(generator) < insertOperationsPercent) {
            insert(key);
        } else {
            find(key);
        }
    }

}
コード例 #4
0
ObjectNode* genForest(int numTrees, float minR, float maxR, const mat4& initTrans, const mat4& initSkew) {
	ObjectNode* forest = new ObjectNode(nullptr, initTrans, initSkew);

	mat4 rotMat = rY(0.3 * numTrees + 2.0 * M_PI / numTrees);
	mat4 tempPosit = MatMath::ID;
	for (int i = 0; i < numTrees; ++i, rotMat *= rotMat) {
		tempPosit = rotMat * translate(0.0, 0.0, -randNum(minR, maxR));
		forest->addChild( *genTree( 3, 2, 150, 0.5, 0.5, 1.6, tempPosit, tempPosit ) );
	}

	return forest;
}
コード例 #5
0
ファイル: part_2.cpp プロジェクト: flow-J/Exercise
int main(int argc, char *argv[])
{
    int N = atoi(argv[1]);
    float m1 = 0.0, m2 = 0.0;

    for (int i = 0; i < N; ++i)
    {
        Number x = randNum();
        m1 += ((float) x)/N;
        m2 += ((float) x*x)/N;
    }
    std::cout << " Avg.: " << m1 << std::endl;
    std::cout << "Std. dev.: " << sqrt(m2-m1*m1) << std::endl;
}
コード例 #6
0
ファイル: DavidsonHarel.cpp プロジェクト: mneumann/tulip
	//newVal is the energy value of a candidate layout. It is accepted if it is lower
	//than the previous energy of the layout or if m_fineTune is not tpFine and
	//the difference to the old energy divided by the temperature is smaller than a
	//random number between zero and one
	bool DavidsonHarel::testEnergyValue(double newVal)
	{
		bool accepted = true;
		if(newVal > m_energy) {
			accepted = false;

			double testval = exp((m_energy-newVal)/ m_temperature);
			double compareVal = randNum(); // number between 0 and 1

			if(compareVal < testval)
				accepted = true;

		}
		return accepted;
	}
コード例 #7
0
int main()
{
	// generate all the random numbers first
	// loop for 20 millions time -> 20,000,000
	int totalNum = 20000000;
	// allocate memory space for the inputs and results in heap
	float* nums = malloc(totalNum * sizeof(float));
	float* result = malloc(totalNum * sizeof(float));
	int i;
	// initiallize the random seed by current time to avoid duplicate
	srand(time(NULL));
	// generate random numbers
	for (i = 0; i < totalNum; ++i)
	{
	    nums[i] = randNum(0, 3);
	    // printf("input number is: %f\n", num[i]);
	}

	// set up variables to calculate time consumption
	struct timeval tpstart, tpend;
	float timeuse;
	// record the start point
	gettimeofday(&tpstart, NULL);

	// call the sqrtAll function to calculate all the inputs
	sqrtAll(totalNum, nums, result);

	// record the end point
	gettimeofday(&tpend, NULL);
	// calculate the time consumption in us
	timeuse = 1000000 * (tpend.tv_sec - tpstart.tv_sec) + tpend.tv_usec - tpstart.tv_usec; // notice, should include both s and us
	printf("Total time:%fms\n", timeuse / 1000);

	// print the inputs and outputs
	// for (i = 0; i < totalNum; ++i) {
	// 	printf("input: %f, output: %f\n", nums[i], result[i]);
	// }

	// print the total generations and max generation
	printf("total generations: %d\n", count);
	printf("single max generations: %d\n", maxGeneration);

	// now free the memory
	free(nums);
	free(result);

	return 0;
}
コード例 #8
0
ファイル: DavidsonHarel.cpp プロジェクト: mneumann/tulip
	//chooses random vertex and a new random position for it on a circle with radius m_diskRadius
	//around its previous position
	node DavidsonHarel::computeCandidateLayout(
	const GraphAttributes &AG,
	DPoint &newPos) const
	{
		int randomPos = randomNumber(0,m_nonIsolatedNodes.size()-1);
		node v = *(m_nonIsolatedNodes.get(randomPos));
		double oldx = AG.x(v);
		double oldy = AG.y(v);
		double randomAngle = randNum() * 2.0 * Math::pi;
		newPos.m_y = oldy+sin(randomAngle)*m_diskRadius;
		newPos.m_x = oldx+cos(randomAngle)*m_diskRadius;
#ifdef OGDF_DEBUG
		double dist = sqrt((newPos.m_x - oldx)*(newPos.m_x - oldx)+(newPos.m_y-oldy)*(newPos.m_y-oldy));
		OGDF_ASSERT(dist > 0.99 * m_diskRadius && dist < 1.01 * m_diskRadius);
#endif
		return v;
	}
コード例 #9
0
void GenExchangeTest::init(RsGroupMetaData& grpMetaData) const
{
    randString(SHORT_STR, grpMetaData.mGroupId);
    //randString(SHORT_STR, grpMetaData.mAuthorId);
    randString(SHORT_STR, grpMetaData.mGroupName);
    randString(SHORT_STR, grpMetaData.mServiceString);


    grpMetaData.mGroupFlags = randNum();
    grpMetaData.mLastPost = randNum();
    grpMetaData.mGroupStatus = randNum();
    grpMetaData.mMsgCount = randNum();
    grpMetaData.mPop = randNum();
    grpMetaData.mSignFlags = randNum();
    grpMetaData.mPublishTs = randNum();
    grpMetaData.mSubscribeFlags = GXS_SERV::GROUP_SUBSCRIBE_ADMIN;
}
squad createSquad(aiTeam _t)
{
    squad r;
    r.m_team = _t;
    r.m_regroupDist = randNum(1000.0f, 2000.0f);
    r.m_size = 0;
    r.m_strength = 0.0f;
    r.m_confidence = 0.0f;
    r.m_max_size = rand() % 20 + 40;
    r.m_squadGoal = GOAL_CONGREGATE;

    if(_t == TEAM_PLAYER) r.m_targetPos = vec3();
    else r.m_targetPos = tovec3( randVec2(2000.0f, 100000.0f) );
    r.m_pAveragePos = r.m_targetPos;

    r.m_averagePos = vec3();
    r.m_averageVel = vec3();

    return r;
}
コード例 #11
0
void InspectObject(FrontCounter shop, int type,int  age)
{
    shop.TypeInspect(type, age);

    cout << endl << endl;

    EndDisplay();
    int choice = objectchoose();
    if (choice == 1)
    {
        IntroDisplay();
        int newtype = objectchoose();
        int newage = randNum(1550);
        InspectObject(shop, newtype, newage);
    }
    else
    {
        cout << "Thank you for using our services" << endl;
    }
}
コード例 #12
0
ファイル: lottery.c プロジェクト: tcode/Lottery
int main(int argc, char* argv[])
{
int num, i;
int count, j;
puts("Welcome to this lottery program");
puts("|======================================|");
printf("How many times would you like to have this lottery run ?");
scanf("%d", &count);
j=0;
while(count > j)
{
for(i=0; i < 6; i++)
{
num = randNum();
printf("%d ", abs(num));
}
printf("\n");
j++;
}
printf("\n");
return 0;
}
コード例 #13
0
void multi(int valA, int valB, int& runningScore)
{
    runningScore = 0;
    int count = 0;
    int product, userAns;
    for(int i = 0; i < 6; i++)
    {
        randNum(valA, valB);
        product = valA * valB;
        cout << "What is " << valA << " * " << valB << " equal to: ";
        cin >> userAns;
        if(product == userAns)
        {
            compliment();
            count++;
            runningScore++;
        }
        else
        {
            encouragement();
        }
    }
    cout << "You got " << count << " problems correct.";
}
コード例 #14
0
ObjectNode* genLeafBunch(float rho, float radius, float prob, int numLeaves,
	const mat4& initTrans, const mat4& initSkew)
{
	ObjectNode* bunch = new ObjectNode(nullptr, initTrans, initSkew);

	mat4 rotMat = MatMath::ID;
	mat4 tempTrans = translate(0.0, radius, 0.0);
	mat4 tempRotate = rY(	randNum(0.0, 2.0 * M_PI) ) *
									rZ(randNum(0.0, rho)	);
	ObjectNode* temp = new ObjectNode(nullptr, tempRotate * tempTrans, tempRotate);
	temp->addChild(*genLeaf(prob));
	bunch->addChild(*temp);
	for (int i = 1; i < numLeaves; ++i) {
		rotMat = rY(	randNum(0.0, 2.0 * M_PI) ) *
								rX( randNum(0.0, M_PI/2.0)	);
		tempRotate = rY(	randNum(0.0, 2.0 * M_PI) ) *
									rX( randNum(0.0, rho)	);
		temp = new ObjectNode(nullptr, tempRotate * tempTrans * rotMat, tempRotate * rotMat);
		temp->addChild(*genLeaf(prob));
		bunch->addChild(*temp);
	}

	return bunch;
}
コード例 #15
0
ファイル: ShowLayer.cpp プロジェクト: zsn6493/EATFUZI
/*加载资源*/
void ShowLayer::loadConfig(int level)
{
	Size visibleSize = Director::getInstance()->getVisibleSize();
	m_Level = level;

	//初始化随机种子
	randNum();

	if (level == 3)
	{
		int rand = CCRANDOM_0_1() * 5;

		//加载地图资源
		m_Map = CCTMXTiledMap::create("LastMap2.tmx");

		m_MaxLength = 1600;
		m_MinLength = 0;

		//获取地图上player的坐标
		TMXObjectGroup* objGoup = m_Map->getObjectGroup("playerPoint");
		ValueMap playerPointMap = objGoup->getObject("Player");

		float playerX = playerPointMap.at("x").asFloat();
		float playerY = playerPointMap.at("y").asFloat();

		//创建playerManager
		m_PlayerManager = PlayerManager::createWithLevel(Vec2(playerX, playerY + 24), level);
		m_PlayerManager->setPosition(Vec2(0, 0));
		m_Map->addChild(m_PlayerManager, 3);

		//获取地图上怪物坐标
		TMXObjectGroup* mobjGoup = m_Map->getObjectGroup("monsterPoint");
		ValueVector monsterPoints = mobjGoup->getObjects();

		//ValueMap monsterPoint = mobjGoup->getObject("monster1");

		//float monsterX = monsterPoint.at("x").asFloat();
		//float monsterY = monsterPoint.at("y").asFloat();

		PhyscisWorld::createWorld(m_Map, level);

		//创建monsterManager
		m_MonsterManager = MonsterManager::createWithLevel(monsterPoints, level);    //change
		m_MonsterManager->setAnchorPoint(Vec2(0, 0));
		m_MonsterManager->setPosition(Vec2(0, 0));
		m_Map->addChild(m_MonsterManager, 2);

		TMXObjectGroup* bobjGoup = m_Map->getObjectGroup("Boss");
		ValueMap bossPoint = bobjGoup->getObject("boss");

		float bossPointX = bossPoint.at("x").asFloat();
		float bossPointY = bossPoint.at("y").asFloat();

		m_BossManager = BossManager::createWithLevel(Vec2(bossPointX, bossPointY), level);
		m_BossManager->setAnchorPoint(Vec2(0, 0));
		m_BossManager->setPosition(Vec2(0, 0));
		m_BossManager->setBOrigin(Vec2(bossPointX, bossPointY));
		m_Map->addChild(m_BossManager, 2);

		//m_boss->setOrigin(Vec2(bossPointX, bossPointY));
		//m_boss->setPosition(Vec2(bossPointX, bossPointY));
		//this->addChild(m_boss, 3);
		m_GodArmManager = GodArmManager::createWithLevel(1, m_PlayerManager, m_MonsterManager, m_BossManager);
		m_GodArmManager->setPosition(Vec2(0, 0));
		m_Map->addChild(m_GodArmManager, 4);

		m_GodArmManager->runPower();

		this->schedule(schedule_selector(ShowLayer::Monsterlogic), 0.1f);
		this->schedule(schedule_selector(ShowLayer::logic), 1 / 20.0f);
		this->schedule(schedule_selector(ShowLayer::Bosslogic), 1.0f);
		//认领地图
		this->addChild(m_Map, 0, 1);
	}
}
コード例 #16
0
int main (int argc, char*argv[]) {
    // set up the game so tests can be run
    srand(time(NULL));
    printf("\n *** Random test of card function for adventurerCard() *** \n\n");
    printf("As a pre-test we test that initialize game has set up the conditions\n");
    printf("necessary to make the call to _adventurerCard() successful\n");
    printf("This ensures that the test we run on _adventureCard() are actually\n");
    printf("testing adventure card not transferring through some other errors.\n");
    printf("Next The first part of function is supposed to shuffle discard and \n");
    printf("add to the deck.  This is only tested when the set initialization is correct.\n\n");

    struct gameState *tGame = malloc(sizeof(struct gameState));

    int i= 0;
    int numPlayers, player;
    int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse,
           sea_hag, tribute, smithy};

    // testing variables
    int discardPass = 0, discardFail = 0, handCountPass = 0, handCountFail = 0, deckCountPass = 0, deckCountFail = 0, adventCardRuns = 0,
     add2DeckCountPass = 0 ,add2DeckCountFail = 0;
    int loops = randNum(500, 10000);
    //int loops =3;
    printf("Random number of test run: %i \n\n",loops);

    for(;i<loops;i++){

        numPlayers = randNum(2, 4);// randomly call between 2 and 6 players
                                // I had to temp change the upper bound to 4 as higher causes a random segfault.
        player =  randNum(0, numPlayers);// randomly apply the player using numPlayers as the max to the player num dose not go to high.
        tGame->whoseTurn = player;

   // Test of game setup pre call to adventureCard initilization zero out of discard pile , hand count and deck count by preloading with a random value
        tGame->discardCount[player] = randNum(1, 500);// preload
        tGame->handCount[player] = randNum(1, 500);
        tGame->deckCount[player] = randNum(1, 500);
             /*
            printf("  Discard pile count pre call of initializeGame %i\n", tGame->discardCount[player]);
            printf("  Hand count pre call of initializeGame %i\n", tGame->handCount[player]);
            printf("  Deck Count pre call initializeGame %i\n\n", tGame->deckCount[player]);
             */
        int mySeed = randNum(1, 20);

    //initialize the game and check numbers
        initializeGame( numPlayers, k , mySeed, tGame);
    // if the deck is empty it needs to shuffle discard and add to deck
            /*
            printf("The second set is after game initialization.\n");
            printf("  discard count post call of initializeGame %i\n", tGame->discardCount[player]);
            printf("  Hand count post call of initializeGame %i\n", tGame->handCount[player]);
            printf("  Deck Count post call initializeGame %i\n", tGame->deckCount[player]);
            */
        if (tGame->deckCount[player] == 10) {deckCountPass +=1;}
        if (tGame->discardCount[player] == 0) {discardPass +=1;}
        if (tGame->discardCount[player] != 0) {discardFail +=1;}
        if (tGame->handCount[player] == 0) {handCountPass +=1;}
        if (tGame->handCount[player] != 0) {handCountFail +=1;}
    // deck count should get set to 10
        if (tGame->deckCount[player] != 10) {deckCountFail +=1;}

    // only runs if set up for adventure card is correct.
    // Tests drawcard function call inside of adveturer card function
//printf("  _____________________________________\n");
        if (tGame->discardCount[player] == 0 && tGame->handCount[player] == 0 && tGame->deckCount[player] == 10) {
            _adventurerCard(tGame);
            tGame->discardCount[player] = 10;
            tGame->deckCount[player] = 0;
            // call adventure card
             _adventurerCard(tGame);

            if (tGame->deckCount[player] == 10 && tGame->discardCount[player] == 0) {add2DeckCountPass += 1;}
            else add2DeckCountFail +=1;

          adventCardRuns++;
        }
    }
        // print test results
        printf("Test to see if the hand deck and discard pile is initialized correctly.  \n");
        printf("discard pile # pass: %i  & fail: %i \n",discardPass,discardFail);
        printf("hand pile # pass: %i  & fail: %i \n",handCountPass ,handCountFail);
        printf("deck pile # pass: %i  & fail: %i \n\n",deckCountPass,deckCountFail);
        printf("Successful adventurer card setup runs -ie initialized properly: %i out of %i\n\n",adventCardRuns, loops);

        printf("This next test is only run when all the conditions are correct to run the test.\n");
        printf("Out of %i runs _adventureCard() successfully transfered: %i times and failed: %i times\n\n",adventCardRuns,add2DeckCountPass, add2DeckCountFail);

    free(tGame);
     return 0;
}
コード例 #17
0
ファイル: McAngus.23.03.15.c プロジェクト: thiago6196/ED
int main(){
	int arr[10];
	randNum(arr, 10, 100, 8);
	selection(arr, 10);
	printArray(arr, 10);
}
コード例 #18
0
ファイル: tiler.cpp プロジェクト: Lyle-Tafoya/CollageMaker
  // Tile images in a width x height rectangle.
  // xOrigin and yOrigin represent the location of this rectangle relative to the canvas
  // minDraw represents the minimum number of pixels to scale an image down to
  // tileType determines whether it tiles horizontally or vertically first
  void Tiler::tileImages(size_t width, size_t height, size_t xOrigin, size_t yOrigin, size_t minDraw, bool tileType)
  {
    size_t x = xOrigin, y = yOrigin;
    std::vector<std::unique_ptr<DrawOperation>> drawBatch;
    size_t imageNum;

    // Tile Horizontally
    if(tileType == 0)
    {
      while(1)
      {
        imageNum = randNum(0, imageFilePaths.size()-1);
        Magick::Image image(popImagePath(imageNum));
        image.resize(Magick::Geometry("x" + std::to_string(height)));
        const size_t imageWidth = image.columns();
        // If the last image wont fit, tile images in the empty space
        if(((x-xOrigin) + imageWidth) > width)
        {
          tileImages(width-(x-xOrigin), height, x, y, minDraw, 1);
          break;
        }

        // Put this draw operation in the queue
        drawBatch.emplace_back(std::make_unique<DrawOperation>(std::move(image), x, y));

        x  += imageWidth;
        // If we run out of room to draw, center what we have then stop
        if(((x-xOrigin) + minDraw) > width)
        {
          for(auto &&drawOperation : drawBatch)
          {
            drawOperation->x += (width-(x-xOrigin))/2;
          }
          break;
        }
      }
    }
    // Tile Vertically
    else
    {
      while(1)
      {
        imageNum = randNum(0, imageFilePaths.size()-1);
        Magick::Image image(popImagePath(imageNum));
        image.resize(Magick::Geometry(std::to_string(width)));
        const size_t imageHeight = image.rows();
        // If the last image wont fit, tile images in the empty space
        if((y-yOrigin+imageHeight) > height)
        {
          tileImages(width, height-(y-yOrigin), x, y, minDraw, 0);
          break;
        }

        // Put this draw operation in the queue
        drawBatch.emplace_back(std::make_unique<DrawOperation>(std::move(image), x, y));

        y += imageHeight;
        // If we run out of room to draw, center what we have then stop
        if((y-yOrigin + minDraw) > height)
        {
          for(auto &&drawOperation : drawBatch)
          {
            drawOperation->y += (height-(y-yOrigin))/2;
          }
          break;
        }
      }
    }
    drawQueue.insert(drawQueue.end(), std::make_move_iterator(drawBatch.begin()), std::make_move_iterator(drawBatch.end()));
  }
コード例 #19
0
ファイル: astar.c プロジェクト: XuHaoJun/astar-c
int main() {
  Point path[] = {{0, 0}, {10, 10}, {5, 5}, {15, 15}, {19, 19}};
  int32_t pathSize = sizeof(path)/sizeof(Point);
  int32_t mapWidth = 20;
  int32_t mapHeight = 20;
  Map map = newMap(mapWidth, mapHeight);
  Guard guard = newGuard("wiwi", (Point) {0, 0});
  guard.joinMap(&guard, &map);

  int i, j = 0;
  int32_t rectWallCount = randNum(3, 5);
  printf("rectWallCount: %d\n", rectWallCount);
  RectWall *rectWalls = malloc(sizeof(RectWall) * rectWallCount);
  for (i = 0; i < rectWallCount; i++) { // each rectWalls
    rectWalls[i].area[0].x = randNum(i, mapWidth - 1);
    rectWalls[i].area[0].y = randNum(i+1, mapHeight - 1);
    rectWalls[i].area[1].x = rectWalls[i].area[0].x + 1;
    rectWalls[i].area[1].y = rectWalls[i].area[0].y;
    rectWalls[i].area[2].x = rectWalls[i].area[0].x + 1;
    rectWalls[i].area[2].y = rectWalls[i].area[0].y + 1;
    rectWalls[i].area[3].x = rectWalls[i].area[0].x;
    rectWalls[i].area[3].y = rectWalls[i].area[0].y + 1;
  }

  i = 0;
  while ((rectWallsInMap(rectWalls, rectWallCount, &map) == false ||
        overlapRectWalls(rectWalls, rectWallCount) ||
        overlapRectWallsAndPath(rectWalls, rectWallCount, &path[0], pathSize)) &&
      i < rectWallCount) {
    // TODO Should find wrong specific rectWall and rand it.
    rectWalls[i].area[0].x = randNum(i+randNum(0,i), mapWidth - 1);
    rectWalls[i].area[0].y = randNum(i, mapHeight - 1);
    rectWalls[i].area[1].x = rectWalls[i].area[0].x + 1;
    rectWalls[i].area[1].y = rectWalls[i].area[0].y;
    rectWalls[i].area[2].x = rectWalls[i].area[0].x + 1;
    rectWalls[i].area[2].y = rectWalls[i].area[0].y + 1;
    rectWalls[i].area[3].x = rectWalls[i].area[0].x;
    rectWalls[i].area[3].y = rectWalls[i].area[0].y + 1;
    i++;
    if (i == rectWallCount) {
      i = 0;
    }
  }

  for (i = 0; i < rectWallCount; i++) { // each rectWalls
    for (j = 0; j < 4; j++) { // each area
      if (map.gridth(&map, rectWalls[i].area[j]) != NULL) {
        printf("rect wall: %d, %d\n",
            map.gridth(&map, rectWalls[i].area[j])->position.x,
            map.gridth(&map, rectWalls[i].area[j])->position.y);
        map.gridth(&map, rectWalls[i].area[j])->isBeWalkable = false;
      }
    }
  }
  free(rectWalls);

  printf("%s start moving\n",guard.name);
  map.gridth(&map, path[2])->isBeWalkable = false;
  guard.move(&guard, path[1]);
  map.gridth(&map, path[2])->isBeWalkable = true;
  guard.move(&guard, path[2]);
  map.gridth(&map, path[1])->isBeWalkable = false;
  guard.move(&guard, path[3]);
  map.gridth(&map, path[1])->isBeWalkable = true;
  guard.move(&guard, path[4]);
  return 0;
}
tt getRandomEntry(std::vector<tt> * _ref)
{
    int ri = randNum(0, static_cast<int>(_ref->size()));
    return (*_ref)[ri];
}
コード例 #21
0
void MCIRDLSLSEngine::calculate() const {

	for(Size i=0;i<additionalStats_.size();++i) {
		additionalStats_[i].reset();
	}

	pathPricer_ = this->lsmPathPricer();
	Size NeedRnd=randNum();
	PseudoRandom::rsg_type gen  = PseudoRandom::make_sequence_generator(NeedRnd, seed_);
	const std::vector<Real>& rand = gen.nextSequence().value;

	//Real values=this->pathPricer_->values(rand,nCalibrationSamples_);
	Real values=this->pathPricer_->values(rand,maxSamples_);
	this->pathPricer_->calibrate(nCalibrationSamples_);

	values=this->pathPricer_->values(rand,maxSamples_);

	results_.additionalResults["ImpliedCall"] = values;

	const std::vector<Date> & fixings=this->arguments_.fixingDates;
	Size sizeOfCouponNum=fixings.size();

	Leg expectedCashflows;
	Leg pastLeg = arguments_.payoffLeg->leg();
	expectedCashflows=pastLeg;


	std::vector<Real> cashflows(sizeOfCouponNum);
	std::vector<Real> cashflowsDates(sizeOfCouponNum);
	std::vector<Real> earlyExProbability;

	std::vector<Real>& earlyExProbabilityM = pathPricer_->earlyExProbability(); // 그거 지난 일자는 빠진거.

	//
	//for(Size i=0;i<additionalStats_.size();++i) {
	//	expectedCashflows[sizeOfCouponNum-i-1]=boost::shared_ptr<CashFlow>(
	//				new SimpleCashFlow(additionalStats_[sizeOfCouponNum-i-1].mean(),fixings[sizeOfCouponNum-i-1]));
	//	cashflows[sizeOfCouponNum-i-1]=additionalStats_[sizeOfCouponNum-i-1].mean();
	//
	//	//std::cout << additionalStats_[i].mean() << std::endl;
	//}

	Date today = Settings::instance().evaluationDate();
	Size numberOfPastFixings=0;
	for(Size i=0;i<sizeOfCouponNum;++i){
		if(fixings[i]<today){
			numberOfPastFixings=numberOfPastFixings+1;
		}
	}

	for(Size i=0;i<numberOfPastFixings;++i) {
		expectedCashflows[i]=boost::shared_ptr<CashFlow>(
					new SimpleCashFlow((arguments_.payoffLeg->payoff())[i]->amount(),fixings[i]));
		cashflows[i]=(arguments_.payoffLeg->payoff())[i]->amount(),fixings[i];
		earlyExProbability.push_back(0.0);
	}

	for(Size i=0;i<additionalStats_.size();++i) {

		expectedCashflows[sizeOfCouponNum-i-1]=boost::shared_ptr<CashFlow>(
					new SimpleCashFlow(additionalStats_[additionalStats_.size()-i-1].mean(),fixings[sizeOfCouponNum-i-1]));
		cashflows[sizeOfCouponNum-i-1]=additionalStats_[additionalStats_.size()-i-1].mean();
		earlyExProbability.push_back(earlyExProbabilityM[i]/maxSamples_);

	}

	results_.additionalResults["cashflows"] = cashflows;

	/*for(Size i=0;i<additionalStats_.size();++i) {
		std::cout << "cashflows : "<< cashflows[i] << std::endl;
	}*/
	for(Size i=0;i<sizeOfCouponNum;++i){
		cashflowsDates[i]=static_cast<Real>(fixings[i].serialNumber());
	}
	
	results_.additionalResults["cashflowsDates"] = cashflowsDates;
	results_.additionalResults["EarlyExProbability"] = earlyExProbability;
	
	//pricer에서 Notional을 더해서옴. 언제 상환될지 모르므로...

	//Real Notional=arguments_.Notional;
	//expectedCashflows.push_back(boost::shared_ptr<CashFlow>(new SimpleCashFlow(Notional,fixings.back())));

	results_.expectedCashflows=expectedCashflows;
	//expected Bond Price도 넣어야하나..?

	QL_REQUIRE(!discountTS_.empty(),
			   "discounting term structure handle is empty");

	results_.valuationDate = Settings::instance().evaluationDate();
	
	bool includeRefDateFlows =false;
	Real Notional=arguments_.Notional;
	results_.additionalResults["nonCallableValue"] = pathPricer_->expectedBondPrice()*10000/maxSamples_;
	results_.additionalResults["nonCallableUnitValue"] = pathPricer_->expectedBondPrice()*100000000/(maxSamples_*Notional);


	results_.value = CashFlows::npv(results_.expectedCashflows,
									**discountTS_,
									includeRefDateFlows,
									results_.valuationDate,
									results_.valuationDate);

	results_.settlementValue = CashFlows::npv(results_.expectedCashflows,
											  **discountTS_,
											  false,
											  arguments_.settlementDate,
											  arguments_.settlementDate);

	results_.additionalResults["UnitValue"] = results_.value*10000/Notional;

}