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

Method addAgentToMap

src/EECBSVisualizer.jsx:331–355  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

handleAddAgentMethod · 0.95

Calls 1

showSnackbarMethod · 0.95

Tested by

no test coverage detected