Esempio n. 1
0
/*-----------------------------------------------------------------------------
 *  Main Function
 *  Initiates the graphics buffer, creates the window and CalculatePoints
 *-----------------------------------------------------------------------------*/
int main( int argc, char *argv[] )
{
    /* Seed the random number generator */
    srand(time(0));

    /* Initialize the drawing environment */
    glutInit( &argc, argv );

    /* Initialize the display mode */
    glutInitDisplayMode ( GLUT_DOUBLE );

    /* Create an application window of a certain size */
    glutInitWindowSize( 850, 450 );

    /* Create an application window on the screen */
    glutCreateWindow( "Assignment #1: Star Polygon" );

    /* Register the function that does drawing */
    glutDisplayFunc( Draw );

    /* Create the Keyboard callback */
    glutKeyboardFunc( KeyboardFunc );

    /* Register Exit Handler */
    atexit(ClearMemory);

    /* Calculate the Points */
    CalculatePoints(RADIUS, m, n);

    /* Turn over control to OpenGL */
    glutMainLoop();

    return( 0 );  /* NOTE: this is here only for ANSI requirements */
}
Esempio n. 2
0
int main (void)
{
	//Local Variables
	cs460hwp hw02[COUNT460];
	char dueDate[9];

	//Get Due DAte
	printf("Please enter hw02 due date (YYYYMMDD)>");
	scanf("%s",dueDate);

	//Loop uisng COUNT460
	for (int i = 0; i < COUNT460; i++){
		strcpy(hw02[i].course,course);
		printf("Please Enter WSU ID>");
		scanf("%s",hw02[i].wsuid);
		printf("Please Enter hw02 submission date (YYYYMMDD)>");
		scanf("%s",hw02[i].subdate);
		printf("Please enter grade points>");
		scanf("%lf",&hw02[i].points1);
		//Calculate points2
		hw02[i].points2 = CalculatePoints(dueDate,hw02[i].subdate, hw02[i].points1);
	}

	PrintGrades(hw02);

	return 0;
}
Esempio n. 3
0
/*-----------------------------------------------------------------------------
 *  KeyboardFunc
 *  Handles the keyboard input for each of the various buttons
 *-----------------------------------------------------------------------------*/
void KeyboardFunc( unsigned char key, int x, int y )
{
    /* Determine which key is pressed */
    switch(key)
    {
        case 27: /* Escape the Program */
            exit(0);
            break;
        case 's': /* Enable the Show Display Items */
            if(enableShow)
                enableShow = FALSE;
            else
                enableShow = TRUE;
            break;
        case 'a': /* Enable the Show All Polygons */
            if(enableAll)
                enableAll = FALSE;
            else
                enableAll = TRUE;
            break;
        case 'r': /* Enable the Show Random Colors */
            if(enableRandom)
                enableRandom = FALSE;
            else
                enableRandom = TRUE;
            break;
        case 'M':
            if(m < MAX_INT)
                m++; /* Increment m */
            break;
        case 'm':
            if(m > MIN_INT)
            {
               m--; /* Decrement m */
               if(n >= (m / 2))
                   n = (m / 2); /* Set n */
            }
            break;
        case 'N':
            if(n < (m / 2))
                n++; /* Increment n */
            break;
        case 'n':
            if(n > MIN_INT)
                n--; /* Decrement n */
            break;
        default: return; /* Exit if another key was pressed */
    }
    /* Recalculate Points */
    CalculatePoints(RADIUS, m, n);

    /* Redraw the Display */
    glutPostRedisplay();
}
Esempio n. 4
0
std::list<DilemmaModel::ActionInfo> DilemmaModel::NextIteration()
{
    std::list<DilemmaModel::ActionInfo> state;
    
    std::list<Action> actions;
    
    for(std::list<DilemmaModel::Strategy>::iterator i = _strategies.begin(); i != _strategies.end(); i++)
    {
        Action current_action = (*i).pointer->GetAction();
        
        actions.push_back(current_action);
        for(std::list<DilemmaModel::Strategy>::iterator j = _strategies.begin(); j != _strategies.end(); j++)
        {
            if(i == j)
            {
                continue;
            }
            
            (*j).pointer->SetOpponentAction((*i).name, current_action);
        }
    }
    
    std::list<int> points = CalculatePoints(actions);
    
    std::list<Action>::iterator actions_iter = actions.begin();
    std::list<int>::iterator points_iter = points.begin();
    
    for(std::list<DilemmaModel::Strategy>::iterator i = _strategies.begin(); i != _strategies.end(); i++)
    {
        DilemmaModel::ActionInfo action;
        
        action.name = (*i).name;
        action.action = *actions_iter;
        action.points = *points_iter;
        action.total_points = (*i).points;
        state.push_back(action);
        
        ++actions_iter;
        ++points_iter;
    }
    
    return state;
}