예제 #1
0
파일: xor.cpp 프로젝트: Urvi5/poker
int main (int argc, char * const argv[]) {    
    PopulationEvolver ev(2, 1, evaluate_fitness_xor, 150, 50, 12, 0.04, false);
    
    ev.evolve(1000);
    
    ev.get_population_fitness(0);
    
    cout << "Best fitness  = " << ev.population_[0]->fitness_ << endl;
    
    for (int i = 0; i < ev.population_.size(); i++) {
        stringstream filename;
        filename << "networks/network" << i << ".gv";
        
        ofstream file;
        file.open(filename.str().c_str());
        file << ev.population_[i]->save();
        file.close();
    }
    
    return 0;
    
    NeuralNetwork* net = Phenotype::get_network(ev.population_[0]);
    while (true) {
        vector<double> input(2);
    
        cout << "x0 = ";
        cin >> input[0];
        cout << "x1 = ";
        cin >> input[1];
        cout << "y = " << net->get_output(input)[0] << endl;
        cout << "------" << endl;
    }
    
    return 0;
}
예제 #2
0
파일: play.cpp 프로젝트: Urvi5/poker
 int operator() (GameState& game_state, PlayerState& player_state, int minimum_money) {
     vector<double> input;
     input.push_back(Hand_EVAL_N(player_state.cards(),StdDeck_numCards(player_state.cards())));
     
     return min((int)(player_state.get_money()*network_->get_output(input)[0]), minimum_money);
 }