Calculating Slots hit with AOE in a 4x3 Array2019 Community Moderator ElectionSimple Cluster algorithm 2D. Detecting clumps of pointsHow do I calculate someone's age in C#?Calculate relative time in C#Creating a byte array from a streamHow do you convert a byte array to a hexadecimal string, and vice versa?Best way to implement keyboard shortcuts in a Windows Forms application?Calculate difference between two dates (number of days)?How do I remedy the “The breakpoint will not currently be hit. No symbols have been loaded for this document.” warning?Program takes too much memoryCalculate the execution time of a methodC# - Loop ending result
Why is the President allowed to veto a cancellation of emergency powers?
Why does a Star of David appear at a rally with Francisco Franco?
Are ETF trackers fundamentally better than individual stocks?
World War I as a war of liberals against authoritarians?
How do I hide Chekhov's Gun?
Happy pi day, everyone!
PTIJ: Who should I vote for? (21st Knesset Edition)
Brexit - No Deal Rejection
What is "focus distance lower/upper" and how is it different from depth of field?
Why Choose Less Effective Armour Types?
Adventure Game (text based) in C++
Examples of transfinite towers
How to terminate ping <dest> &
What options are left, if Britain cannot decide?
Is there a place to find the pricing for things not mentioned in the PHB? (non-magical)
How to pronounce "I ♥ Huckabees"?
A single argument pattern definition applies to multiple-argument patterns?
Why do passenger jet manufacturers design their planes with stall prevention systems?
A diagram about partial derivatives of f(x,y)
How to plot polar formed complex numbers?
What's the meaning of a knight fighting a snail in medieval book illustrations?
Do I need life insurance if I can cover my own funeral costs?
Is it true that good novels will automatically sell themselves on Amazon (and so on) and there is no need for one to waste time promoting?
Why do newer 737s use two different styles of split winglets?
Calculating Slots hit with AOE in a 4x3 Array
2019 Community Moderator ElectionSimple Cluster algorithm 2D. Detecting clumps of pointsHow do I calculate someone's age in C#?Calculate relative time in C#Creating a byte array from a streamHow do you convert a byte array to a hexadecimal string, and vice versa?Best way to implement keyboard shortcuts in a Windows Forms application?Calculate difference between two dates (number of days)?How do I remedy the “The breakpoint will not currently be hit. No symbols have been loaded for this document.” warning?Program takes too much memoryCalculate the execution time of a methodC# - Loop ending result
I'm not exactly what terminology to even use to look this up, and I figure the best way to explain it is with an example image.
I have a game field made up of 12 (numbered 1-12) slots, 4 wide and 3 deep, I need to be able to take the main slot number hit and get the numbers of its neighboring slots for an Area of Effect system.
c#
|
show 1 more comment
I'm not exactly what terminology to even use to look this up, and I figure the best way to explain it is with an example image.
I have a game field made up of 12 (numbered 1-12) slots, 4 wide and 3 deep, I need to be able to take the main slot number hit and get the numbers of its neighboring slots for an Area of Effect system.
c#
2
include relevant code..
– Matt.G
Mar 6 at 20:54
Did you read the description of[slots]
before you tagged your question with that tag. It's some sort of Python feature
– Flydog57
Mar 6 at 20:55
I don't think my code is relevant in this case. Let's just assume I generate a random number from 1-12 and it picks 6. How would I go about getting slot 6's neighboring slots as shown in the included image? Some fancy multidimensional array business I'm assuming.
– user3882530
Mar 6 at 21:02
Have you done any research? I searched for "area of effect" implementation and found Simple Cluster algorithm 2D. Detecting clumps of points, which sounds pretty close...
– Heretic Monkey
Mar 6 at 21:06
instead consider creating a slot class which has a row and column property to identify the slot position. all 12 slots will be stored inslots
variable of type List<Slot>. Now, slot "6" is at row 1, column 1 (index starting at 0). then slots in the "Area of Effect" could be all slots in the list that are at (row -1, col), (row + 1, col), (row, col - 1), (row, col + 1), (row -1, col -1) (row + 1, col -1), (row - 1, col + 1) and (row + 1, col + 1)
– Matt.G
Mar 6 at 21:10
|
show 1 more comment
I'm not exactly what terminology to even use to look this up, and I figure the best way to explain it is with an example image.
I have a game field made up of 12 (numbered 1-12) slots, 4 wide and 3 deep, I need to be able to take the main slot number hit and get the numbers of its neighboring slots for an Area of Effect system.
c#
I'm not exactly what terminology to even use to look this up, and I figure the best way to explain it is with an example image.
I have a game field made up of 12 (numbered 1-12) slots, 4 wide and 3 deep, I need to be able to take the main slot number hit and get the numbers of its neighboring slots for an Area of Effect system.
c#
c#
edited Mar 6 at 21:01
Heretic Monkey
6,57263571
6,57263571
asked Mar 6 at 20:52
user3882530user3882530
11
11
2
include relevant code..
– Matt.G
Mar 6 at 20:54
Did you read the description of[slots]
before you tagged your question with that tag. It's some sort of Python feature
– Flydog57
Mar 6 at 20:55
I don't think my code is relevant in this case. Let's just assume I generate a random number from 1-12 and it picks 6. How would I go about getting slot 6's neighboring slots as shown in the included image? Some fancy multidimensional array business I'm assuming.
– user3882530
Mar 6 at 21:02
Have you done any research? I searched for "area of effect" implementation and found Simple Cluster algorithm 2D. Detecting clumps of points, which sounds pretty close...
– Heretic Monkey
Mar 6 at 21:06
instead consider creating a slot class which has a row and column property to identify the slot position. all 12 slots will be stored inslots
variable of type List<Slot>. Now, slot "6" is at row 1, column 1 (index starting at 0). then slots in the "Area of Effect" could be all slots in the list that are at (row -1, col), (row + 1, col), (row, col - 1), (row, col + 1), (row -1, col -1) (row + 1, col -1), (row - 1, col + 1) and (row + 1, col + 1)
– Matt.G
Mar 6 at 21:10
|
show 1 more comment
2
include relevant code..
– Matt.G
Mar 6 at 20:54
Did you read the description of[slots]
before you tagged your question with that tag. It's some sort of Python feature
– Flydog57
Mar 6 at 20:55
I don't think my code is relevant in this case. Let's just assume I generate a random number from 1-12 and it picks 6. How would I go about getting slot 6's neighboring slots as shown in the included image? Some fancy multidimensional array business I'm assuming.
– user3882530
Mar 6 at 21:02
Have you done any research? I searched for "area of effect" implementation and found Simple Cluster algorithm 2D. Detecting clumps of points, which sounds pretty close...
– Heretic Monkey
Mar 6 at 21:06
instead consider creating a slot class which has a row and column property to identify the slot position. all 12 slots will be stored inslots
variable of type List<Slot>. Now, slot "6" is at row 1, column 1 (index starting at 0). then slots in the "Area of Effect" could be all slots in the list that are at (row -1, col), (row + 1, col), (row, col - 1), (row, col + 1), (row -1, col -1) (row + 1, col -1), (row - 1, col + 1) and (row + 1, col + 1)
– Matt.G
Mar 6 at 21:10
2
2
include relevant code..
– Matt.G
Mar 6 at 20:54
include relevant code..
– Matt.G
Mar 6 at 20:54
Did you read the description of
[slots]
before you tagged your question with that tag. It's some sort of Python feature– Flydog57
Mar 6 at 20:55
Did you read the description of
[slots]
before you tagged your question with that tag. It's some sort of Python feature– Flydog57
Mar 6 at 20:55
I don't think my code is relevant in this case. Let's just assume I generate a random number from 1-12 and it picks 6. How would I go about getting slot 6's neighboring slots as shown in the included image? Some fancy multidimensional array business I'm assuming.
– user3882530
Mar 6 at 21:02
I don't think my code is relevant in this case. Let's just assume I generate a random number from 1-12 and it picks 6. How would I go about getting slot 6's neighboring slots as shown in the included image? Some fancy multidimensional array business I'm assuming.
– user3882530
Mar 6 at 21:02
Have you done any research? I searched for "area of effect" implementation and found Simple Cluster algorithm 2D. Detecting clumps of points, which sounds pretty close...
– Heretic Monkey
Mar 6 at 21:06
Have you done any research? I searched for "area of effect" implementation and found Simple Cluster algorithm 2D. Detecting clumps of points, which sounds pretty close...
– Heretic Monkey
Mar 6 at 21:06
instead consider creating a slot class which has a row and column property to identify the slot position. all 12 slots will be stored in
slots
variable of type List<Slot>. Now, slot "6" is at row 1, column 1 (index starting at 0). then slots in the "Area of Effect" could be all slots in the list that are at (row -1, col), (row + 1, col), (row, col - 1), (row, col + 1), (row -1, col -1) (row + 1, col -1), (row - 1, col + 1) and (row + 1, col + 1)– Matt.G
Mar 6 at 21:10
instead consider creating a slot class which has a row and column property to identify the slot position. all 12 slots will be stored in
slots
variable of type List<Slot>. Now, slot "6" is at row 1, column 1 (index starting at 0). then slots in the "Area of Effect" could be all slots in the list that are at (row -1, col), (row + 1, col), (row, col - 1), (row, col + 1), (row -1, col -1) (row + 1, col -1), (row - 1, col + 1) and (row + 1, col + 1)– Matt.G
Mar 6 at 21:10
|
show 1 more comment
1 Answer
1
active
oldest
votes
Here's one sample implementation, but it may not work depending on how you're storing your data. The first part just creates the array, then the second part asks the user to select a number so we can highlight it and it's neighbors.
All we have to do is check if the current row is within 1
of the selected row, and if the current column is within 1
of the selected column, and hightlight that square (because it'a a neighbor). Of course if both the row and column match, then we highlight that a little differently since that's the number they chose:
private static void Main(string[] args)
var rowCount = 4;
var colCount = 3;
var slots = new int[rowCount, colCount];
// Populate the grid
for (int i = 0; i < rowCount * colCount; i++)
var col = i / rowCount;
var row = i % rowCount;
slots[row, col] = i + 1;
// Print the grid
for (int row = 0; row < rowCount; row++)
for (int col = 0; col < colCount; col++)
Console.Write($" slots[row, col]");
Console.WriteLine();
// Ask the user to select a number from the grid
var chosenNumber = GetIntFromUser("nSelect a number: ",
x => x > 0 && x < rowCount * colCount);
// Get the coordinates of that selected number
var selCol = (chosenNumber - 1) / 4;
var selRow = (chosenNumber - 1) % 4;
// Print the grid, highlighting their
// selected number and it's neighbors
Console.WriteLine();
for (int row = 0; row < rowCount; row++)
for (int col = 0; col < colCount; col++)
if (row == selRow && col == selCol)
Console.BackgroundColor = ConsoleColor.White;
Console.ForegroundColor = ConsoleColor.Red;
else if (row >= selRow - 1 && row <= selRow + 1 &&
col >= selCol - 1 && col <= selCol + 1)
Console.BackgroundColor = ConsoleColor.Gray;
Console.ForegroundColor = ConsoleColor.Blue;
else
Console.ResetColor();
Console.Write($" slots[row, col]");
Console.WriteLine();
GetKeyFromUser("nDone! Press any key to exit...");
Output
Oh,and the helper function I used to get a valid number is:
private static int GetIntFromUser(string prompt, Func<int, bool> validator = null)
!(validator?.Invoke(result) ?? true));
return result;
This was very kind of you. Only critique would be to use constants for your table sizes as right now it is very magical.
– Michael Dorgan
Mar 6 at 22:04
@MichaelDorgan good point, updated sample.
– Rufus L
Mar 6 at 22:46
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55031933%2fcalculating-slots-hit-with-aoe-in-a-4x3-array%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here's one sample implementation, but it may not work depending on how you're storing your data. The first part just creates the array, then the second part asks the user to select a number so we can highlight it and it's neighbors.
All we have to do is check if the current row is within 1
of the selected row, and if the current column is within 1
of the selected column, and hightlight that square (because it'a a neighbor). Of course if both the row and column match, then we highlight that a little differently since that's the number they chose:
private static void Main(string[] args)
var rowCount = 4;
var colCount = 3;
var slots = new int[rowCount, colCount];
// Populate the grid
for (int i = 0; i < rowCount * colCount; i++)
var col = i / rowCount;
var row = i % rowCount;
slots[row, col] = i + 1;
// Print the grid
for (int row = 0; row < rowCount; row++)
for (int col = 0; col < colCount; col++)
Console.Write($" slots[row, col]");
Console.WriteLine();
// Ask the user to select a number from the grid
var chosenNumber = GetIntFromUser("nSelect a number: ",
x => x > 0 && x < rowCount * colCount);
// Get the coordinates of that selected number
var selCol = (chosenNumber - 1) / 4;
var selRow = (chosenNumber - 1) % 4;
// Print the grid, highlighting their
// selected number and it's neighbors
Console.WriteLine();
for (int row = 0; row < rowCount; row++)
for (int col = 0; col < colCount; col++)
if (row == selRow && col == selCol)
Console.BackgroundColor = ConsoleColor.White;
Console.ForegroundColor = ConsoleColor.Red;
else if (row >= selRow - 1 && row <= selRow + 1 &&
col >= selCol - 1 && col <= selCol + 1)
Console.BackgroundColor = ConsoleColor.Gray;
Console.ForegroundColor = ConsoleColor.Blue;
else
Console.ResetColor();
Console.Write($" slots[row, col]");
Console.WriteLine();
GetKeyFromUser("nDone! Press any key to exit...");
Output
Oh,and the helper function I used to get a valid number is:
private static int GetIntFromUser(string prompt, Func<int, bool> validator = null)
!(validator?.Invoke(result) ?? true));
return result;
This was very kind of you. Only critique would be to use constants for your table sizes as right now it is very magical.
– Michael Dorgan
Mar 6 at 22:04
@MichaelDorgan good point, updated sample.
– Rufus L
Mar 6 at 22:46
add a comment |
Here's one sample implementation, but it may not work depending on how you're storing your data. The first part just creates the array, then the second part asks the user to select a number so we can highlight it and it's neighbors.
All we have to do is check if the current row is within 1
of the selected row, and if the current column is within 1
of the selected column, and hightlight that square (because it'a a neighbor). Of course if both the row and column match, then we highlight that a little differently since that's the number they chose:
private static void Main(string[] args)
var rowCount = 4;
var colCount = 3;
var slots = new int[rowCount, colCount];
// Populate the grid
for (int i = 0; i < rowCount * colCount; i++)
var col = i / rowCount;
var row = i % rowCount;
slots[row, col] = i + 1;
// Print the grid
for (int row = 0; row < rowCount; row++)
for (int col = 0; col < colCount; col++)
Console.Write($" slots[row, col]");
Console.WriteLine();
// Ask the user to select a number from the grid
var chosenNumber = GetIntFromUser("nSelect a number: ",
x => x > 0 && x < rowCount * colCount);
// Get the coordinates of that selected number
var selCol = (chosenNumber - 1) / 4;
var selRow = (chosenNumber - 1) % 4;
// Print the grid, highlighting their
// selected number and it's neighbors
Console.WriteLine();
for (int row = 0; row < rowCount; row++)
for (int col = 0; col < colCount; col++)
if (row == selRow && col == selCol)
Console.BackgroundColor = ConsoleColor.White;
Console.ForegroundColor = ConsoleColor.Red;
else if (row >= selRow - 1 && row <= selRow + 1 &&
col >= selCol - 1 && col <= selCol + 1)
Console.BackgroundColor = ConsoleColor.Gray;
Console.ForegroundColor = ConsoleColor.Blue;
else
Console.ResetColor();
Console.Write($" slots[row, col]");
Console.WriteLine();
GetKeyFromUser("nDone! Press any key to exit...");
Output
Oh,and the helper function I used to get a valid number is:
private static int GetIntFromUser(string prompt, Func<int, bool> validator = null)
!(validator?.Invoke(result) ?? true));
return result;
This was very kind of you. Only critique would be to use constants for your table sizes as right now it is very magical.
– Michael Dorgan
Mar 6 at 22:04
@MichaelDorgan good point, updated sample.
– Rufus L
Mar 6 at 22:46
add a comment |
Here's one sample implementation, but it may not work depending on how you're storing your data. The first part just creates the array, then the second part asks the user to select a number so we can highlight it and it's neighbors.
All we have to do is check if the current row is within 1
of the selected row, and if the current column is within 1
of the selected column, and hightlight that square (because it'a a neighbor). Of course if both the row and column match, then we highlight that a little differently since that's the number they chose:
private static void Main(string[] args)
var rowCount = 4;
var colCount = 3;
var slots = new int[rowCount, colCount];
// Populate the grid
for (int i = 0; i < rowCount * colCount; i++)
var col = i / rowCount;
var row = i % rowCount;
slots[row, col] = i + 1;
// Print the grid
for (int row = 0; row < rowCount; row++)
for (int col = 0; col < colCount; col++)
Console.Write($" slots[row, col]");
Console.WriteLine();
// Ask the user to select a number from the grid
var chosenNumber = GetIntFromUser("nSelect a number: ",
x => x > 0 && x < rowCount * colCount);
// Get the coordinates of that selected number
var selCol = (chosenNumber - 1) / 4;
var selRow = (chosenNumber - 1) % 4;
// Print the grid, highlighting their
// selected number and it's neighbors
Console.WriteLine();
for (int row = 0; row < rowCount; row++)
for (int col = 0; col < colCount; col++)
if (row == selRow && col == selCol)
Console.BackgroundColor = ConsoleColor.White;
Console.ForegroundColor = ConsoleColor.Red;
else if (row >= selRow - 1 && row <= selRow + 1 &&
col >= selCol - 1 && col <= selCol + 1)
Console.BackgroundColor = ConsoleColor.Gray;
Console.ForegroundColor = ConsoleColor.Blue;
else
Console.ResetColor();
Console.Write($" slots[row, col]");
Console.WriteLine();
GetKeyFromUser("nDone! Press any key to exit...");
Output
Oh,and the helper function I used to get a valid number is:
private static int GetIntFromUser(string prompt, Func<int, bool> validator = null)
!(validator?.Invoke(result) ?? true));
return result;
Here's one sample implementation, but it may not work depending on how you're storing your data. The first part just creates the array, then the second part asks the user to select a number so we can highlight it and it's neighbors.
All we have to do is check if the current row is within 1
of the selected row, and if the current column is within 1
of the selected column, and hightlight that square (because it'a a neighbor). Of course if both the row and column match, then we highlight that a little differently since that's the number they chose:
private static void Main(string[] args)
var rowCount = 4;
var colCount = 3;
var slots = new int[rowCount, colCount];
// Populate the grid
for (int i = 0; i < rowCount * colCount; i++)
var col = i / rowCount;
var row = i % rowCount;
slots[row, col] = i + 1;
// Print the grid
for (int row = 0; row < rowCount; row++)
for (int col = 0; col < colCount; col++)
Console.Write($" slots[row, col]");
Console.WriteLine();
// Ask the user to select a number from the grid
var chosenNumber = GetIntFromUser("nSelect a number: ",
x => x > 0 && x < rowCount * colCount);
// Get the coordinates of that selected number
var selCol = (chosenNumber - 1) / 4;
var selRow = (chosenNumber - 1) % 4;
// Print the grid, highlighting their
// selected number and it's neighbors
Console.WriteLine();
for (int row = 0; row < rowCount; row++)
for (int col = 0; col < colCount; col++)
if (row == selRow && col == selCol)
Console.BackgroundColor = ConsoleColor.White;
Console.ForegroundColor = ConsoleColor.Red;
else if (row >= selRow - 1 && row <= selRow + 1 &&
col >= selCol - 1 && col <= selCol + 1)
Console.BackgroundColor = ConsoleColor.Gray;
Console.ForegroundColor = ConsoleColor.Blue;
else
Console.ResetColor();
Console.Write($" slots[row, col]");
Console.WriteLine();
GetKeyFromUser("nDone! Press any key to exit...");
Output
Oh,and the helper function I used to get a valid number is:
private static int GetIntFromUser(string prompt, Func<int, bool> validator = null)
!(validator?.Invoke(result) ?? true));
return result;
edited Mar 6 at 22:51
answered Mar 6 at 21:30
Rufus LRufus L
19k31732
19k31732
This was very kind of you. Only critique would be to use constants for your table sizes as right now it is very magical.
– Michael Dorgan
Mar 6 at 22:04
@MichaelDorgan good point, updated sample.
– Rufus L
Mar 6 at 22:46
add a comment |
This was very kind of you. Only critique would be to use constants for your table sizes as right now it is very magical.
– Michael Dorgan
Mar 6 at 22:04
@MichaelDorgan good point, updated sample.
– Rufus L
Mar 6 at 22:46
This was very kind of you. Only critique would be to use constants for your table sizes as right now it is very magical.
– Michael Dorgan
Mar 6 at 22:04
This was very kind of you. Only critique would be to use constants for your table sizes as right now it is very magical.
– Michael Dorgan
Mar 6 at 22:04
@MichaelDorgan good point, updated sample.
– Rufus L
Mar 6 at 22:46
@MichaelDorgan good point, updated sample.
– Rufus L
Mar 6 at 22:46
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55031933%2fcalculating-slots-hit-with-aoe-in-a-4x3-array%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
include relevant code..
– Matt.G
Mar 6 at 20:54
Did you read the description of
[slots]
before you tagged your question with that tag. It's some sort of Python feature– Flydog57
Mar 6 at 20:55
I don't think my code is relevant in this case. Let's just assume I generate a random number from 1-12 and it picks 6. How would I go about getting slot 6's neighboring slots as shown in the included image? Some fancy multidimensional array business I'm assuming.
– user3882530
Mar 6 at 21:02
Have you done any research? I searched for "area of effect" implementation and found Simple Cluster algorithm 2D. Detecting clumps of points, which sounds pretty close...
– Heretic Monkey
Mar 6 at 21:06
instead consider creating a slot class which has a row and column property to identify the slot position. all 12 slots will be stored in
slots
variable of type List<Slot>. Now, slot "6" is at row 1, column 1 (index starting at 0). then slots in the "Area of Effect" could be all slots in the list that are at (row -1, col), (row + 1, col), (row, col - 1), (row, col + 1), (row -1, col -1) (row + 1, col -1), (row - 1, col + 1) and (row + 1, col + 1)– Matt.G
Mar 6 at 21:10