std::string pretty_print() const
      {
        std::ostringstream ss;

        ss << what();
        if (call_stack.size() > 0) {
          ss << "during evaluation at (" << fname(call_stack[0]) << " " << startpos(call_stack[0]) << ")" << std::endl;
          ss << std::endl << detail << std::endl;
          ss << "  " << fname(call_stack[0]) << " (" << startpos(call_stack[0]) << ") '" << pretty(call_stack[0]) << "'";
          for (size_t j = 1; j < call_stack.size(); ++j) {
            if (id(call_stack[j]) != chaiscript::AST_Node_Type::Block
                && id(call_stack[j]) != chaiscript::AST_Node_Type::File)
            {
              ss << std::endl;
              ss << "  from " << fname(call_stack[j]) << " (" << startpos(call_stack[j]) << ") '" << pretty(call_stack[j]) << "'";
            }
          }
        }
        ss << std::endl;
        return ss.str();
      }
GraphSize OperationDrawer::drawOrSizeDiagram(DiagramDrawer &drawer,
        OperationGraph &graph, const OperationDrawOptions &options, bool draw)
    {
    mCharHeight = static_cast<int>(drawer.getTextExtentHeight("W"));
    int pad = mCharHeight / 3;
    if(pad < 1)
        pad = 1;
    mPad = pad;

    GraphPoint startpos(mCharHeight, mCharHeight);
    GraphPoint pos = startpos;
    GraphSize size;
    GraphSize diagramSize;
    int maxy = 0;
    std::vector<int> classEndY;
    for(size_t i=0; i<graph.mOpClasses.size(); i++)
        {
        OperationClass &opClass = graph.mOpClasses[i];
        opClass.setPosition(pos);
        size = drawClass(drawer, opClass, options, draw);
        size_t condDepth = graph.getNestDepth(i);
        size.x += static_cast<int>(condDepth) * mPad;
        opClass.setSize(size);
        pos.x += size.x + mCharHeight;
        classEndY.push_back(startpos.y + size.y);
        if(size.y > maxy)
            maxy = size.y;
        }
    diagramSize.x = pos.x;

    pos = startpos;
    pos.y = startpos.y + maxy;  // space between class rect and operations
    std::set<const OperationDefinition*> drawnOperations;
    for(const auto &oper : graph.mOperations)
        {
        if(drawnOperations.find(oper) == drawnOperations.end())
            {
            size = drawOperation(drawer, pos, *oper, graph, options,
                    drawnOperations, draw);
            pos.y += size.y;
            }
        }
    if(draw)
        {
        drawLifeLines(drawer, graph.mOpClasses, classEndY, pos.y);
        }

    diagramSize.y = pos.y + mCharHeight;
    return diagramSize;
    }
Exemple #3
0
void DispInfo::rotate(const Vertex& point, const Matrix3d& rotmat)
{
	//mictimer rotatetimer("ms Side::rotate()", 1000.0);

	if (keyvals.size() == 0) return;

	Vertex startpos((*this)["startposition"]);
	startpos = startpos.rotate(point, rotmat);
	(*this)["startposition"] = std::string("[") + startpos.toStr() + "]";

	for (auto& vec : info)
		for (auto& disp : vec)
			disp.offset_normal = disp.offset_normal.rotate(rotmat);
}
bool OptionsWrapper::loadOptions(Enum::GameOption modmapFlag, const std::string& name)
{
	unLoadOptions(modmapFlag);
	GameOptions opt;
	switch (modmapFlag) {
		default:
			break;
		case Enum::MapOption:
			try {
				opt = usync().GetMapOptions(name);
			} catch (...) {
				LslError("Could not load map options");
				usync().FetchUnitsyncErrors(name);
				return false;
			}
			break;

		case Enum::ModOption:
			try {
				opt = usync().GetGameOptions(name);
			} catch (...) {
				LslError("Could not load game options");
				usync().FetchUnitsyncErrors(name);
				return false;
			}
			break;

		case Enum::EngineOption: {
			//TODO Fixed,random and so forth are intls
			mmOptionList startpos("Start Position Type", "startpostype", "How players will select where to be spawned in the map\n0: fixed map positions\n1: random map positions\n2: choose in game\n3: choose in the lobby before starting", "0");
			startpos.addItem("0", "Fixed", "Use the start positions defined in the map, the positions will be assigned incrementally from the team with lowest number to highest");
			startpos.addItem("1", "Random", "Use the start positions defined in the map, the positions will be assigned randomly");
			startpos.addItem("2", "Choose in-game", "Players will be able to pick their own starting point right before the game starts, optionally limited by a bounding box defined by the host");
			startpos.addItem("3", "Choose before game", "The host will place each player's start position in the map preview before the game is launched");
			opt.list_map["startpostype"] = startpos;
			break;
		}

		case Enum::PrivateOptions: {
			opt.string_map["restrictions"] = mmOptionString("List of restricted units", "restrictedunits", "Units in this list won't be available in game", "", 0); // tab separated list
			opt.string_map["mapname"] = mmOptionString("Map name", "mapname", "Map name", "", 0);
			break;
		}
	}
	m_opts[modmapFlag] = opt;
	return true;
}
Exemple #5
0
int main(int argc, char *argv[])
{
	char instructions;

	//Alloc memory for robot
	ROBOT *bot = malloc(sizeof(ROBOT));
	while(1) {
		startpos(bot);
		location(bot);
		printf("Please give the robot some instructions\n"
			"t for turn, m for move +5 in current facing\n");
		read_instructions(bot);
		printf("Bot after moving\n");
		location(bot);
		//Check they want to play again	
		if(move_again()==1) break;
	}

	free(bot);

	return 0;
}
Exemple #6
0
void LevelFinished::setPosition(){

	sf::Vector2f startpos(285,300);
	float distance = 96;
	float ydist = 96;
	bool overflow = false;
	int n = 0;

	for(int i = 0; i<mAliveVector.size(); i++){
		
		if(n > 6){
			overflow = true;
			n=0;
		}

		mAliveVector[i]->setPosition(startpos.x + distance * n, startpos.y + ydist*overflow);
		n++;
	}

	for(int i = 0; i<mDeadVector.size(); i++){

		mDeadVector[i]->setPosition(startpos.x + distance * i, startpos.y + ydist + ydist*overflow);
	}
}
Exemple #7
0
void
SectorParser::parse_old_format(const ReaderMapping& reader)
{
  m_sector.name = "main";
  reader.get("gravity", m_sector.gravity);

  std::string backgroundimage;
  if (reader.get("background", backgroundimage) && (backgroundimage != "")) {
    if (backgroundimage == "arctis.png") backgroundimage = "arctis.jpg";
    if (backgroundimage == "arctis2.jpg") backgroundimage = "arctis.jpg";
    if (backgroundimage == "ocean.png") backgroundimage = "ocean.jpg";
    backgroundimage = "images/background/" + backgroundimage;
    if (!PHYSFS_exists(backgroundimage.c_str())) {
      log_warning << "Background image \"" << backgroundimage << "\" not found. Ignoring." << std::endl;
      backgroundimage = "";
    }
  }

  float bgspeed = .5;
  reader.get("bkgd_speed", bgspeed);
  bgspeed /= 100;

  Color bkgd_top, bkgd_bottom;
  int r = 0, g = 0, b = 128;
  reader.get("bkgd_red_top", r);
  reader.get("bkgd_green_top",  g);
  reader.get("bkgd_blue_top",  b);
  bkgd_top.red = static_cast<float> (r) / 255.0f;
  bkgd_top.green = static_cast<float> (g) / 255.0f;
  bkgd_top.blue = static_cast<float> (b) / 255.0f;

  reader.get("bkgd_red_bottom",  r);
  reader.get("bkgd_green_bottom", g);
  reader.get("bkgd_blue_bottom", b);
  bkgd_bottom.red = static_cast<float> (r) / 255.0f;
  bkgd_bottom.green = static_cast<float> (g) / 255.0f;
  bkgd_bottom.blue = static_cast<float> (b) / 255.0f;

  if(backgroundimage != "") {
    auto background = std::make_shared<Background>();
    background->set_image(backgroundimage, bgspeed);
    m_sector.add_object(background);
  } else {
    auto gradient = std::make_shared<Gradient>();
    gradient->set_gradient(bkgd_top, bkgd_bottom);
    m_sector.add_object(gradient);
  }

  std::string particlesystem;
  reader.get("particle_system", particlesystem);
  if(particlesystem == "clouds")
    m_sector.add_object(std::make_shared<CloudParticleSystem>());
  else if(particlesystem == "snow")
    m_sector.add_object(std::make_shared<SnowParticleSystem>());
  else if(particlesystem == "rain")
    m_sector.add_object(std::make_shared<RainParticleSystem>());

  Vector startpos(100, 170);
  reader.get("start_pos_x", startpos.x);
  reader.get("start_pos_y", startpos.y);

  auto spawn = std::make_shared<SpawnPoint>();
  spawn->pos = startpos;
  spawn->name = "main";
  m_sector.spawnpoints.push_back(spawn);

  m_sector.music = "chipdisko.ogg";
  // skip reading music filename. It's all .ogg now, anyway
  /*
    reader.get("music", music);
  */
  m_sector.music = "music/" + m_sector.music;

  int width = 30, height = 15;
  reader.get("width", width);
  reader.get("height", height);

  std::vector<unsigned int> tiles;
  if(reader.get("interactive-tm", tiles)
     || reader.get("tilemap", tiles)) {
    auto tileset = TileManager::current()->get_tileset(m_sector.level->get_tileset());
    auto tilemap = std::make_shared<TileMap>(tileset);
    tilemap->set(width, height, tiles, LAYER_TILES, true);

    // replace tile id 112 (old invisible tile) with 1311 (new invisible tile)
    for(size_t x=0; x < tilemap->get_width(); ++x) {
      for(size_t y=0; y < tilemap->get_height(); ++y) {
        uint32_t id = tilemap->get_tile_id(x, y);
        if(id == 112)
          tilemap->change(x, y, 1311);
      }
    }

    if (height < 19) tilemap->resize(width, 19);
    m_sector.add_object(tilemap);
  }

  if(reader.get("background-tm", tiles)) {
    auto tileset = TileManager::current()->get_tileset(m_sector.level->get_tileset());
    auto tilemap = std::make_shared<TileMap>(tileset);
    tilemap->set(width, height, tiles, LAYER_BACKGROUNDTILES, false);
    if (height < 19) tilemap->resize(width, 19);
    m_sector.add_object(tilemap);
  }

  if(reader.get("foreground-tm", tiles)) {
    auto tileset = TileManager::current()->get_tileset(m_sector.level->get_tileset());
    auto tilemap = std::make_shared<TileMap>(tileset);
    tilemap->set(width, height, tiles, LAYER_FOREGROUNDTILES, false);

    // fill additional space in foreground with tiles of ID 2035 (lightmap/black)
    if (height < 19) tilemap->resize(width, 19, 2035);

    m_sector.add_object(tilemap);
  }

  // read reset-points (now spawn-points)
  ReaderMapping resetpoints;
  if(reader.get("reset-points", resetpoints)) {
    auto iter = resetpoints.get_iter();
    while(iter.next()) {
      if(iter.get_key() == "point") {
        Vector sp_pos;
        if(reader.get("x", sp_pos.x) && reader.get("y", sp_pos.y))
        {
          auto sp = std::make_shared<SpawnPoint>();
          sp->name = "main";
          sp->pos = sp_pos;
          m_sector.spawnpoints.push_back(sp);
        }
      } else {
        log_warning << "Unknown token '" << iter.get_key() << "' in reset-points." << std::endl;
      }
    }
  }

  // read objects
  ReaderCollection objects;
  if(reader.get("objects", objects)) {
    for(auto const& obj : objects.get_objects())
    {
      auto object = parse_object(obj.get_name(), obj.get_mapping());
      if(object) {
        m_sector.add_object(object);
      } else {
        log_warning << "Unknown object '" << obj.get_name() << "' in level." << std::endl;
      }
    }
  }

  // add a camera
  auto camera_ = std::make_shared<Camera>(&m_sector, "Camera");
  m_sector.add_object(camera_);

  m_sector.update_game_objects();

  if (m_sector.solid_tilemaps.empty()) {
    log_warning << "sector '" << m_sector.name << "' does not contain a solid tile layer." << std::endl;
  }

  fix_old_tiles();
  m_sector.update_game_objects();
}
Exemple #8
0
/** Object packs are our own custom format for simple, fixed, object tests. The file format is
 *  a simple binary dump of each objects information:
 *
 *    struct ObjectInformation {
 *        uint64 object_id;
 *        double x;
 *        double y;
 *        double z;
 *        double radius;
 *    };
 *
 *  This gives the minimal information for a static object and allows you to seek directly to any
 *  object in the file, making it easy to split the file across multiple object hosts.
 */
void ObjectFactory::generatePackObjects(const BoundingBox3f& region, const Duration& duration) {
    bool dump_pack = GetOptionValue<bool>(OBJECT_PACK_DUMP);
    if (dump_pack) return; // If we're dumping objects, don't load
                           // from a pack

    Time start(Time::null());

    uint32 nobjects = GetOptionValue<uint32>(OBJECT_PACK_NUM);
    if (nobjects == 0) return;
    String pack_filename = GetOptionValue<String>(OBJECT_PACK);
    assert(!pack_filename.empty());

    String pack_dir = GetOptionValue<String>(OBJECT_PACK_DIR);
    pack_filename = pack_dir + pack_filename;

    FILE* pack_file = fopen(pack_filename.c_str(), "rb");
    if (pack_file == NULL) {
        SILOG(objectfactory,error,"Couldn't open object pack file, not generating any objects.");
        assert(false);
        return;
    }

    // First offset ourselves into the file
    uint32 pack_offset = GetOptionValue<uint32>(OBJECT_PACK_OFFSET);

    uint32 obj_pack_size =
        8 + // objid
        8 + // radius
        8 + // x
        8 + // y
        8 + // z
        0;
    int seek_success = fseek( pack_file, obj_pack_size * pack_offset, SEEK_SET );
    if (seek_success != 0) {
        SILOG(objectfactory,error,"Couldn't seek to appropriate offset in object pack file.");
        fclose(pack_file);
        return;
    }

    for(uint32 i = 0; i < nobjects; i++) {
        ObjectInputs* inputs = new ObjectInputs;

        uint64 pack_objid = 0;
        double x = 0, y = 0, z = 0, rad = 0;
        fread( &pack_objid, sizeof(uint64), 1, pack_file );
        fread( &x, sizeof(double), 1, pack_file );
        fread( &y, sizeof(double), 1, pack_file );
        fread( &z, sizeof(double), 1, pack_file );
        fread( &rad, sizeof(double), 1, pack_file );

        UUID id = pack2UUID(pack_objid);

        Vector3f startpos((float)x, (float)y, (float)z);
        float bounds_radius = (float)rad;
        //SILOG(oh,error,"Preating "<<id.toString()<<" radius "<<bounds_radius);
        inputs->localID = mLocalIDSource++;
        inputs->motion = new StaticMotionPath(start, startpos);
        inputs->bounds = BoundingSphere3f( Vector3f(0, 0, 0), bounds_radius );
        inputs->registerQuery = false;
        inputs->queryAngle = SolidAngle::Max;
        inputs->connectAt = Duration::seconds(0.f);

        inputs->startTimer = Network::IOTimer::create(mContext->ioService);

        mObjectIDs.insert(id);
        mInputs[id] = inputs;
    }

    fclose(pack_file);
}
bool OptionsWrapper::loadOptions( GameOption modmapFlag, const wxString& name, const wxString& extra_filename )
{
	unLoadOptions(modmapFlag);
	GameOptions opt;
	switch (modmapFlag)
	{
	    default:
            break;
		case MapOption:
			try
			{
                opt = usync().GetMapOptions(name);
                ParseSectionMap( m_sections[modmapFlag], opt.section_map );
			}
			catch(...)
			{
				wxLogError(_T("Could not load map options"));
				return false;
			}
			break;

		case ModOption:
			try
			{
                opt = usync().GetModOptions(name);
                ParseSectionMap( m_sections[modmapFlag], opt.section_map );
			}
			catch(...)
			{
				wxLogError(_T("Could not load game options"));
				return false;
			}
			break;

        case EngineOption: {
            mmOptionList startpos( _("Start Position Type"),_T("startpostype"), _("How players will select where to be spawned in the map\n0: fixed map positions\n1: random map positions\n2: choose in game\n3: choose in the lobby before starting"), _T("0") );
            startpos.addItem( _T("0"), _("Fixed"), _T("Use the start positions defined in the map, the positions will be assigned incrementally from the team with lowest number to highest") );
            startpos.addItem( _T("1"), _("Random"), _T("Use the start positions defined in the map, the positions will be assigned randomly") );
            startpos.addItem( _T("2"), _("Choose in-game"), _T("Players will be able to pick their own starting point right before the game starts, optionally limited by a bounding box defined by the host") );
            startpos.addItem( _T("3"), _("Choose before game"), _T("The host will place each player's start position in the map preview before the game is launched") );
            opt.list_map[_T("startpostype")] = startpos;
            break;
        }

        case PrivateOptions: {
            opt.string_map[_T("restrictions")] = mmOptionString(_("List of restricted units"), _T("restrictedunits"), _T("Units in this list won't be available in game"), _T(""), 0 ); // tab separated list
            opt.string_map[_T("mapname")] = mmOptionString(_("Map name"), _T("mapname"), _T("Map name"), _T(""), 0 );
            break;
        }

        case ModCustomizations: {
            try {
                opt = usync().GetModCustomizations( name );
            }
            catch(...) {
				wxLogError(_T("Could not load mod customizations"));
				return false;
			}
			break;
        }

        case SkirmishOptions: {
            try {
                opt = usync().GetSkirmishOptions( name, extra_filename );
            }
            catch(...) {
				wxLogError(_T("Could not load skirmish options"));
				return false;
			}
			break;
        }
	}
	m_opts[modmapFlag] = opt;
	return true;
}
Exemple #10
0
void ITEMS::render_projectile(const NETOBJ_PROJECTILE *current, int itemid)
{

	// get positions
	float curvature = 0;
	float speed = 0;
	if(current->type == WEAPON_GRENADE)
	{
		curvature = gameclient.tuning.grenade_curvature;
		speed = gameclient.tuning.grenade_speed;
	}
	else if(current->type == WEAPON_SHOTGUN)
	{
		curvature = gameclient.tuning.shotgun_curvature;
		speed = gameclient.tuning.shotgun_speed;
	}
	else if(current->type == WEAPON_GUN)
	{
		curvature = gameclient.tuning.gun_curvature;
		speed = gameclient.tuning.gun_speed;
	}

	float ct = (client_prevtick()-current->start_tick)/(float)SERVER_TICK_SPEED + client_ticktime();
	if(ct < 0)
		return; // projectile havn't been shot yet
		
	vec2 startpos(current->x, current->y);
	vec2 startvel(current->vx/100.0f, current->vy/100.0f);
	vec2 pos = calc_pos(startpos, startvel, curvature, speed, ct);
	vec2 prevpos = calc_pos(startpos, startvel, curvature, speed, ct-0.001f);


	gfx_texture_set(data->images[IMAGE_GAME].id);
	gfx_quads_begin();
	
	select_sprite(data->weapons.id[clamp(current->type, 0, NUM_WEAPONS-1)].sprite_proj);
	vec2 vel = pos-prevpos;
	//vec2 pos = mix(vec2(prev->x, prev->y), vec2(current->x, current->y), client_intratick());
	

	// add particle for this projectile
	if(current->type == WEAPON_GRENADE)
	{
		gameclient.effects->smoketrail(pos, vel*-1);
		gameclient.flow->add(pos, vel*1000*client_frametime(), 10.0f);
		gfx_quads_setrotation(client_localtime()*pi*2*2 + itemid);
	}
	else
	{
		gameclient.effects->bullettrail(pos);
		gameclient.flow->add(pos, vel*1000*client_frametime(), 10.0f);

		if(length(vel) > 0.00001f)
			gfx_quads_setrotation(get_angle(vel));
		else
			gfx_quads_setrotation(0);

	}

	gfx_quads_draw(pos.x, pos.y, 32, 32);

	///--- Added by Tigra
	// Draw shadows of grenades
	bool local_player_in_game = 
		gameclient.clients[gameclient.snap.local_cid].team != -1;

	if(config.cl_antiping && current->type == WEAPON_GRENADE && local_player_in_game)
	{
		// Calculate average prediction offset, because client_predtick() gets varial values :(((
		// Must be there is a normal way to realize it, but I'm too lazy to find it. ^)
		if (gameclient.average_prediction_offset == -1)
		{
			int offset = client_predtick() - client_tick();
			gameclient.prediction_offset_summ += offset;
			gameclient.prediction_offset_count++;

			if (gameclient.prediction_offset_count >= 100)
			{
				gameclient.average_prediction_offset = 
					round((float)gameclient.prediction_offset_summ / gameclient.prediction_offset_count);
			}
		}		

		// Draw shadow only if grenade directed to local player
		int local_cid = gameclient.snap.local_cid;
		NETOBJ_CHARACTER& cur_char = gameclient.snap.characters[local_cid].cur;
		NETOBJ_CHARACTER& prev_char = gameclient.snap.characters[local_cid].prev;
		vec2 server_pos = mix(vec2(prev_char.x, prev_char.y), vec2(cur_char.x, cur_char.y), client_intratick());

		float d1 = distance(pos, server_pos);
		float d2 = distance(prevpos, server_pos);
		if (d1 < 0) d1 *= -1;
		if (d2 < 0) d2 *= -1;
		bool grenade_directed_to_local_player = d1 < d2;

		if (gameclient.average_prediction_offset != -1 && grenade_directed_to_local_player)
		{
			int predicted_tick = client_prevtick() + gameclient.average_prediction_offset;
			float predicted_ct = (predicted_tick - current->start_tick)/(float)SERVER_TICK_SPEED + client_ticktime();
		
			if (predicted_ct >= 0)
			{
				int shadow_type = WEAPON_GUN; // Pistol bullet sprite is used for marker of shadow. TODO: use something custom.
				select_sprite(data->weapons.id[clamp(shadow_type, 0, NUM_WEAPONS-1)].sprite_proj);

				vec2 predicted_pos = calc_pos(startpos, startvel, curvature, speed, predicted_ct);
				gfx_quads_draw(predicted_pos.x, predicted_pos.y, 32, 32);
			}
		}
	}
	///---

	gfx_quads_setrotation(0);
	gfx_quads_end();
}
Exemple #11
0
void stratifysites::run ()  {
    cout << "# Parameters\n";
    cout << "# thresh1=" << thresh1 << "\n";
    cout << "# thresh2=" <<thresh2 << "\n";
    cout << "# tlength="<<tlength << "h\n";
    cout << "# genpos="<<usegenpos << "\n";
    cout << "# strict="<<strict << "\n";
    cout << "# bin="<<bins << "\n";
    cout << "# predfile="<<predfile << "\n";
    cout << "# snpfile="<<snpfile << "\n";
    cout << "# genofile="<<genofile << "\n";
    cout <<  "## SNP id\n";
    cout <<  "## Chromosome \n";
    cout <<  "## Genetic position\n";
    cout <<  "## Physical position\n";
    cout <<  "## Average posterior probability of N on derived alleles \n";
    cout <<  "## Average posterior probability of N on ancestral alleles \n";
    cout <<  "## Number of derived alleles that are predicted to be Neandertal \n";
    cout <<  "## Total number of derived alleles \n";
    cout <<  "## Number of ancestral alleles that are predicted to be Neandertal \n";
    cout <<  "## Total number of ancestral alleles \n";



    if (givenprefix) {
        
        cout.setf(ios::fixed,ios::floatfield); 
        cout.precision(3);
    }

    for (int c = 0 ; c < nchr; c++) { 
        vector<snp> snps = geno->snps[geno->chrs[c]];
        vector<int> tmppred (nind, 0);
        vector<double> reg (nind,0);
        vector<double> reg2 (nind,0);
        vector<double> st1 (nind,0);
        vector<double> st2 (nind,0);
        vector<int> startpos (nind, 0);
        
        vector<double> maxlengths(snps.size(), 0 );
        vector<double> avglengths(snps.size(), 0 );
        vector<double> maxglengths(snps.size(), 0 );
        vector<double> avgglengths(snps.size(), 0 );
        vector<int> denomlengths(snps.size(), 0 );

        unordered_map <string, double> plmap ;
        unordered_map <string, double> glmap ;

        int incontig = 0 ;
        int contigsnps  = 0;
        string contigchr;
        double contigstart = 0;
        double  contigend = 0 ;
        double contigl = 0 ;
        double contigavganc =  0;

        double avgpredanc  = 0;

        for (int i = 0 ; i < snps.size() ; i++) { 
            for (int j = 0 ; j < nind; j++) { 
                double p = (*predanc).get(c,i,j);
                tmppred [j] = (p>thresh1)?1:0;
                avgpredanc += p;
            }
            string id = snps[i].id;
            string chr = snps[i].chr;

            if (nind>0)
                avgpredanc /= nind ;

            if (i==0) { 
                for (int j = 0  ; j < nind ; j++) { 
                    reg[j]  =reg2[j] = 0;
                    st1[j] = st2[j] = tmppred[j];
                    startpos[j] = 0;
                }
            } else { 
                int count1 = 0 ; 
                int count2 = 0;
                for (int j = 0 ; j < nind; j++) { 
                    int flag1 = 0;
                    int flag2 = 0;
                    int len1 = 0 ;
                    double len2 = 0;
                    double avgconf = 0 ;
                    double trueconf = 0 ;
                    int denom = 0 ;
                    int start = 0 ;
                    int end = 0 ;

                    if (st1[j] == 0 && tmppred[j] > 0) {
                        st1[j] = 1;
                        startpos[j] = i;
                    } else if (st1[j]==1 && tmppred[j]==0) {
                        len1 = reg[j];
                        for (int k = i - 1; k >= 0 && k >= startpos[j] ; k--) {
                            if ( maxlengths[k] < len1) {
                                maxlengths[k] = len1;
                            }
                            avglengths[k] += len1;
                            denomlengths[k]++;

                            start = snps[k].physpos;
                            avgconf +=  (*predanc).get (c,k,j);
                            if (giventrue)
                                trueconf +=  (*trueanc)(c,k,j);
                            denom ++;

                            string key =  chr + ":" + tostring(k) +":"+ tostring(j);
                            plmap[key] = len1;

                        }
                        avgconf = (denom>0)?avgconf/denom:0;
                        trueconf = (denom>0)?trueconf/denom:0;
                        reg[j] = 0;
                        st1[j] = 0;
                        flag1 = 1;
                        end = snps[i-1].physpos;
                        if (len1 > 0) count1++;
                    } else if (st1[j]==1 && tmppred[j] > 0 ) {
                        reg[j] +=  tmppred[j] *(snps[i].physpos - snps[i-1].physpos);
                        count2 ++;
                    } else {
                    }


                    if (st2[j] == 0 && tmppred[j] > 0)
                        st2[j] = 1;
                    else if (st2[j]==1 && tmppred[j]==0) {
                        len2 = reg2[j];
                        for (int k = i - 1; k >= 0 && k >= startpos[j] ; k--) {
                            if (maxglengths[k] < len2) {
                                maxglengths[k] = len2;
                            }
                            avgglengths[k] += len2;
                            string key =  chr + ":" + tostring(k) +":"+ tostring(j);
                            glmap[key] = len2;
                        }
                        reg2[j] = 0; 
                        st2[j] = 0 ;
                        flag2 = 1;

                    } else if (st2[j]==1 && tmppred[j] > 0 ) {
                        reg2[j] +=  tmppred[j] *(snps[i].genpos - snps[i-1].genpos);
                    } else {
                    }

                    if (flag1 && flag2) {
                        if (givenprefix) {

                            len2 *= 100;
                        }
                    }
                }
                if (count2 > 0  ) { 
                    if (incontig) { 
                        contigsnps ++;
                        contigavganc += avgpredanc;
                    } else { 
                        contigchr = geno->chrs[c];
                        contigstart = snps[i-1].physpos;
                        incontig = 1;
                    }
                    contigl += (snps[i].physpos - snps[i-1].physpos);
                } else if (count2 == 0 && count1 >  0) { 
                    contigend = snps[i].physpos;
                    if (contigsnps > 0) 
                        contigavganc /= contigsnps;
                    long cs = contigstart;
                    long ce = contigend;
                    contigl = 0 ;
                    incontig = 0 ;
                    contigsnps = 0 ;
                    contigavganc = 0 ;
                }
            }
        }

        for (int i = 0 ; i < snps.size() ; i++) { 
            string id = snps[i].id;
            string chr = snps[i].chr;
            double pos = snps[i].physpos;
            double gpos = snps[i].genpos;

            int n1 = 0;
            int n2 = 0;
            double n3 = 0;
            double n3a = 0 ;
            double n4 = 0;
            double g = 0 ;
            double f = 0 ;
            double f2 = 0 ; 
            int denom2 = 0 ;
            double f1 = 0 ;
            int denom1 = 0 ;
            int d = 0 ;
            int a = 0 ;
            int dn = 0 ; 
            int an = 0;


            double maxl = 0 ;
            double maxgl  = 0;
            for (int j = 0 ; j < nind ; j++) { 
                string key = chr + ":" + tostring(i) + ":" + tostring(j);
                double panc = (*predanc).get(c,i,j);
                if (io::debug >= 1)
                    cout << "panc ( " << c <<","<<i<<","<<j<<") = " << panc << endl;
                int predn = 0 ;
                int predh = 0 ;
                double predl = 0 ;
                if (usegenpos) {
                    if ( glmap.find(key) != glmap.end())
                        predl = glmap[key] * 100;
                    if (maxgl < predl)
                        maxgl = predl;
                } else { 
                    if ( plmap.find(key) != plmap.end())
                        predl = plmap[key];
                    if (maxl < predl) 
                        maxl  = predl;
                }

                if ( panc >= thresh1 && predl >= tlength)
                    predn = 1;
                if (panc <= thresh2)
                    predh = 1;

                int allele = (*geno)(c,i,j);
                f += allele;

                if (allele==1) {
                    d ++;
                    n1 += predn;
                    n2 += predh;
                    n3 += panc;
                    if (predn )
                        dn ++;
                }
                if (allele==0) { 
                    n3a += panc;
                    a ++;
                    if (predn )
                        an ++;
                }

                n4 += panc;

                if (predn) {
                    f1 += allele;
                    denom1++;
                }
                if (predh) { 
                    f2 += allele;
                    denom2 ++;
                }

            }
            f /= nind;
            g /= nind;
            f1 = denom1>0?(f1/denom1):0;
            f2 = denom2>0?(f2/denom2):0;

            if (d>0) { 
                n1/=d; n2/=d; n3/=d; 
            }
            if (a>0) { 
                n3a /= a;
            }
            if (nind > 0)
                n4 /= nind;
            int m1 = (n1>=1)?1:0;
            int m2 = ( (n1>0)&&(n2>0))?1:0;

            cout << id << "\t" << chr << "\t" << gpos*100 << "\t" << snps[i].getphyspos ();
            cout <<  "\t" << n3 << "\t" << n3a  ;
            cout << "\t" << dn  << "\t" << d << "\t" << an << "\t" << a;
            cout << endl;

            if (denomlengths[i]>0) { 
                avglengths[i] /= denomlengths[i];
                avgglengths[i] /= denomlengths[i];
            }

            if (givenprefix) {
                maxglengths[i] *= 100;
                avgglengths[i] *= 100;
                long ml = maxlengths[i];
                long al = avglengths[i];
            }

        }


    }
}