In the mystical land of Mythos, creatures from various realms come together to battle in the Gridlock Arena, a chess-like grid where strategy, power, and cunning are tested. Each creature has its unique move, power, and strategy.
Your task is to simulate a battle in the Gridlock Arena. Each creature will make a series of moves, and after each move, the creature might inflict damage on its opponent if they land on the same square. The goal is to accumulate the highest score by the end of the battle. To track the progress of the battle, visualize the grid after each move and display the current scores right below the grid.
Creature Data:
Name | Start | Moves | Power | Icon |
---|---|---|---|---|
Dragon | 2,2 | RIGHT, LEFT, DOWN | 7 | 🐉 |
Goblin | 2,3 | LEFT, RIGHT, UP | 3 | 👺 |
Ogre | 0,0 | RIGHT, DOWN, DOWN | 5 | 👹 |
At the end of the battle, return the total points each creature accumulated.
creatures
array containing the creature details.directions
object to map the movement directions to their respective changes in coordinates.grid
) with all cells initialized to null
.creatures
array.scores
object.move
is -1), render the grid.See if you can use Copilot to find out the complexity (BigO notation) of the code.
Open the GitHub Copilot Chat view in the sidebar if it’s not already open. Make sure your solution file is still open as well.
Ask Copilot Chat what the complexity of the code is.
Ask Copilot Chat to make the code more efficient.
Ask for the complexity again - is it better?
Highlight all of the code with Ctrl/Cmd+A.
Press Ctrl/Cmd+I to open the inline chat.
Type “/doc”
Ask Copilot Chat to document the function.
Open GitHub Copilot Chat in the sidebar.
Type “/simplify” and press Enter. You can also add any text you want after the “/simplify” to give Copilot more instructions.
What did Copilot Chat suggest you do to make it simpler?
Copilot Chat can help with that too! Just copy the error message and paste it into Chat. Often that’s all Copilot needs to resolve your issue.