void Program::Main(Array<String>* args){ C* c = new C(); IA* a = *c; a->f(); IB* b = *c; b->f(); c->f(); }
MoveActionState Gomoku::DoNextMove() { int num = this->nextPlayerNum - 1; if (this->players[num]->GetType() == IS_HUMAN) return (WAITING_PLAYER_ACTION); else { IA *ia = (IA*)this->players[num]; ia->findMove(); return (DONE); } }
bool CIsmBlock::isAllIAClosed()const { size_t ism_ia_sz = ismIAVec.size(); size_t count=0; for(size_t i =0;i<ism_ia_sz;i++) { IA *ia = ismIAVec[i]; if(ia->isAborted()||ia->isClosed()){ count++; } } return count == ism_ia_sz; }
void Controller::init(IA<Dim, Type>& _ia, Environment<Dim, Type, Data>& _env) { logger(Logger::PROGRESS) << "Init Controller."; // Check that there is a least one continue criterion if(Controller::cont.size() == 0) throw std::runtime_error("One criterion is requiered at least !"); // TODO Surchage de la méthode init /*if(Controller::env == nullptr) throw std::runtime_error("Controller needs an environment !");*/ // If SpatialData is not specified, we created it if(spatialData == nullptr) { // If we have partition or indexing algorithm AND environment //if() logger(Logger::DEBUG) << "Controller : SpatialData creation"; spatialData = new SpatialData(&_env); } _env.setSpatialData(*spatialData); _ia.setSpatialData(*spatialData); spatialData->startPartitioning(); spatialData->startIndexing(); Controller::initialized = true; }
IA *XmlLoad::createAI(tinyxml2::XMLElement *ai, int width, int height) const { IA *newAI; newAI = new IA(this->getUnIntValue(ai, "position"), static_cast<eDifficulty>(this->getIntValue(ai, "difficulty")), width, height); newAI->setMaxBombs(this->getIntValue(ai, "maxBombs")); newAI->setState(this->getBoolValue(ai, "state")); newAI->setDirection(static_cast<eDirection>(this->getIntValue(ai, "direction"))); newAI->setSpeed(this->getFloatValue(ai, "speed")); newAI->setRangeBomb(this->getUnIntValue(ai, "rangeBomb")); newAI->setTexturePath(std::string(ai->FirstChildElement("texture")->GetText())); newAI->setBombs(this->createBombs(ai->FirstChildElement("bombs"))); return (newAI); }
void Bonus::doBonus(IA& bomberman) { if (this->bonus == SPEEDADD) bomberman.setSpeed(bomberman.getSpeed() + 1); if (this->bonus == PORTEE) bomberman.setPortee(bomberman.getPortee() + 1); if (this->bonus == BOMBNB) bomberman.setStockBomb(bomberman.getStockBomb() + 1); }
int main() { sf::Music music; if (!music.openFromFile("MainMusic.ogg")) std::cout << "Probleme chargement fichier audio" << std::endl; music.play(); int x=0; int y=0; sf::RenderWindow window(sf::VideoMode(500, 450), "MORPION"); Menu menu(window.getSize().x, window.getSize().y); while (window.isOpen()) { sf::Event event; while (window.pollEvent(event)) { switch (event.type) { case sf::Event::KeyReleased: switch (event.key.code) { case sf::Keyboard::Up: menu.MoveUp(); break; case sf::Keyboard::Down: menu.MoveDown(); break; case sf::Keyboard::Return: switch (menu.GetPressedItem()) { case 0: x=x+1; std::cout << "Joueur contre joueur" << std::endl; window.close(); break; case 1: x=x-1; std::cout << "Joueur contre IA" << std::endl; window.close(); break; case 2: std::cout << "Partie multi" << std::endl; window.close(); y=y+1; break; case 3: std::cout << "Vous avez quitter" << std::endl; window.close(); break; } break; } break; case sf::Event::Closed: window.close(); break; } } window.clear(); menu.draw(window); window.display(); } if (x>0) { Game game; game.run(); } else if (x<0) { IA ia; ia.run(); } else if (y>0) { MenuClient client; client.run(); } return 0; }