232
X-Machines for Agent-Based Modeling: FLAME Perspectives
drug_a_information_message=get_first_drug_a_information_message();
while(drug_a_information_message)
{
drugx=drug_a_information_message->myx;
drugy=drug_a_information_message->myy;
current_distance_squared = (drugx - XPOS)*(drugx - XPOS) +
(drugy - YPOS)*(drugy - YPOS);
if(current_distance_squared <= (attack_length*attack_length))
{
if(current_distance_squared < shortest_distance)
{
shortest_distance = current_distance_squared;
closest_drug_a_id = drug_a_information_message->drugid;
}
}
drug_a_information_message = get_next_drug_a_information_message
(drug_a_information_message);
}
if(closest_drug_a_id != -1)
{
if(shortest_distance <= (attack_length*attack_length))
{
if(MCAT==1)
{
add_drug_used_message(closest_drug_a_id, MCAT, XPOS, YPOS);
return 1;
}
if(MCAT==3)
{
add_drug_used_message(closest_drug_a_id, MCAT, XPOS, YPOS);
return 1;
}
}
}
drug_b_information_message=get_first_drug_b_information_message();
while(drug_b_information_message)
{
drugx=drug_b_information_message->myx;
drugy=drug_b_information_message->myy;
current_distance_squared = (drugx - XPOS)*(drugx - XPOS) +
(drugy - YPOS)*(drugy - YPOS);
if(current_distance_squared <= (attack_length*attack_length))
{
if(current_distance_squared < shortest_distance)
{
shortest_distance = current_distance_squared;
closest_drug_b_id = drug_b_information_message->drugid;
}
}
drug_b_information_message = get_next_drug_b_information_message
(drug_b_information_message);
}
if(closest_drug_b_id != -1)
{
if(shortest_distance <= (attack_length*attack_length))
{
X-Machines for Agent-Based Modeling: FLAME Perspectives
drug_a_information_message=get_first_drug_a_information_message();
while(drug_a_information_message)
{
drugx=drug_a_information_message->myx;
drugy=drug_a_information_message->myy;
current_distance_squared = (drugx - XPOS)*(drugx - XPOS) +
(drugy - YPOS)*(drugy - YPOS);
if(current_distance_squared <= (attack_length*attack_length))
{
if(current_distance_squared < shortest_distance)
{
shortest_distance = current_distance_squared;
closest_drug_a_id = drug_a_information_message->drugid;
}
}
drug_a_information_message = get_next_drug_a_information_message
(drug_a_information_message);
}
if(closest_drug_a_id != -1)
{
if(shortest_distance <= (attack_length*attack_length))
{
if(MCAT==1)
{
add_drug_used_message(closest_drug_a_id, MCAT, XPOS, YPOS);
return 1;
}
if(MCAT==3)
{
add_drug_used_message(closest_drug_a_id, MCAT, XPOS, YPOS);
return 1;
}
}
}
drug_b_information_message=get_first_drug_b_information_message();
while(drug_b_information_message)
{
drugx=drug_b_information_message->myx;
drugy=drug_b_information_message->myy;
current_distance_squared = (drugx - XPOS)*(drugx - XPOS) +
(drugy - YPOS)*(drugy - YPOS);
if(current_distance_squared <= (attack_length*attack_length))
{
if(current_distance_squared < shortest_distance)
{
shortest_distance = current_distance_squared;
closest_drug_b_id = drug_b_information_message->drugid;
}
}
drug_b_information_message = get_next_drug_b_information_message
(drug_b_information_message);
}
if(closest_drug_b_id != -1)
{
if(shortest_distance <= (attack_length*attack_length))
{
