Gnuplot::Gnuplot(Grid entry) {
	matrix vals = entry.get_values();
	fp = popen(GNUPLOT, "w");
	str = strStream.str();
	for (unsigned int y = 0; y < vals[0].size(); y++) {
		for (unsigned int x = 0; x < vals.size(); x++) {
			 datStream << vals[x][y].value << "	";
		}
		datStream << "\n";
	}
    data = datStream.str();
    int x_siz = vals.size() - 1;
    int y_siz = vals[0].size() - 1;
    double min = lowest_value(vals);
    double max = highest_value(vals);
    std::string s1 = std::string("set xrange [0:") + numberToString(x_siz) + std::string("]");
	add_command(s1);
	std::string s2 = std::string("set yrange [0:") + numberToString(y_siz) + std::string("]");
    add_command(s2);
    std::string s3 = std::string("set cbrange [") + numberToString(min) + std::string(":") + numberToString(max) + std::string("]");
    add_command(s3);

}
Example #2
0
int next_point(int *move, int which, int algo)
{
    int MAX_POINTS;
    int x, y;

    if (algo == 1)
    {
        MAX_POINTS = 1000000;
        if (which >= MAX_POINTS)
            return 0;
        move[0] = which / 1000;
        move[1] = which % 1000;
        return 1;
    }
    if (algo == 2)
    {
        MAX_POINTS = 100;
        if (which >= MAX_POINTS)
            return 0;
        move[0] = (which / 10) * 100;
        move[1] = (which % 10) * 100;
        return 1;
    }
    if (algo == 3)
    {
        //DO SOMETHING WITH GAME BOARD
        //MAKE ARRAY OF POINTS
        MAX_POINTS = 40;
        if (which > MAX_POINTS)
            return 0;
        //SET MOVE TO which POINT
        return 1;
     }
     //Greedy next to their stones. Chooses the one 
     //with the highest value
     if (algo == 4)
     {
        move[0] = -1;
        move[1] = -1;
        MAX_POINTS = (MAX_NUMBER_OF_MOVES / 2);
        if (which >= MAX_POINTS)
           return 0;
        if(NUM_MOVES_REMAINING == MAX_NUMBER_OF_MOVES)
        {
           move[0] = 500;
           move[1] = 500;
           which = MAX_POINTS;
           return 1;
        }
       if(!next_to_set)
        {
           x = moves[(which * 2) - 2];
           y = moves[(which * 2) - 2 + 1];
           highest_value_greedy(move, x, y);
        }
        else
        {
           x = moves[which * 2];
           y = moves[which * 2 + 1];
           highest_value_greedy(move, x, y);
        } 
        if(move[0] == -1 && move[1] == -1)
        {
           move[0] = get_random_int();
           move[1] = get_random_int();
           return 0;
        }
        return 1;
     }
     // Greedy next to their stone. Choose the best one
     if(algo == 5)
     {
        move[0] = -1;
        move[1] = -1;
        MAX_POINTS = (MAX_NUMBER_OF_MOVES / 2);
        if (which >= MAX_POINTS)
           return 0;
        if(NUM_MOVES_REMAINING == MAX_NUMBER_OF_MOVES)
        {
           move[0] = 500;
           move[1] = 500;
           which = MAX_POINTS;
           return 1;
        }
        if(!next_to_set)
        { 
           x = moves[(which * 2) - 2];
           y = moves[(which * 2) - 2 + 1];
           nearby_greedy(move, x, y);
        }
        else
        {
           x = moves[which * 2];
           y = moves[which * 2 + 1];
           nearby_greedy(move, x, y);
        } 
        if(move[0] == -1 && move[1] == -1)
        {
           move[0] = get_random_int();
           move[1] = get_random_int();
           return 0;
        }
        return 1;
     }
     // Random algorithm
     if (algo == 6)
     {
        MAX_POINTS = 400;
        if(which > MAX_POINTS)
           return 0;
        move[0] = get_random_int();
        move[1] = get_random_int();
     }
     //lowest value on the board 
     if(algo == 7)
     {
        MAX_POINTS = 1;
        if(which > MAX_POINTS)
           return 0;
        lowest_value(move, 25);
        return 1;
     }
     //lowest value from random values
     if(algo == 8)
     {
        MAX_POINTS = 300;
        if(which > MAX_POINTS)
           return 0;
        lowest_random(move, 25, .00003);
        return 1;
     }     

     return 0;
}