예제 #1
0
ConfigPlugin::ConfigPlugin(GluxiBot *parent) :
	BasePlugin(parent),  DiscoHandler(GLUXI_CONFIG_NODE,"", "Configuration")
{
	bot()->registerIqHandler("http://jabber.org/protocol/disco#info");
	bot()->registerIqHandler("http://jabber.org/protocol/commands");
	bot()->rootDiscoHandler()->registerDiscoHandler(this);
	addInfoItem(new FeatureItem("http://jabber.org/protocol/commands"));
	addInfoItem(new IdentityItem("automation", "command-node", "Configuration"));
	commands << "GET" << "SET";
}
예제 #2
0
UserPlugin::UserPlugin(GluxiBot *parent) :
	BasePlugin(parent)
{
	commands << "VERSION" << "PING" << "DISCO" << "VCARD" << "PHOTO" << "STATLIST" << "STAT" << "UPTIME"
		 << "TIME";

	bot()->registerIqHandler("jabber:iq:version");
	bot()->registerIqHandler("jabber:iq:last");
	bot()->registerIqHandler("jabber:iq:time");
	bot()->registerIqHandler("http://jabber.org/protocol/disco#items");
	bot()->registerIqHandler("http://jabber.org/protocol/stats");
}
예제 #3
0
파일: main.cpp 프로젝트: EvulMastah/nvsk
int main(int argc, char **argv)
{
	(void) argc;
	(void) argv;

	Logger::Echo("Main", "nvsk v0.1");
	signal(SIGINT, onSignal);

	if(!g_config->load() || !g_config->getNum())
		return -1;

	ScriptEnv::Init();

	for(uint32_t i = 0; i < g_config->getNum(); ++i)
	{
		BotPtr bot(new Bot(i));
		Bot::Instances.insert({i, bot});
		threads.push_back(std::thread(std::bind(&Bot::worker, bot)));
	}

	while(threads.size())
		std::this_thread::sleep_for(std::chrono::seconds(1));

	Bot::Instances.clear();
	ScriptEnv::Finish();

	return 0;
}
예제 #4
0
void
Controller::update_bullets()
{
  Bullet *bullet(0);
  Bot *bot(0);
  sf::Vector2f hitPoint;
  for (unsigned int i(0); i < m_model.get_bullets().size(); i++)
  {    
    // Get a direct pointer for convenience.
    bullet = (Bullet*) m_model.get_bullets()[i];
    
    if (m_model.collides(bullet, hitPoint)) // Collision with circles and world' boundaries.
    {
      m_view.add_explosion(hitPoint);
      m_model.erase_bullet(i);
    }
    else if (m_model.collides(bullet, &bot, hitPoint)) // Collision with bots.
    {
      m_view.add_explosion(hitPoint);
      m_model.inflict_damages(bot);
      if (!bot->is_alive())
      {
	bullet->get_bot_origin()->add_kill();
        m_view.add_bot_explosion(bot->get_position());
      }
      m_model.erase_bullet(i);
    }
    else
      bullet->move(); // Update position.
  }
}
예제 #5
0
void
Controller::update_bots()
{
  // Loop over all the bots.
  Bot *bot(0);
  sf::Vector2f hitPoint;
  for (int i(0); i < (int) m_model.get_bots().size(); i++) // See bot death below for the cast.
  {
    // Get a direct pointer for convenience.
    bot = (Bot*) m_model.get_bots()[i];    
    
    // Get and manage the request of each bot.
    BotConnector::Request const& request(bot->get_connector().get_request());
    unsigned int circlesCount(0), botsCount(0), bulletsCount(0); // Results for a scan.
    switch (request.type)
    {
      case BotConnector::SKIP: // The bot asked to skip its turn.
	bot->get_connector().answer_request(bot->get_health(), bot->get_bullets_left(), bot->get_num_kills());
	break;
      case BotConnector::MOVE: // The bot asked to move forward.
        bot->move();
        bot->get_connector().answer_request(bot->get_health(), bot->get_bullets_left(), bot->get_num_kills());
        break;
      case BotConnector::ROTATE: // The bot asked to be rotated.
        bot->rotate(request.rotationDegrees);
        bot->get_connector().answer_request(bot->get_health(), bot->get_bullets_left(), bot->get_num_kills());
        break;
      case BotConnector::FIRE: // The bot asked to fire a bullet.
        if (bot->get_bullets_left() > 0)
          m_model.fire_bullet(bot);
        bot->get_connector().answer_request(bot->get_health(), bot->get_bullets_left(), bot->get_num_kills());
        break;
      case BotConnector::SCAN: // The bot asked a scan.
        bot->set_scan(request.scanDistance, request.scanRadius);
        m_model.scan(bot, request.scanCircles, circlesCount, request.scanBots, botsCount, request.scanBullets, bulletsCount);
        bot->get_connector().answer_scan_request(bot->get_health(), bot->get_bullets_left(), bot->get_num_kills(), circlesCount, botsCount, bulletsCount);
        break;
      default: // The bot did not ask for anything.
        break;
    }

    // Manage collisions.
    Bot *botCollision(0);
    if (m_model.collides(bot, &botCollision, hitPoint))
    {
      m_view.add_explosion(hitPoint);
      m_model.inflict_damages(bot);
      if (!bot->is_alive())
      {
	if (botCollision != 0) // If the bot collides with another bot and not the world, add a kill to this other bot.
	  botCollision->add_kill();
        m_view.add_bot_explosion(bot->get_position());
        i--; // If the bot has been removed from the vector (dead), the next bot will be on the current index.
      }
    }
    
    // Load new bullets.
    bot->load_bullet();
  }
}
예제 #6
0
파일: main.cpp 프로젝트: AcYut/segway-lite
int main()
{
		
//	(void) signal(SIGINT,doquit);	
	Communication comm;
	testBot bot(&comm);
	Walk walk(&bot);
	
	// while(walk.velocity()*1.5<=90)
	// 	{
	// 		walk.accelerate();
	// 		walk.dribble();
	// 	}
	// while(1)
	// {
	double pi=acos(-1);
		walk.move(100.0,-pi/4);

	// 	cvNamedWindow("w");
	// 	char c= cvWaitKey(10);
	// 	if(c=='c' || c==27)
	// 			break;
	// }
	return 0;
	
	
};
예제 #7
0
void UserPlugin::sendTime(gloox::Stanza* s)
{
	time_t rawtime;
	struct tm *timeinfo;
	char buffer[80];

	time ( &rawtime );
	timeinfo = localtime ( &rawtime );

	strftime (buffer, 80, "%Z",timeinfo);
	QString tz = QString::fromLocal8Bit(buffer);

	QString display = QDateTime::currentDateTime().toString("ddd MMM dd HH:mm:ss %1 yyyy").arg(tz);
	QString utc = QDateTime::currentDateTime().toUTC().toString("yyyyMMddhh:mm:ss");

	gloox::Stanza *st = gloox::Stanza::createIqStanza(s->from(),
	    s->findAttribute("id"), gloox::StanzaIqResult, "jabber:iq:time");

	gloox::Tag* tag=st->findChild("query");
	assert(tag);
	tag->addChild(new gloox::Tag("utc", utc.toStdString()));
	tag->addChild(new gloox::Tag("tz", tz.toStdString()));
	tag->addChild(new gloox::Tag("display", display.toStdString()));
	qDebug() << QString::fromStdString(st->xml());
	bot()->client()->send(st);
}
예제 #8
0
int main()
{
	std::cout << "Chatterbot v9.0 Copyright (C) 2009 Gonzales Cenelia\n" << std::endl;

	try 
	{
		CBot bot("Chatterbot9");

		bot.signon();
		while(!bot.quit()) 
		{
			bot.get_input();
			bot.respond();
		}
	}
	catch(std::string str)
	{
		std::cerr << str << std::endl;
	}
	catch(...)
	{
		std::cerr << "The program has stop due to some unknown exception" << std::endl;
	}
		
	return 0;
}
예제 #9
0
int main(int argc, char** argv) {
  gflags::ParseCommandLineFlags(&argc, &argv, true);
  srand (time(NULL));

  if (FLAGS_race_id.empty()) {
    FLAGS_race_id = random_race_id();
  }
  std::cout << "Race id: " << FLAGS_race_id << std::endl;
  boost::filesystem::create_directories("bin/" + FLAGS_race_id);

  try {
    std::cout << "Host: " << FLAGS_host << ", port: " << FLAGS_port <<
      ", name: " << FLAGS_bot << ", key:" << FLAGS_key << std::endl;

    std::unique_ptr<bots::RawBot> bot(new bots::RawBot(GetBot(FLAGS_bot_algorithm)));
    utils::Connection connection(FLAGS_host, FLAGS_port);

    run(&connection, bot.get(), FLAGS_bot, FLAGS_key);
  } catch (const std::exception& e) {
    std::cerr << "EXCEPTION!!!" << std::endl;
    std::cerr << e.what() << std::endl;
    return 2;
  }

  return 0;
}
예제 #10
0
void MythD3D9Painter::DrawRect(const QRect &area, const QBrush &fillBrush,
                               const QPen &linePen, int alpha)
{
    int style = fillBrush.style();
    if (style == Qt::SolidPattern || style == Qt::NoBrush)
    {
        if (!m_render)
            return;

        if (style != Qt::NoBrush)
            m_render->DrawRect(area, fillBrush.color(), alpha);

        if (linePen.style() != Qt::NoPen)
        {
            int lineWidth = linePen.width();
            QRect top(QPoint(area.x(), area.y()),
                      QSize(area.width(), lineWidth));
            QRect bot(QPoint(area.x(), area.y() + area.height() - lineWidth),
                      QSize(area.width(), lineWidth));
            QRect left(QPoint(area.x(), area.y()),
                       QSize(lineWidth, area.height()));
            QRect right(QPoint(area.x() + area.width() - lineWidth, area.y()),
                        QSize(lineWidth, area.height()));
            m_render->DrawRect(top,   linePen.color(), alpha);
            m_render->DrawRect(bot,   linePen.color(), alpha);
            m_render->DrawRect(left,  linePen.color(), alpha);
            m_render->DrawRect(right, linePen.color(), alpha);
        }
        return;
    }

    MythPainter::DrawRect(area, fillBrush, linePen, alpha);
}
예제 #11
0
int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);

    SignalHandler signalHandler;
    Q_UNUSED(signalHandler)

    if (QCoreApplication::arguments().length() < 2)
        qFatal("Specify superuser user-id.");

    bool ok;
    auto headadminId = QCoreApplication::arguments()[1].toLongLong(&ok);

    if (!ok)
        qFatal("Specify superuser user-id.");

    app.setApplicationName("Telegram-Bot");
    app.setApplicationVersion(Bot::version());

    //qputenv("QT_LOGGING_RULES", "tg.*=false");
    qputenv("QT_LOGGING_RULES", "tg.*=false\nbot.*.debug=false");
    //qputenv("DEBUG", "true");

    Database database;

    Bot bot(&database, headadminId);
    bot.installModule(new Board);
    bot.installModule(new Help);
    bot.installModule(new Subscribe);
    bot.installModule(new ConfigModule);
    bot.installModule(new GroupModule);
    bot.init();

    return app.exec();
}
예제 #12
0
파일: ubot.c 프로젝트: troglobit/ubot
int main(int argc, char *argv[])
{
	int c;
	char server[256] = SERVER;
	struct option long_options[] = {
		{ "channel",  1, NULL, 'c' },
		{ "debug",    0, NULL, 'd' },
		{ "help",     0, NULL, 'h' },
		{ "nick",     1, NULL, 'n' },
		{ "password", 1, NULL, 'l' },
		{ "port",     1, NULL, 'p' },
		{ "ssl",      0, NULL, 's' },
		{ "version",  0, NULL, 'v' },
		{ NULL, 0, NULL, 0 }
	};

	signal(SIGINT,  sigint_cb);
	signal(SIGTERM, sigint_cb);
	while ((c = getopt_long(argc, argv, "c:dh?n:l:p:sv", long_options, NULL)) != EOF) {
		switch(c) {
		case 'c':
			channel = strdup(optarg);
			break;

		case 'd':
			debug = 1;
			break;

		case 'n':
			nick = strdup(optarg);
			break;

		case 'l':
			pass = strdup(optarg);
			break;

		case 'p':
			port = strdup(optarg);
			break;

		case 'v':
			return puts("v" VERSION) == EOF;

		case 's':
			if (ssl_init())
				error(1, 0, "Failed creating SSL context, missing library?");
			break;

		case 'h':
		case '?':
			return usage(0);
		}
	}

	if (optind < argc)
		strncpy(server, argv[optind++], sizeof(server));

	return bot(server, port);
}
예제 #13
0
QString UserPlugin::resolveTargetJid(gloox::Stanza* s, const QString& arg)
{
	QString jid=bot()->getJID(s, arg);
	if (jid.isEmpty())
		jid=arg;
	if (jid.isEmpty())
		jid=QString::fromStdString(s->from().full());
	return jid;
}
void coll_box::get_corners( vec2_f24p8& lt_corner, vec2_f24p8& rt_corner, 
	vec2_f24p8& rb_corner, vec2_f24p8& lb_corner )
{
	lt_corner.x = lb_corner.x = left();
	rt_corner.x = rb_corner.x = right();
	
	lt_corner.y = rt_corner.y = top();
	lb_corner.y = rb_corner.y = bot();
}
예제 #15
0
//--------------------------------------------------------------
void ofApp::draw(){
    
    {
        //This colors the background
        ofBackgroundGradient( ofColor(55), ofColor(0), OF_GRADIENT_CIRCULAR );
        
        //"Turns on alpha blending (which is on by default since OF version 0.8.0). It simply wraps opengl commands that enable blending, and turn on a common blend mode." (From openframeworks.cc)
        ofEnableAlphaBlending();
        
        // This feeds values measured in pixels, the frequency value will be pretty small
        float frequency = ofMap( ofGetMouseX(),  0, ofGetWidth(),  0.0001, 0.05 );
        
        // Draw ticks at each unit edge
        int numTicks = ceil(ofGetWidth() * frequency);
        float areaCovered = numTicks;
        if( numTicks <= 5 ) { numTicks *= 10; }
        
        //for loop
        for( int i = 0; i < numTicks; i++ )
        {
            float noisePos = ofMap( i, 0, numTicks, 0, areaCovered); //Maps the position of the noise
            float screenX = noisePos * (1.0/frequency); //Tracks the X location of the screen
            ofVec2f top( screenX, 0); //Computes the top of the screen
            ofVec2f bot( screenX, ofGetHeight()); //Computes the bottome of the screen
            
            // Brighter white lines at unit edges (0,1,2) and less bright at fractionals (0.1,0.2, etc), but only if we are zoomed in enough
            if( (abs(fmodf(noisePos, 1.0)) <= 0) && areaCovered < 18 )  { ofSetColor( ofColor::white, 90 ); } else { ofSetColor( ofColor::white, 30 );  }
            
            ofLine( top, bot); //Tells the line to go inbetween the top and bottom of the of the screen
            
            ofVec2f textPos = top + ofVec2f(4,20); // Text location
            fontSmall.drawString( ofToString(noisePos), textPos.x, textPos.y ); //String of text
        }
        
        // Compute a noise position for each pixels x position, taking a frequency value into account
        float noiseMagnitude = 300; //Size of the wave
        ofMesh mesh; //creates mesh
        mesh.setMode( OF_PRIMITIVE_LINE_STRIP); //Could not find out what this does
        int res = ofGetWidth();
        for( int i = 0; i < res; i++ ) //for loop
        {
            ofVec2f pos = ofVec2f( ofMap( i, 0, res, 0, ofGetWidth() ), ofGetHeight() * 0.5f ); //Handles the position of the wave
            
            float noisePos = (pos.x * frequency); //The position of the noise equals the x position times the frequency
            float noiseValue = ofSignedNoise( noisePos ); // ofSignedNoise gives us a value -1..1
            
            ofVec2f drawPos = pos + ofVec2f(0,noiseValue * noiseMagnitude); //The is the draw position
            
            mesh.addVertex( drawPos ); //adds the vertices
        }
        
        ofSetColor( ofColor::white );//sets color to white
        mesh.draw(); //draws the mesh
    }
    
}
예제 #16
0
static void
newuhs(bool incr)
{
	int newhs, h = u.uhunger;

	newhs = (h > 1000) ? SATIATED :
		(h > 150) ? NOT_HUNGRY :
		(h > 50) ? HUNGRY :
		(h > 0) ? WEAK : FAINTING;

	if (newhs == FAINTING) {
		if (u.uhs == FAINTED)
			newhs = FAINTED;
		if (u.uhs <= WEAK || rn2(20 - u.uhunger / 10) >= 19) {
			if (u.uhs != FAINTED && multi >= 0 /* %% */) {
				pline("You faint from lack of food.");
				nomul(-10 + (u.uhunger / 10));
				nomovemsg = "You regain consciousness.";
				afternmv = unfaint;
				newhs = FAINTED;
			}
		} else if (u.uhunger < -(int)(200 + 25 * u.ulevel)) {
			u.uhs = STARVED;
			flags.botl = 1;
			bot();
			pline("You die from starvation.");
			done("starved");
		}
	}

	if (newhs != u.uhs) {
		if (newhs >= WEAK && u.uhs < WEAK)
			losestr(1);	/* this may kill you -- see below */
		else if (newhs < WEAK && u.uhs >= WEAK && u.ustr < u.ustrmax)
			losestr(-1);
		switch (newhs) {
		case HUNGRY:
			pline((!incr) ? "You only feel hungry now." :
			      (u.uhunger < 145) ? "You feel hungry." :
			      "You are beginning to feel hungry.");
			break;
		case WEAK:
			pline((!incr) ? "You feel weak now." :
			      (u.uhunger < 45) ? "You feel weak." :
			      "You are beginning to feel weak.");
			break;
		}
		u.uhs = newhs;
		flags.botl = 1;
		if (u.uhp < 1) {
			pline("You die from hunger and exhaustion.");
			killer = "exhaustion";
			done("starved");
		}
	}
}
예제 #17
0
파일: game.cpp 프로젝트: clone2727/xoreos
bool Game::showMainMenu() {
	Graphics::Aurora::GUIQuad top("introscr_top" , 0.0f, 0.0f, kScreenWidth, kScreenHeight, 0.0f, 1.0f, 1.0f, 0.0f);
	Graphics::Aurora::GUIQuad bot("startupscrbot", 0.0f, 0.0f, kScreenWidth, kScreenHeight, 0.0f, 1.0f, 1.0f, 0.0f);

	top.setPosition(kTopScreenX   , kTopScreenY   , 0.0f);
	bot.setPosition(kBottomScreenX, kBottomScreenY, 0.0f);

	top.show();
	bot.show();


	Graphics::Aurora::TextureHandle buttonTexture = loadNCGR("main_pnl_off", "gui_main_pnl", 8, 2,
			"00", "01", "02", "03", "04", (const char *) 0, (const char *) 0, (const char *) 0,
			"10", "11", "12", "13", "14", "15", "16", "17");

	Graphics::Aurora::GUIQuad button(buttonTexture, 0.0f, 0.0f, 240.0f, 48.0f, 0.0f, 1.0f, 1.0f, 0.0f);

	button.setPosition(-120.0f, -120.0f, -1.0f);
	button.show();


	Graphics::Aurora::Text buttonText(_guiFont, TalkMan.getString(15860));

	float buttonX, buttonY, buttonZ;
	button.getPosition(buttonX, buttonY, buttonZ);

	const float buttonTextX = buttonX + ((button.getWidth()  - buttonText.getWidth())  / 2.0f);
	const float buttonTextY = buttonY + ((button.getHeight() - buttonText.getHeight()) / 2.0f);

	buttonText.setPosition(buttonTextX, buttonTextY, -2.0f);
	buttonText.show();


	Graphics::Aurora::Text helpText(_guiFont, TalkMan.getString(18707));

	const float helpTextX = kBottomScreenX + ((kScreenWidth - helpText.getWidth()) / 2.0f);
	const float helpTextY = kBottomScreenY;

	helpText.setPosition(helpTextX, helpTextY, -2.0f);
	helpText.show();


	GfxMan.unlockFrame();

	if (!waitClick())
		return false;

	GfxMan.lockFrame();
	helpText.hide();
	buttonText.hide();
	button.hide();
	top.hide();
	bot.hide();

	return true;
}
예제 #18
0
AbstractConfigurator* ConfigPlugin::getConfiguratorVerbose(gloox::Stanza* s)
{
	AbstractConfigurator* config=bot()->getConfigurator(s);
	if (!config)
	{
		reply(s,"Unable to find configurator");
		return 0;
	}
	return config;
}
int coll_box::contains( const vec2_f24p8& point )
{
	if ( point.x > left() && point.x < right() 
		&& point.y > top() && point.y < bot() )
	{
		return true;
	}
	
	return false;
}
예제 #20
0
bool Cylinder::computeNearestPoints(const Vector3D &test_point, Vector3D &top_point, Vector3D &bot_point) const
{
    Vector2D test_point2d(test_point[0], test_point[1]);

    Vector2D top2d, bot2d;
    bool top_status = top().computeNearestPoint(test_point2d, top2d);
    bool bot_status = bot().computeNearestPoint(test_point2d, bot2d);

    return top_status && bot_status;
}
예제 #21
0
파일: wintty.c 프로젝트: saihack/NetHack
static void
winch()
{
    int oldLI = LI, oldCO = CO, i;
    register struct WinDesc *cw;

    getwindowsz();
    if((oldLI != LI || oldCO != CO) && ttyDisplay) {
	ttyDisplay->rows = LI;
	ttyDisplay->cols = CO;

	cw = wins[BASE_WINDOW];
	cw->rows = ttyDisplay->rows;
	cw->cols = ttyDisplay->cols;

	if(flags.window_inited) {
	    cw = wins[WIN_MESSAGE];
	    cw->curx = cw->cury = 0;

	    tty_destroy_nhwindow(WIN_STATUS);
	    WIN_STATUS = tty_create_nhwindow(NHW_STATUS);

	    if(u.ux) {
#ifdef CLIPPING
		if(CO < COLNO || LI < ROWNO+3) {
		    setclipped();
		    tty_cliparound(u.ux, u.uy);
		} else {
		    clipping = FALSE;
		    clipx = clipy = 0;
		}
#endif
		i = ttyDisplay->toplin;
		ttyDisplay->toplin = 0;
		docrt();
		bot();
		ttyDisplay->toplin = i;
		flush_screen(1);
		if(i) {
		    addtopl(toplines);
		} else
		    for(i=WIN_INVEN; i < MAXWIN; i++)
			if(wins[i] && wins[i]->active) {
			    /* cop-out */
			    addtopl("Press Return to continue: ");
			    break;
			}
		(void) fflush(stdout);
		if(i < 2) flush_screen(1);
	    }
	}
    }
}
예제 #22
0
void UserPlugin::sendVersion(gloox:: Stanza* s)
{
	gloox::Stanza *st=gloox::Stanza::createIqStanza(s->from(),
			s->findAttribute("id"), gloox::StanzaIqResult, "jabber:iq:version");
	gloox::Tag* tag=st->findChild("query");
	assert(tag);
	tag->addChild(new gloox::Tag("name","GluxiBot"));
	tag->addChild(new gloox::Tag("version",getGluxiVersion()));
	tag->addChild(new gloox::Tag("os",version().toStdString()));
	qDebug() << QString::fromStdString(st->xml());
	bot()->client()->send(st);
}
예제 #23
0
// @requires UseG1GC
TEST_VM(FreeRegionList, length) {
  if (!UseG1GC) {
    return;
  }

  FreeRegionList l("test");
  const uint num_regions_in_test = 5;

  // Create a fake heap. It does not need to be valid, as the HeapRegion constructor
  // does not access it.
  MemRegion heap(NULL, num_regions_in_test * HeapRegion::GrainWords);

  // Allocate a fake BOT because the HeapRegion constructor initializes
  // the BOT.
  size_t bot_size = G1BlockOffsetTable::compute_size(heap.word_size());
  HeapWord* bot_data = NEW_C_HEAP_ARRAY(HeapWord, bot_size, mtGC);
  ReservedSpace bot_rs(G1BlockOffsetTable::compute_size(heap.word_size()));
  G1RegionToSpaceMapper* bot_storage =
    G1RegionToSpaceMapper::create_mapper(bot_rs,
                                         bot_rs.size(),
                                         os::vm_page_size(),
                                         HeapRegion::GrainBytes,
                                         BOTConstants::N_bytes,
                                         mtGC);
  G1BlockOffsetTable bot(heap, bot_storage);
  bot_storage->commit_regions(0, num_regions_in_test);

  // Set up memory regions for the heap regions.
  MemRegion mr0(heap.start(), HeapRegion::GrainWords);
  MemRegion mr1(mr0.end(), HeapRegion::GrainWords);
  MemRegion mr2(mr1.end(), HeapRegion::GrainWords);
  MemRegion mr3(mr2.end(), HeapRegion::GrainWords);
  MemRegion mr4(mr3.end(), HeapRegion::GrainWords);

  HeapRegion hr0(0, &bot, mr0);
  HeapRegion hr1(1, &bot, mr1);
  HeapRegion hr2(2, &bot, mr2);
  HeapRegion hr3(3, &bot, mr3);
  HeapRegion hr4(4, &bot, mr4);
  l.add_ordered(&hr1);
  l.add_ordered(&hr0);
  l.add_ordered(&hr3);
  l.add_ordered(&hr4);
  l.add_ordered(&hr2);

  EXPECT_EQ(l.length(), num_regions_in_test) << "Wrong free region list length";
  l.verify_list();

  bot_storage->uncommit_regions(0, num_regions_in_test);
  delete bot_storage;
  FREE_C_HEAP_ARRAY(HeapWord, bot_data);
}
예제 #24
0
static void pre_move_tasks(boolean didmove)
{
    boolean is_on_elbereth = sengr_at("Elbereth", u.ux, u.uy);

    /* recalc attribute bonuses from items */
    calc_attr_bonus();
    find_ac();

    if (!flags.mv || Blind)
	special_vision_handling();

    /* update "Elbereth" status */
    if (was_on_elbereth != is_on_elbereth) {
	was_on_elbereth = is_on_elbereth;
	iflags.botl = 1;
    }

    if (iflags.botl)
	bot();

    if (didmove &&
	(u.uhave.amulet || Clairvoyant) &&
	!In_endgame(&u.uz) && !BClairvoyant &&
	!(moves % 15) && !rn2(2))
	    do_vicinity_map();

    u.umoved = FALSE;

    if (multi > 0) {
	lookaround();
	if (!multi) {
	    /* lookaround may clear multi */
	    flags.move = 0;
	    iflags.botl = 1;
	}
    }
    
    if (didmove && moves % 100 == 0)
	realtime_tasks();
    
    update_inventory();
    update_location(FALSE);

    if (didmove) {
	/* Mark the current square as stepped on unless blind,
	 * since that would imply that we had properly explored it. */
	struct rm *loc = &level->locations[u.ux][u.uy];
	if (!Blind && !loc->mem_stepped)
	    loc->mem_stepped = 1;
    }
}
예제 #25
0
파일: line.cpp 프로젝트: wschweer/qped
void LinePos::decr()
      {
      if (bot())
            return;
      if (il.col == 0) {
            --ilist;
            --ln;
            il = iLine(&*ilist, 0);
            while (!(*il).isNull())
                  ++il;
            }
      else
            --il;
      }
예제 #26
0
bool Cylinder::computeEdges(const Vector3D &test_point, Vector3D &top_right, Vector3D &bot_right, Vector3D &top_left,  Vector3D &bot_left) const
{
    Vector2D test_point2d(test_point[0], test_point[1]);

    Vector2D top_right2d, top_left2d;
    int top_status = top().computeExtremalPoints(test_point2d, top_right2d, top_left2d);
    top_right[0] = top_right2d[0]; top_right[1] = top_right2d[1]; top_right[2] = m_length;
    top_left[0]  = top_left2d[0];  top_left[1]  = top_left2d[1];  top_left[2] = m_length;

    Vector2D bot_right2d, bot_left2d;
    int bot_status = bot().computeExtremalPoints(test_point2d, bot_right2d, bot_left2d);
    bot_right[0] = bot_right2d[0]; bot_right[1] = bot_right2d[1]; bot_right[2] = 0.0;
    bot_left[0]  = bot_left2d[0];  bot_left[1]  = bot_left2d[1];  bot_left[2] = 0.0;

    return (top_status != 0) || (bot_status != 0);
}
예제 #27
0
void codeFrame::paintEvent(QPaintEvent *){
   QPainter painter(this);
   QRect rect (0,0,width(),height());
   botA = new QImage();
   topA = new QImage(":/images/resources/arrow.png");
   
   *botA = topA->mirrored(true,true);
   QRect top( (width()-topA->width()-32), 4, topA->width(), topA->height() );
   QRect bot( (width()-botA->width()-32), height() - botA->height() -4 , botA->width(), botA->height());
   painter.setOpacity(0.8);
   painter.drawImage(rect, QImage(":/images/resources/dropspace.png"));
   painter.drawImage(bot, *botA);
   painter.drawImage(top,*topA);
   
   
}
예제 #28
0
void Octree::split() {
	for(int x = 0; x < 2; ++x) {
		FixedPoint bot_x;
		FixedPoint top_x;
		if (x == 0) {
			bot_x = bot.x;
			top_x = center.x;
		}
		else {
			bot_x = center.x;
			top_x = top.x;
		}
		for(int y = 0; y < 2; ++y) {
			FixedPoint bot_y;
			FixedPoint top_y;
			if (y == 0) {
				bot_y = bot.y;
				top_y = center.y;
			}
			else {
				bot_y = center.y;
				top_y = top.y;
			}
			
			for(int z = 0; z < 2; ++z) {
				FixedPoint bot_z;
				FixedPoint top_z;
				if (z == 0) {
					bot_z = bot.z;
					top_z = center.z;
				}
				else {
					bot_z = center.z;
					top_z = top.z;
				}
				Location bot(bot_x, bot_y, bot_z);
				Location top(top_x, top_y, top_z);
				children[x][y][z].reset(new Octree(bot, top, depth + 1));
			}
		}
	}
	hasChildren = true;
	for(auto it = objects.begin(); it != objects.end(); ++it) {
		insertObject(*it);
	}
	objects.clear();
}
예제 #29
0
파일: main.c 프로젝트: scruff3y/tictactoe
// Does next turn.
void nextTurn(GameBoard * game, PlayerList * playerlist) {
	/*
	If the current player is human, ask where they want to play.
	otherwise, pass bot gamestate and do what it passes back.
	*/
	int i = NUMBER_OF_GAME_SQUARES+1;
	int j = NUMBER_OF_GAME_SQUARES+1;

	Player currentPlayer = playerlist->players[(int) playerlist->whosTurn];

	printf("Player %c: where do you play?: ", currentPlayer.tile);

	if (currentPlayer.human) {
		scanf("%i %i", &i, &j);
		while ((i < 1) ||
			(i > NUMBER_OF_GAME_SQUARES) ||
			(j < 1) ||
			(j > NUMBER_OF_GAME_SQUARES) ||
			(game->tile[i-1][j-1] != 0x0)) {
			if (!((i < 1) || (i > NUMBER_OF_GAME_SQUARES) || (j < 1) || (j > NUMBER_OF_GAME_SQUARES))) {
				printf("Player %c has played there already.\n", game->tile[i-1][j-1]);
			}
			else {
				printf("An index was out of range or invalid.\n");
			}
			printf("Please try again: ");
			// Clear stdin...
			int c;
			while ((c = getc(stdin)) != '\n');
			scanf("%i %i", &i, &j);
		}
		i = i - 1;
		j = j - 1;

		// Clear stdin...
		int c;
		while ((c = getc(stdin)) != '\n');
	}
	else {
		bot(*game, &i, &j, *playerlist, currentPlayer.tile);
		printf("%i %i\n", i+1, j+1);
		// ^ Bot prints line to screen as if it were playing like a person.
	}
	game->tile[i][j] = currentPlayer.tile;
	playerlist->whosTurn += 1;
	playerlist->whosTurn %= playerlist->numPlayers;
}
예제 #30
0
파일: game.cpp 프로젝트: Supermanu/xoreos
bool Game::showMainMenu() {
	Graphics::Aurora::GUIQuad top("introscr_top" , 0.0f, 0.0f, kScreenWidth, kScreenHeight, 0.0f, 1.0f, 1.0f, 0.0f);
	Graphics::Aurora::GUIQuad bot("startupscrbot", 0.0f, 0.0f, kScreenWidth, kScreenHeight, 0.0f, 1.0f, 1.0f, 0.0f);

	top.setPosition(kTopScreenX   , kTopScreenY   , 0.0f);
	bot.setPosition(kBottomScreenX, kBottomScreenY, 0.0f);

	top.show();
	bot.show();


	Graphics::Aurora::TextureHandle buttonTexture = loadNCGR("main_pnl_off", "gui_main_pnl", 8, 2,
			"00", "01", "02", "03", "04", (const char *) 0, (const char *) 0, (const char *) 0,
			"10", "11", "12", "13", "14", "15", "16", "17");

	Graphics::Aurora::GUIQuad button(buttonTexture, 0.0f, 0.0f, 240.0f, 48.0f, 0.0f, 1.0f, 1.0f, 0.0f);

	button.setPosition(-120.0f, -120.0f, -1.0f);
	button.show();


	Graphics::Aurora::Text buttonText(_guiFont, 240.0f, 48.0f, TalkMan.getString(15860), 1.0f, 1.0f, 1.0f, 1.0f,
	                                  Graphics::Aurora::kHAlignCenter, Graphics::Aurora::kVAlignMiddle);
	buttonText.setPosition(-120.0f, -120.0f, -2.0f);
	buttonText.show();


	Graphics::Aurora::Text helpText(_guiFont, kScreenWidth, kScreenHeight, TalkMan.getString(18707), 1.0f, 1.0f, 1.0f, 1.0f,
	                                Graphics::Aurora::kHAlignCenter, Graphics::Aurora::kVAlignBottom);
	helpText.setPosition(kBottomScreenX, kBottomScreenY, -2.0f);
	helpText.show();


	GfxMan.unlockFrame();

	if (!waitClick())
		return false;

	GfxMan.lockFrame();
	helpText.hide();
	buttonText.hide();
	button.hide();
	top.hide();
	bot.hide();

	return true;
}