Ocean::Ocean(QWidget *parent) : QMainWindow(parent), ui(new Ui::Ocean) { ui->setupUi(this); timer = new QTimer; SizeField=ui->SizeFieldBox->value(); for (int i = 0;i<100;i++) massPointX.push_back(i); ocean = new Drawing_Scene(this, SizeField); area = new AREA * [400]; for (int i = 0; i < 400; i++) area[i] = new AREA [400]; connect(ui->startButton, SIGNAL(clicked()), this, SLOT(Generation())); connect(ui->generationButton, SIGNAL(clicked()), this, SLOT(StartInit())); connect(ocean, SIGNAL(SendCoordMous(int, int, int)), this, SLOT(GetCoordMouse(int, int, int))); connect(timer, SIGNAL(timeout()), this, SLOT(Generation())); connect(ui->SizeFieldBox, SIGNAL(valueChanged(int)), ocean, SLOT(ChangeFieldSize(int))); ui->main_layout->setStretchFactor(ui->OceanScene, 8); ui->main_layout->setStretchFactor(ui->ConfigLaout, 2); ui->startButton->setEnabled(false); ui->OceanScene->addWidget(ocean); ocean->RecieveInit(area); }
Game::Game() { srand(time(0)); //Create main game scene QGraphicsScene *game_screen = new QGraphicsScene(this); //Create player tank Player *player = new Player('U'); player->setRect(0, 0, 31, 31); game_screen->addItem(player); player->setFlag(QGraphicsItem::ItemIsFocusable); player->setFocus(); QGraphicsView *screen = new QGraphicsView(game_screen); screen->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); screen->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); screen->show(); screen->setFixedSize(800, 600); game_screen->setSceneRect(0, 0, 800, 600); //player->setPos(screen->width()/2+1, screen->height() - player->rect().height()-5); player->setPos(32*4,32*12); //player->setPos(screen->width()/2+1, screen->height() - player->rect().height()-4); Generation(game_screen); }
Population::Population(unsigned firstGenerationSize, Functions& newGoalFunctions, Functions &newConstraints, double newLowerBound, double newUpperBound) : goalFunctions(&newGoalFunctions) , constraints(&newConstraints) , lowerBound(newLowerBound) , upperBound(newUpperBound) , generations(1, Generation(firstGenerationSize, *goalFunctions, *constraints, lowerBound, upperBound)) { }
std::vector<std::vector<double>> Population::generateGenerations(unsigned generationsCount) { assert(generations.size() >= 1); generations.resize(1, Generation(sizeOfGeneration(1), *goalFunctions, *constraints, lowerBound, upperBound) ); for (unsigned i = 0; i < generationsCount - 1; ++i) generations.push_back(generations[i].produceNextGeneration()); generations.shrink_to_fit(); return generations[generations.size() - 1].getFirstFront(); }