(e)
| 141 | } |
| 142 | |
| 143 | async requestSolution(e) { |
| 144 | e.preventDefault(); |
| 145 | |
| 146 | if (this.state.agents.length === 0) { |
| 147 | this.setState({ isDialogOpen: true }); |
| 148 | return; |
| 149 | } |
| 150 | |
| 151 | if (this.state.goalToAdd) return; |
| 152 | |
| 153 | this.setState({ isPlanning: true }); |
| 154 | |
| 155 | // change agents to border |
| 156 | this.state.agents.forEach((agent) => { |
| 157 | var color = agent.color; |
| 158 | document.getElementById(`grid-${agent.SR}-${agent.SC}`).style.backgroundColor = "#fff"; |
| 159 | document.getElementById(`grid-${agent.SR}-${agent.SC}`).style.border = `4px solid ${color}`; |
| 160 | document.getElementById(`grid-${agent.GR}-${agent.GC}`).style.backgroundColor = "#fff"; |
| 161 | document.getElementById(`grid-${agent.GR}-${agent.GC}`).style.border = `4px solid ${color}`; |
| 162 | }); |
| 163 | |
| 164 | await new Promise((resolve) => setTimeout(resolve, 1000)); |
| 165 | |
| 166 | var walls = []; |
| 167 | var agents = []; |
| 168 | this.state.map.forEach((row, rowId) => { |
| 169 | row.forEach((grid, gridId) => { |
| 170 | if (grid.isWall) { |
| 171 | walls.push(this.linearizeLocation(rowId, gridId)); |
| 172 | } |
| 173 | }); |
| 174 | }); |
| 175 | this.state.agents.forEach((agent) => { |
| 176 | agents.push({ |
| 177 | startLoc: this.linearizeLocation(agent.SR, agent.SC), |
| 178 | goalLoc: this.linearizeLocation(agent.GR, agent.GC), |
| 179 | }); |
| 180 | }); |
| 181 | |
| 182 | const req = { |
| 183 | method: "POST", |
| 184 | headers: { |
| 185 | // Accept: "application/json", |
| 186 | "Content-Type": "application/json", |
| 187 | }, |
| 188 | body: JSON.stringify({ |
| 189 | row: this.state.numRow, |
| 190 | col: this.state.numCol, |
| 191 | walls: walls, |
| 192 | agents: agents, |
| 193 | heuristic: this.state.heuristics[this.state.whichHeuristic], |
| 194 | isBypass: this.state.isBypass, |
| 195 | isPrioritizeConflict: this.state.isPrioritizeConflict, |
| 196 | isDisjointSplitting: this.state.isDisjointSplitting, |
| 197 | isTarget: this.state.isTarget, |
| 198 | solver: this.state.highLevelSolvers[this.state.whichSolver], |
| 199 | inadmissibleHeuristic: |
| 200 | this.state.inadmissibleHeuristics[this.state.whichInadmissibleHeuristic], |
no test coverage detected