Beispiel #1
0
//! set up a graph
void AOgraph::setupGraph()
{
    // update the feasibility status of the nodes in the graph
    updateNodeFeasibility();
    //DEBUG:printGraphInfo();
    
    // generate all paths navigating the graph
    generatePaths();
    // set the "checked" property of the nodes in the paths to false
    // NOTE: during execution, "checked" is used to mark the solved nodes
    for (int i=0; i < (int)paths.size(); i++)
        for (int j=0; j < (int)paths[i].checkedNodes.size(); j++)
            paths[i].checkedNodes[j] = false;

    for (int i=0; i < (int)paths.size(); i++)
        paths[i].printPathInfo();
            
    // identify the first suggestion to make (long-sighted strategy chosen BY DEFAULT)
    suggestNext(true);
}
Beispiel #2
0
/***************************************************************************
 * initGame
 * Parameter: GameData - the struct to initialize
 * Description: This function initializes the given GameData object.
 * This is used to create the rooms. This will call the function
 * generatePath to create paths between rooms.
 ***************************************************************************/
void initGame( GameData* data )
{
    char* roomNames[10];
    // insert names into array
    roomNames[0] = "Holy Ground";
    roomNames[1] = "Far Thunder";
    roomNames[2] = "Spiral";
    roomNames[3] = "Great Seal";
    roomNames[4] = "Nothingness";
    roomNames[5] = "Touchstone";
    roomNames[6] = "Twin Hills";
    roomNames[7] = "Fertile Land";
    roomNames[8] = "Melody";
    roomNames[9] = "Remnant";

    // shuffle arrays for randomization
    int n;
    n = sizeof( roomNames ) / sizeof( roomNames[0] );
    shuffle( roomNames, n );
    //init the current Room
    data->currentRoom = malloc( sizeof( Room ) );
    //create the rooms (random name)
    int i;

    for( i = 0; i < MAX_ROOMS; i++ )
    {
        data->rooms[i] = malloc( sizeof( Room ) );
        initRoom( data->rooms[i], roomNames[i] );
    }

    //setup the start and end rooms
    data->rooms[0]->type = start_room;
    data->rooms[MAX_ROOMS - 1]->type = end_room;
    //set up the game first position
    data->currentRoom = data->rooms[0];
    data->endRoom = data->rooms[MAX_ROOMS - 1];
    //make a winning path
    generatePaths( data );
    data->steps = 0;
}