Soar Kernel  9.3.2 08-06-12
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Data Structures | Typedefs | Functions
decision_manipulation.h File Reference
#include <string>
#include "gdatastructs.h"

Go to the source code of this file.

Data Structures

struct  select_info_struct

Typedefs

typedef struct agent_struct agent
typedef struct select_info_struct select_info

Functions

const char * predict_get (agent *my_agent)
void predict_init (agent *my_agent)
void predict_set (agent *my_agent, const char *prediction)
void predict_srand_restore_snapshot (agent *my_agent, bool clear_snapshot=true)
void predict_srand_store_snapshot (agent *my_agent)
preferenceselect_force (agent *my_agent, preference *candidates, bool reinit=true)
const char * select_get_operator (agent *my_agent)
void select_init (agent *my_agent)
void select_next_operator (agent *my_agent, const char *operator_id)

Typedef Documentation

typedef struct agent_struct agent

Definition at line 20 of file decision_manipulation.h.

Function Documentation

const char* predict_get ( agent my_agent)

Definition at line 149 of file decision_manipulation.cpp.

References do_decision_phase(), predict_srand_store_snapshot(), and agent_struct::prediction.

{
do_decision_phase( my_agent, true );
return my_agent->prediction->c_str();
}
void predict_init ( agent my_agent)

Definition at line 107 of file decision_manipulation.cpp.

References agent_struct::predict_seed, and agent_struct::prediction.

Referenced by create_soar_agent(), init_soar_agent(), and predict_srand_restore_snapshot().

{
my_agent->predict_seed = 0;
(*my_agent->prediction) = "";
}
void predict_set ( agent my_agent,
const char *  prediction 
)

Definition at line 141 of file decision_manipulation.cpp.

References agent_struct::prediction.

Referenced by decide_context_slot().

{
(*my_agent->prediction) = prediction;
}
void predict_srand_restore_snapshot ( agent my_agent,
bool  clear_snapshot = true 
)

Definition at line 129 of file decision_manipulation.cpp.

References predict_init(), agent_struct::predict_seed, and SoarSeedRNG().

Referenced by do_decision_phase().

{
if ( my_agent->predict_seed )
SoarSeedRNG( my_agent->predict_seed );
if ( clear_snapshot )
predict_init( my_agent );
}
void predict_srand_store_snapshot ( agent my_agent)

Definition at line 116 of file decision_manipulation.cpp.

References agent_struct::predict_seed, SoarRandInt(), and uint32_t().

Referenced by predict_get().

{
uint32_t storage_val = 0;
while ( !storage_val )
storage_val = SoarRandInt();
my_agent->predict_seed = storage_val;
}
preference* select_force ( agent my_agent,
preference candidates,
bool  reinit = true 
)

Definition at line 66 of file decision_manipulation.cpp.

References symbol_union::id, IDENTIFIER_SYMBOL_TYPE, identifier_struct::name_letter, identifier_struct::name_number, preference_struct::next, agent_struct::select, select_info_struct::select_enabled, select_init(), select_info_struct::select_operator, and preference_struct::value.

Referenced by run_preference_semantics().

{
preference *return_val = NULL;
preference *cand = candidates;
std::string temp;
if ( my_agent->select->select_enabled )
{
// go through the list till we find a match or done
while ( cand && !return_val )
{
if ( cand->value->common.symbol_type == IDENTIFIER_SYMBOL_TYPE )
{
// clear comparison string
temp = "";
// get first letter of comparison string
temp += cand->value->id.name_letter;
// get number of comparison string
std::string temp2;
to_string( cand->value->id.name_number, temp2 );
temp += temp2;
if ( !my_agent->select->select_operator.compare( temp ) )
return_val = cand;
}
cand = cand->next;
}
if ( return_val && reinit )
select_init( my_agent );
}
return return_val;
}
const char* select_get_operator ( agent my_agent)

Definition at line 55 of file decision_manipulation.cpp.

References agent_struct::select, select_info_struct::select_enabled, and select_info_struct::select_operator.

Referenced by run_preference_semantics().

{
if ( !my_agent->select->select_enabled )
return NULL;
return my_agent->select->select_operator.c_str();
}
void select_init ( agent my_agent)
void select_next_operator ( agent my_agent,
const char *  operator_id 
)

Definition at line 37 of file decision_manipulation.cpp.

References agent_struct::select, select_info_struct::select_enabled, select_init(), and select_info_struct::select_operator.

{
select_init( my_agent );
std::string& op = my_agent->select->select_operator;
my_agent->select->select_enabled = true;
op.assign(operator_id);
assert( !op.empty() );
// lazy users may use a lower-case letter
std::string::iterator iter = op.begin();
*iter = static_cast< char >( toupper( *iter ) );
}