SlideShare a Scribd company logo
1 of 1
Download to read offline
This is a follow up question to my unity agents farmer, horse, pig, chicken. given a farmeragent.cs
that was provided will this animalagent.cs work as long as i provide a fooditem script attached to
apple, truffle, worm? Basically what Im trying to verify is that my animalagent script will work with
the farmeragent script here are the scripts
Farmeragent.cs
public class FarmerAgent : Agent { public GameObject horse; public GameObject pig; public
GameObject chicken; private bool isHorseFed = false; private bool isPigFed = false; private bool
isChickenFed = false; public override void AgentReset() { isHorseFed = false; isPigFed = false;
isChickenFed = false; } public override void CollectObservations() { // No observations needed for
the farmer agent } public override void AgentAction(float[] vectorAction, string textAction) { int
action = Mathf.FloorToInt(vectorAction[0]); switch (action) { case 0: DropApple(horse); break; case
1: DropTruffle(pig); break; case 2: DropWorm(chicken); break; } AddReward(-0.01f); } private void
DropApple(GameObject animal) { if (animal.GetComponent<AnimalAgent>().preferredFood ==
Food.Apple) { animal.GetComponent<AnimalAgent>().isFed = true; isHorseFed = true;
AddReward(1.0f); } else { AddReward(-1.0f); } } private void DropTruffle(GameObject animal) { if
(animal.GetComponent<AnimalAgent>().preferredFood == Food.Truffle) {
animal.GetComponent<AnimalAgent>().isFed = true; isPigFed = true; AddReward(1.0f); } else {
AddReward(-1.0f); } } private void DropWorm(GameObject animal) { if
(animal.GetComponent<AnimalAgent>().preferredFood == Food.Worm) {
animal.GetComponent<AnimalAgent>().isFed = true; isChickenFed = true; AddReward(1.0f); }
else { AddReward(-1.0f); } } private void OnTriggerEnter(Collider other) { if
(other.CompareTag("Wall") || other.CompareTag("Environment")) { AddReward(-0.1f); } } }
animalagents.cs
public class AnimalAgent : Agent { public Food preferredFood; public bool isFed = false; public
override void AgentReset() { isFed = false; } public override void CollectObservations() { // No
observations needed for the animal agent } public override void AgentAction(float[] vectorAction,
string textAction) { // No actions needed for the animal agent } private void OnTriggerEnter(Collider
other) { if (other.CompareTag("Food")) { Food foodType =
other.GetComponent<FoodItem>().foodType; if (foodType == preferredFood) { isFed = true;
AddReward(1.0f); } else { AddReward(-1.0f); } Destroy(other.gameObject); } else if
(other.CompareTag("Wall") || other.CompareTag("Environment")) { AddReward(-0.1f); } } }
fooditem.cs
public class FoodItem : MonoBehaviour { public Food foodType; }

More Related Content

More from abithmobiles

waine the NPV or the preiont Mr 45N of saiea Pius Deprec.pdf
waine the NPV or the preiont Mr 45N of saiea Pius Deprec.pdfwaine the NPV or the preiont Mr 45N of saiea Pius Deprec.pdf
waine the NPV or the preiont Mr 45N of saiea Pius Deprec.pdfabithmobiles
 
Use one paragraph to answer the question of which of the two.pdf
Use one paragraph to answer the question of which of the two.pdfUse one paragraph to answer the question of which of the two.pdf
Use one paragraph to answer the question of which of the two.pdfabithmobiles
 
Dunphy Company issued 16000 of 7510year bonds at par v.pdf
Dunphy Company issued 16000 of 7510year bonds at par v.pdfDunphy Company issued 16000 of 7510year bonds at par v.pdf
Dunphy Company issued 16000 of 7510year bonds at par v.pdfabithmobiles
 
67Divya a cybersecurity analyst has been noticing more in.pdf
67Divya a cybersecurity analyst has been noticing more in.pdf67Divya a cybersecurity analyst has been noticing more in.pdf
67Divya a cybersecurity analyst has been noticing more in.pdfabithmobiles
 
4 Multiple choice On the Internet application protocols p.pdf
4  Multiple choice On the Internet application protocols p.pdf4  Multiple choice On the Internet application protocols p.pdf
4 Multiple choice On the Internet application protocols p.pdfabithmobiles
 
5 Suppose Xi Normal 0i21 where i129 and X1X2X9.pdf
5 Suppose Xi Normal 0i21 where i129 and X1X2X9.pdf5 Suppose Xi Normal 0i21 where i129 and X1X2X9.pdf
5 Suppose Xi Normal 0i21 where i129 and X1X2X9.pdfabithmobiles
 
Airqual Test Corporation provides onsite air quialify testi.pdf
Airqual Test Corporation provides onsite air quialify testi.pdfAirqual Test Corporation provides onsite air quialify testi.pdf
Airqual Test Corporation provides onsite air quialify testi.pdfabithmobiles
 
The Mars company says that before the introduction of purple.pdf
The Mars company says that before the introduction of purple.pdfThe Mars company says that before the introduction of purple.pdf
The Mars company says that before the introduction of purple.pdfabithmobiles
 
The partial worksheet for the Jamison Company showed the fol.pdf
The partial worksheet for the Jamison Company showed the fol.pdfThe partial worksheet for the Jamison Company showed the fol.pdf
The partial worksheet for the Jamison Company showed the fol.pdfabithmobiles
 
Reference Question In an early meeting with your customer t.pdf
Reference Question In an early meeting with your customer t.pdfReference Question In an early meeting with your customer t.pdf
Reference Question In an early meeting with your customer t.pdfabithmobiles
 
Send answers please Thanks 27 The ANS generally exhibits .pdf
Send answers please Thanks 27 The ANS generally exhibits .pdfSend answers please Thanks 27 The ANS generally exhibits .pdf
Send answers please Thanks 27 The ANS generally exhibits .pdfabithmobiles
 
Suppose a byteaddressable memory contains 2MB and cache con.pdf
Suppose a byteaddressable memory contains 2MB and cache con.pdfSuppose a byteaddressable memory contains 2MB and cache con.pdf
Suppose a byteaddressable memory contains 2MB and cache con.pdfabithmobiles
 
Starting with the SIR model with births and deaths where i.pdf
Starting with the SIR model with births and deaths where  i.pdfStarting with the SIR model with births and deaths where  i.pdf
Starting with the SIR model with births and deaths where i.pdfabithmobiles
 
QUESTION 23 focus on a single product or service and have th.pdf
QUESTION 23 focus on a single product or service and have th.pdfQUESTION 23 focus on a single product or service and have th.pdf
QUESTION 23 focus on a single product or service and have th.pdfabithmobiles
 
begintabularrrl hline multicolumn1r P23 a.pdf
begintabularrrl hline multicolumn1r P23  a.pdfbegintabularrrl hline multicolumn1r P23  a.pdf
begintabularrrl hline multicolumn1r P23 a.pdfabithmobiles
 
Marin Supplies Company sells many different widgets and uses.pdf
Marin Supplies Company sells many different widgets and uses.pdfMarin Supplies Company sells many different widgets and uses.pdf
Marin Supplies Company sells many different widgets and uses.pdfabithmobiles
 
OnBoarding and Training Young Leaders at ECommerce Giant A.pdf
OnBoarding and Training Young Leaders at ECommerce Giant A.pdfOnBoarding and Training Young Leaders at ECommerce Giant A.pdf
OnBoarding and Training Young Leaders at ECommerce Giant A.pdfabithmobiles
 
Note Round to the nearest 1000 th decimal place include .pdf
Note Round to the nearest 1000 th decimal place include .pdfNote Round to the nearest 1000 th decimal place include .pdf
Note Round to the nearest 1000 th decimal place include .pdfabithmobiles
 
Menkes Syndrome is a rare Xlinked disease that affects copp.pdf
Menkes Syndrome is a rare Xlinked disease that affects copp.pdfMenkes Syndrome is a rare Xlinked disease that affects copp.pdf
Menkes Syndrome is a rare Xlinked disease that affects copp.pdfabithmobiles
 
Milano Gallery purchases the copyright on a painting for 42.pdf
Milano Gallery purchases the copyright on a painting for 42.pdfMilano Gallery purchases the copyright on a painting for 42.pdf
Milano Gallery purchases the copyright on a painting for 42.pdfabithmobiles
 

More from abithmobiles (20)

waine the NPV or the preiont Mr 45N of saiea Pius Deprec.pdf
waine the NPV or the preiont Mr 45N of saiea Pius Deprec.pdfwaine the NPV or the preiont Mr 45N of saiea Pius Deprec.pdf
waine the NPV or the preiont Mr 45N of saiea Pius Deprec.pdf
 
Use one paragraph to answer the question of which of the two.pdf
Use one paragraph to answer the question of which of the two.pdfUse one paragraph to answer the question of which of the two.pdf
Use one paragraph to answer the question of which of the two.pdf
 
Dunphy Company issued 16000 of 7510year bonds at par v.pdf
Dunphy Company issued 16000 of 7510year bonds at par v.pdfDunphy Company issued 16000 of 7510year bonds at par v.pdf
Dunphy Company issued 16000 of 7510year bonds at par v.pdf
 
67Divya a cybersecurity analyst has been noticing more in.pdf
67Divya a cybersecurity analyst has been noticing more in.pdf67Divya a cybersecurity analyst has been noticing more in.pdf
67Divya a cybersecurity analyst has been noticing more in.pdf
 
4 Multiple choice On the Internet application protocols p.pdf
4  Multiple choice On the Internet application protocols p.pdf4  Multiple choice On the Internet application protocols p.pdf
4 Multiple choice On the Internet application protocols p.pdf
 
5 Suppose Xi Normal 0i21 where i129 and X1X2X9.pdf
5 Suppose Xi Normal 0i21 where i129 and X1X2X9.pdf5 Suppose Xi Normal 0i21 where i129 and X1X2X9.pdf
5 Suppose Xi Normal 0i21 where i129 and X1X2X9.pdf
 
Airqual Test Corporation provides onsite air quialify testi.pdf
Airqual Test Corporation provides onsite air quialify testi.pdfAirqual Test Corporation provides onsite air quialify testi.pdf
Airqual Test Corporation provides onsite air quialify testi.pdf
 
The Mars company says that before the introduction of purple.pdf
The Mars company says that before the introduction of purple.pdfThe Mars company says that before the introduction of purple.pdf
The Mars company says that before the introduction of purple.pdf
 
The partial worksheet for the Jamison Company showed the fol.pdf
The partial worksheet for the Jamison Company showed the fol.pdfThe partial worksheet for the Jamison Company showed the fol.pdf
The partial worksheet for the Jamison Company showed the fol.pdf
 
Reference Question In an early meeting with your customer t.pdf
Reference Question In an early meeting with your customer t.pdfReference Question In an early meeting with your customer t.pdf
Reference Question In an early meeting with your customer t.pdf
 
Send answers please Thanks 27 The ANS generally exhibits .pdf
Send answers please Thanks 27 The ANS generally exhibits .pdfSend answers please Thanks 27 The ANS generally exhibits .pdf
Send answers please Thanks 27 The ANS generally exhibits .pdf
 
Suppose a byteaddressable memory contains 2MB and cache con.pdf
Suppose a byteaddressable memory contains 2MB and cache con.pdfSuppose a byteaddressable memory contains 2MB and cache con.pdf
Suppose a byteaddressable memory contains 2MB and cache con.pdf
 
Starting with the SIR model with births and deaths where i.pdf
Starting with the SIR model with births and deaths where  i.pdfStarting with the SIR model with births and deaths where  i.pdf
Starting with the SIR model with births and deaths where i.pdf
 
QUESTION 23 focus on a single product or service and have th.pdf
QUESTION 23 focus on a single product or service and have th.pdfQUESTION 23 focus on a single product or service and have th.pdf
QUESTION 23 focus on a single product or service and have th.pdf
 
begintabularrrl hline multicolumn1r P23 a.pdf
begintabularrrl hline multicolumn1r P23  a.pdfbegintabularrrl hline multicolumn1r P23  a.pdf
begintabularrrl hline multicolumn1r P23 a.pdf
 
Marin Supplies Company sells many different widgets and uses.pdf
Marin Supplies Company sells many different widgets and uses.pdfMarin Supplies Company sells many different widgets and uses.pdf
Marin Supplies Company sells many different widgets and uses.pdf
 
OnBoarding and Training Young Leaders at ECommerce Giant A.pdf
OnBoarding and Training Young Leaders at ECommerce Giant A.pdfOnBoarding and Training Young Leaders at ECommerce Giant A.pdf
OnBoarding and Training Young Leaders at ECommerce Giant A.pdf
 
Note Round to the nearest 1000 th decimal place include .pdf
Note Round to the nearest 1000 th decimal place include .pdfNote Round to the nearest 1000 th decimal place include .pdf
Note Round to the nearest 1000 th decimal place include .pdf
 
Menkes Syndrome is a rare Xlinked disease that affects copp.pdf
Menkes Syndrome is a rare Xlinked disease that affects copp.pdfMenkes Syndrome is a rare Xlinked disease that affects copp.pdf
Menkes Syndrome is a rare Xlinked disease that affects copp.pdf
 
Milano Gallery purchases the copyright on a painting for 42.pdf
Milano Gallery purchases the copyright on a painting for 42.pdfMilano Gallery purchases the copyright on a painting for 42.pdf
Milano Gallery purchases the copyright on a painting for 42.pdf
 

Recently uploaded

When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhleson0603
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxLimon Prince
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17Celine George
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxMarlene Maheu
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptxPoojaSen20
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesPooky Knightsmith
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project researchCaitlinCummins3
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...Nguyen Thanh Tu Collection
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint23600690
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMELOISARIVERA8
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 

Recently uploaded (20)

When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 

This is a follow up question to my unity agents farmer hors.pdf

  • 1. This is a follow up question to my unity agents farmer, horse, pig, chicken. given a farmeragent.cs that was provided will this animalagent.cs work as long as i provide a fooditem script attached to apple, truffle, worm? Basically what Im trying to verify is that my animalagent script will work with the farmeragent script here are the scripts Farmeragent.cs public class FarmerAgent : Agent { public GameObject horse; public GameObject pig; public GameObject chicken; private bool isHorseFed = false; private bool isPigFed = false; private bool isChickenFed = false; public override void AgentReset() { isHorseFed = false; isPigFed = false; isChickenFed = false; } public override void CollectObservations() { // No observations needed for the farmer agent } public override void AgentAction(float[] vectorAction, string textAction) { int action = Mathf.FloorToInt(vectorAction[0]); switch (action) { case 0: DropApple(horse); break; case 1: DropTruffle(pig); break; case 2: DropWorm(chicken); break; } AddReward(-0.01f); } private void DropApple(GameObject animal) { if (animal.GetComponent<AnimalAgent>().preferredFood == Food.Apple) { animal.GetComponent<AnimalAgent>().isFed = true; isHorseFed = true; AddReward(1.0f); } else { AddReward(-1.0f); } } private void DropTruffle(GameObject animal) { if (animal.GetComponent<AnimalAgent>().preferredFood == Food.Truffle) { animal.GetComponent<AnimalAgent>().isFed = true; isPigFed = true; AddReward(1.0f); } else { AddReward(-1.0f); } } private void DropWorm(GameObject animal) { if (animal.GetComponent<AnimalAgent>().preferredFood == Food.Worm) { animal.GetComponent<AnimalAgent>().isFed = true; isChickenFed = true; AddReward(1.0f); } else { AddReward(-1.0f); } } private void OnTriggerEnter(Collider other) { if (other.CompareTag("Wall") || other.CompareTag("Environment")) { AddReward(-0.1f); } } } animalagents.cs public class AnimalAgent : Agent { public Food preferredFood; public bool isFed = false; public override void AgentReset() { isFed = false; } public override void CollectObservations() { // No observations needed for the animal agent } public override void AgentAction(float[] vectorAction, string textAction) { // No actions needed for the animal agent } private void OnTriggerEnter(Collider other) { if (other.CompareTag("Food")) { Food foodType = other.GetComponent<FoodItem>().foodType; if (foodType == preferredFood) { isFed = true; AddReward(1.0f); } else { AddReward(-1.0f); } Destroy(other.gameObject); } else if (other.CompareTag("Wall") || other.CompareTag("Environment")) { AddReward(-0.1f); } } } fooditem.cs public class FoodItem : MonoBehaviour { public Food foodType; }