GAMA agent-oriented simulation

I have two agent in the GAMA-platform 1. water user 2. authority. I need help to make a water user agent to move to authority agent to get permision to user water then to go back to its original position.the authority go to the water source and back to its original position. this is the gaml code.

global {
    //global attributes
    float distance_to_intercept <- 100.0;
    int number_of_water_source <-2;
    int number_of_water_user <-2;
    int number_of_authority <-1;
    
    init{
        //instantiate species
        create water_source number:number_of_water_source;
        create water_user number:number_of_water_user;
        create pangani_board number:number_of_authority;
        
        }
}

species water_source{
    //attributes 
     string source_name;
     string source_type;
     string source_catchment_name;
     float water_capacity;
     
     //aspect to represent agents of this species in the simulation
     aspect default{
        draw circle(1)color:#blue border:#black;
     }
}

species water_user skills:[moving]{
    pangani_board target;
    //attributes
     float amount_requested <-5.0;
     float amount_granted;
     string water_use;
     string source_type;
     string source_name;
     string catchment_name;
     bool is_returning;
     point location <- {rnd(100), rnd(100)}; // Random initial location
     point original_location <- location; // Store the original location
     
     //initialize agent speed
     init {
      speed <- 0.0;
      is_returning <- false; // Initialize is_returning to false
     }
     //request water use permit
      reflex request_water_use_permit {
        ask authority{
            myself.amount_granted<- grant_water_use_permit(myself.amount_requested);
        }
     }
    //move to authority 
    reflex search_target when: target=nil and not is_returning {
    ask authority at_distance(distance_to_intercept) {
        myself.target <- self;
        myself.speed <- 0.05; // Set speed to 0.05 when target is found
     }
    }
   
    reflex follow when: target!=nil {
    speed <- 0.0025;
    do goto target: target;
    float tolerance <- 0.9; // Tolerance for location comparison
    if (abs(self.location.x - target.location.x) < tolerance and abs(self.location.y - target.location.y) < tolerance) { // Check if the water_user has reached the authority within tolerance
        speed <- 0.0; // Stop the agent
        do goback; // Call the goback action
    }
    }
     action goback {
     is_returning <- true; // Set the is_returning flag to true
     speed <- 0.5; // Reset speed to the original value
     do goto target: original_location; // Move back to the original location
     if (self.location = original_location) { // Check if the water_user has reached the original location
          speed <- 0.0; // Stop the agent
          target <- nil; // Reset the target to nil to prevent re-activation of search_target reflex
         // is_returning <- false; // Reset the is_returning flag to false
          write("Agent has returned to original location"); // Log the return
      }
     }

     //aspect to represent agents of this species in the simulation
     aspect default{
        draw circle(1)color:#red border:#black;
     }
}
species authority{
    //atributes
    float amount_abstracted;
    point location <- {50, 50}; // Fixed location for authority
    
    float grant_water_use_permit(float amount_requested){
        
        float requested_amount<-amount_requested;
        
        if (requested_amount>=15 and requested_amount<=26.975){
            amount_abstracted <-23.18;
        }else if(requested_amount=10){
            amount_abstracted <-3.98;
        }else if(requested_amount<=2.0){
                amount_abstracted <-2.62;
            
        }else if (requested_amount<=5.0){
            amount_abstracted <-2.87;
        }else{
            amount_abstracted<-0.0;
        }
        
        return amount_abstracted;
    }
    
    //aspect to represent agents of this species in the simulation
    aspect default{
        draw circle(1)color:#yellow border:#black;
    }
    
}

experiment water_allocation type:gui{
    output{
        display my_agents{
            species water_source aspect:default;
            species water_user aspect:default;
            species authority aspect:default;
        }
    }
}

I tried to make the water_user move to the authority using the code above. its actualy move but it doesnt go back to its original position

New contributor

Coder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật