Advertisement
OverSkillers

Untitled

Apr 2nd, 2019
555
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using DeepCopyExtensions;
  6.  
  7. public class UtilityFunction
  8. {
  9.  
  10. public float evaluate(State s)
  11. {
  12. /////////////////
  13. // You should implement these
  14. /////////////////
  15.  
  16. List<Unit> theirUnits = s.AdversaryUnits;
  17. float theirHealth = 0.0F;
  18. foreach (Unit unit in theirUnits)
  19. {
  20. theirHealth += unit.hp;
  21. }
  22.  
  23. if (theirHealth == 0)
  24. {
  25. return Int32.MaxValue;
  26. }
  27.  
  28. List<Unit> ourUnits = s.PlayersUnits;
  29. float ourHealth = 0.0F;
  30. foreach (Unit unit in ourUnits){
  31. ourHealth += unit.hp;
  32. }
  33.  
  34. if (ourHealth == 0){
  35. return Int32.MinValue;
  36. }
  37.  
  38. return 0;
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement