?? crstrtgy.c
字號(hào):
if (flag == LESS_THAN) { lastAct = actPtr; if (actPtr == theGroup->last) { break; } else { actPtr = actPtr->next; } } else if (flag == GREATER_THAN) { break; } else /* flag == EQUAL */ { if (timetag > actPtr->timetag) { lastAct = actPtr; if (actPtr == theGroup->last) { break; } else { actPtr = actPtr->next; } } else { break; } } } /*========================================*/ /* Update the salience group information. */ /*========================================*/ if ((lastAct == NULL) || ((theGroup->prev != NULL) && (theGroup->prev->last == lastAct))) { theGroup->first = newActivation; } if ((theGroup->last == NULL) || (theGroup->last == lastAct)) { theGroup->last = newActivation; } /*===========================================*/ /* Return the insertion point in the agenda. */ /*===========================================*/ return(lastAct); }/*******************************************************************//* PlaceMEAActivation: Determines the location in the agenda *//* where a new activation should be placed for the mea *//* strategy. Returns a pointer to the activation after which *//* the new activation should be placed (or NULL if the *//* activation should be placed at the beginning of the agenda). *//*******************************************************************/static ACTIVATION *PlaceMEAActivation( void *theEnv, ACTIVATION *newActivation, struct salienceGroup *theGroup) { unsigned long long timetag; ACTIVATION *lastAct, *actPtr; int flag; unsigned long long cWhoset = 0, oWhoset = 0; intBool cSet, oSet; /*============================================*/ /* Set up initial information for the search. */ /*============================================*/ timetag = newActivation->timetag; if (theGroup->prev == NULL) { lastAct = NULL; } else { lastAct = theGroup->prev->last; } /*================================================*/ /* Look first at the very end of the group to see */ /* if the activation should be placed there. */ /*================================================*/ actPtr = theGroup->last; if (actPtr != NULL) { if (GetMatchingItem(newActivation,0) != NULL) { cWhoset = GetMatchingItem(newActivation,0)->timeTag; cSet = TRUE; } else { cSet = FALSE; } if (GetMatchingItem(actPtr,0) != NULL) { oWhoset = GetMatchingItem(actPtr,0)->timeTag; oSet = TRUE; } else { oSet = FALSE; } if ((cSet == FALSE) && (oSet == FALSE)) { flag = ComparePartialMatches(theEnv,actPtr,newActivation); } else if ((cSet == TRUE) && (oSet == FALSE)) { flag = GREATER_THAN; } else if ((cSet == FALSE) && (oSet == TRUE)) { flag = LESS_THAN; } else if (oWhoset < cWhoset) { flag = GREATER_THAN; } else if (oWhoset > cWhoset) { flag = LESS_THAN; } else { flag = ComparePartialMatches(theEnv,actPtr,newActivation); } if ((flag == LESS_THAN) || ((flag == EQUAL) && (timetag > actPtr->timetag))) { theGroup->last = newActivation; return(actPtr); } } /*=========================================================*/ /* Find the insertion point in the agenda. The activation */ /* is placed before activations of lower salience and */ /* after activations of higher salience. Among activations */ /* of equal salience, the OPS5 mea strategy is used for */ /* determining placement. */ /*=========================================================*/ actPtr = theGroup->first; while (actPtr != NULL) { cWhoset = -1; oWhoset = -1; if (GetMatchingItem(newActivation,0) != NULL) { cWhoset = GetMatchingItem(newActivation,0)->timeTag; } if (GetMatchingItem(actPtr,0) != NULL) { oWhoset = GetMatchingItem(actPtr,0)->timeTag; } if (oWhoset < cWhoset) { if (cWhoset > 0) flag = GREATER_THAN; else flag = LESS_THAN; } else if (oWhoset > cWhoset) { if (oWhoset > 0) flag = LESS_THAN; else flag = GREATER_THAN; } else { flag = ComparePartialMatches(theEnv,actPtr,newActivation); } if (flag == LESS_THAN) { lastAct = actPtr; if (actPtr == theGroup->last) { break; } else { actPtr = actPtr->next; } } else if (flag == GREATER_THAN) { break; } else /* flag == EQUAL */ { if (timetag > actPtr->timetag) { lastAct = actPtr; if (actPtr == theGroup->last) { break; } else { actPtr = actPtr->next; } } else { break; } } } /*========================================*/ /* Update the salience group information. */ /*========================================*/ if ((lastAct == NULL) || ((theGroup->prev != NULL) && (theGroup->prev->last == lastAct))) { theGroup->first = newActivation; } if ((theGroup->last == NULL) || (theGroup->last == lastAct)) { theGroup->last = newActivation; } /*===========================================*/ /* Return the insertion point in the agenda. */ /*===========================================*/ return(lastAct); }/*********************************************************************//* PlaceComplexityActivation: Determines the location in the agenda *//* where a new activation should be placed for the complexity *//* strategy. Returns a pointer to the activation after which the *//* new activation should be placed (or NULL if the activation *//* should be placed at the beginning of the agenda). *//*********************************************************************/static ACTIVATION *PlaceComplexityActivation( ACTIVATION *newActivation, struct salienceGroup *theGroup) { int complexity; unsigned long long timetag; ACTIVATION *lastAct, *actPtr; /*========================================*/ /* Set up initial information for search. */ /*========================================*/ timetag = newActivation->timetag; complexity = newActivation->theRule->complexity; if (theGroup->prev == NULL) { lastAct = NULL; } else { lastAct = theGroup->prev->last; } /*=========================================================*/ /* Find the insertion point in the agenda. The activation */ /* is placed before activations of lower salience and */ /* after activations of higher salience. Among activations */ /* of equal salience, the activation is placed before */ /* activations of equal or lessor complexity. */ /*=========================================================*/ actPtr = theGroup->first; while (actPtr != NULL) { if (complexity < (int) actPtr->theRule->complexity) { lastAct = actPtr; if (actPtr == theGroup->last) { break; } else { actPtr = actPtr->next; } } else if (complexity > (int) actPtr->theRule->complexity) { break; } else if (timetag > actPtr->timetag) { lastAct = actPtr; if (actPtr == theGroup->last) { break; } else { actPtr = actPtr->next; } } else { break; } } /*========================================*/ /* Update the salience group information. */ /*========================================*/ if ((lastAct == NULL) || ((theGroup->prev != NULL) && (theGroup->prev->last == lastAct))) { theGroup->first = newActivation; } if ((theGroup->last == NULL) || (theGroup->last == lastAct)) { theGroup->last = newActivation; } /*===========================================*/ /* Return the insertion point in the agenda. */ /*===========================================*/ return(lastAct); }/*********************************************************************//* PlaceSimplicityActivation: Determines the location in the agenda *//* where a new activation should be placed for the simplicity *//* strategy. Returns a pointer to the activation after which the *//* new activation should be placed (or NULL if the activation *//* should be placed at the beginning of the agenda). *//*********************************************************************/static ACTIVATION *PlaceSimplicityActivation( ACTIVATION *newActivation, struct salienceGroup *theGroup) { int complexity; unsigned long long timetag; ACTIVATION *lastAct, *actPtr; /*============================================*/ /* Set up initial information for the search. */ /*============================================*/ timetag = newActivation->timetag; complexity = newActivation->theRule->complexity; if (theGroup->prev == NULL) { lastAct = NULL; } else { lastAct = theGroup->prev->last; } /*=========================================================*/ /* Find the insertion point in the agenda. The activation */ /* is placed before activations of lower salience and */ /* after activations of higher salience. Among activations */ /* of equal salience, the activation is placed after */ /* activations of equal or greater complexity. */ /*=========================================================*/ actPtr = theGroup->first; while (actPtr != NULL) { if (complexity > (int) actPtr->theRule->complexity) { lastAct = actPtr; if (actPtr == theGroup->last) { break; } else { actPtr = actPtr->next; } } else if (complexity < (int) actPtr->theRule->complexity) { break; } else if (timetag > actPtr->timetag) { lastAct = actPtr; if (actPtr == theGroup->last) { break; } else { actPtr = actPtr->next; } } else { break; } } /*========================================*/ /* Update the salience group information. */ /*========================================*/ if ((lastAct == NULL) || ((theGroup->prev != NULL) && (theGroup->prev->last == lastAct))) { theGroup->first = newActivation; } if ((theGroup->last == NULL) || (theGroup->last == lastAct)) { theGroup->last = newActivation; } /*===========================================*/ /* Return the insertion point in the agenda. */ /*===========================================*/ return(lastAct); }/*******************************************************************//* PlaceRandomActivation: Determines the location in the agenda *//* where a new activation should be placed for the random *//* strategy. Returns a pointer to the activation after which *//* the new activation should be placed (or NULL if the *//* activation should be placed at the beginning of the agenda). *//*******************************************************************/static ACTIVATION *PlaceRandomActivation( ACTIVATION *newActivation, struct salienceGroup *theGroup) { int randomID;
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -