From 099a52e70659c635a475a7934bbb65dc1bd04a06 Mon Sep 17 00:00:00 2001 From: "git@github.com" Date: Sun, 3 Mar 2024 21:08:51 -0500 Subject: [PATCH] rough fix for drone out of range problem --- .../se2aa4/island/team101/AirDecision.java | 14 ++++++++++---- .../ca/mcmaster/se2aa4/island/team101/AreaMap.java | 8 ++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/ca/mcmaster/se2aa4/island/team101/AirDecision.java b/src/main/java/ca/mcmaster/se2aa4/island/team101/AirDecision.java index 2b99e11..b5d8301 100644 --- a/src/main/java/ca/mcmaster/se2aa4/island/team101/AirDecision.java +++ b/src/main/java/ca/mcmaster/se2aa4/island/team101/AirDecision.java @@ -5,13 +5,17 @@ public class AirDecision extends Decision { private Drone drone; //private JSONObject decision = new JSONObject(); - + private static final String FLY = "fly"; + private static final String STOP = "stop"; + private static final String HEADING = "heading"; + private static final String ECHO = "echo"; + private static final String SCAN = "scan"; // Command object Command command = new Command(); - Response response; // will be initialized accordidng to type -> using polymorphism + private int counter = 0; - + private String lastCommand; // use getters from drone to get other relevant info/objects for decision logic // should only need emergency detector and battery through drone // commands cover everything else i think @@ -27,7 +31,7 @@ public String decide() { // not sure how to return strings for turning...maybe need to change heading logic to work // with however you turn in this, if there's a command to turn n/e/s/w, instead of DIY turning // then those commands could be an option to return from here + add to String list in decision - if (counter > 1000){ + if (counter > 20){ // just for the mvp, it checks for land and returns home immediately // ideally, this is put into a method, but since its just temporary, itl just be done in the if statement // need to implement a drone.goHomeCost() or something to figure out when to return, its being simulated by a simple counter for now @@ -41,8 +45,10 @@ public String decide() { //decision.put("action", ECHO); //decision.put("parameters", parameters); command.echo(EAST); + lastCommand = "echo"; } else { + lastCommand = "fly"; command.fly(); } } diff --git a/src/main/java/ca/mcmaster/se2aa4/island/team101/AreaMap.java b/src/main/java/ca/mcmaster/se2aa4/island/team101/AreaMap.java index 93bb77d..dcfb7d7 100644 --- a/src/main/java/ca/mcmaster/se2aa4/island/team101/AreaMap.java +++ b/src/main/java/ca/mcmaster/se2aa4/island/team101/AreaMap.java @@ -1,17 +1,21 @@ package ca.mcmaster.se2aa4.island.team101; import java.util.List; // keep it general ig import java.util.ArrayList; +import java.util.HashMap; public class AreaMap { private List creeks; //ids will be strings I suppose private String emergencySite; - private Tile[][] map; - + List rows = new ArrayList(); + HashMap map = new HashMap(); + public AreaMap(){ this.creeks = new ArrayList(); // implementing it as arraylist but methods will work if u choose to change it here // idk if this is a stupid idea or not or if we should just put it as an arraylist from the start here } + + public void addCreek(String creekID){ creeks.add(creekID); }