MCPcopy Create free account
hub / github.com/StevenLyt/mapf-visualizer / addAgentToMap

Method addAgentToMap

src/MAPFVisualizer.jsx:325–349  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

323 }
324
325 addAgentToMap() {
326 const color = randomColor();
327 var newMap = structuredClone(this.state.map);
328 var i = this.state.addedSRow;
329 var j = this.state.addedSCol;
330 if (newMap[i][j].agent !== -1 || newMap[i][j].isWall) {
331 this.setState({ isError: true }, () => this.showSnackbar(color));
332 return;
333 }
334 newMap[i][j].agent = this.state.numAgents + 1;
335 newMap[i][j].isStart = true;
336 newMap[i][j].color = color;
337
338 i = this.state.addedGRow;
339 j = this.state.addedGCol;
340 if (newMap[i][j].agent !== -1 || newMap[i][j].isWall) {
341 this.setState({ isError: true }, () => this.showSnackbar(color));
342 return;
343 }
344 newMap[i][j].agent = this.state.numAgents + 1;
345 newMap[i][j].isGoal = true;
346 newMap[i][j].color = color;
347
348 this.setState({ map: newMap }, () => this.showSnackbar(color));
349 }
350
351 emptyForm() {
352 this.setState({

Callers 1

handleAddAgentMethod · 0.95

Calls 1

showSnackbarMethod · 0.95

Tested by

no test coverage detected