-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethods.cs
More file actions
31 lines (26 loc) · 849 Bytes
/
Methods.cs
File metadata and controls
31 lines (26 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Collections.Generic;
using System.Linq;
namespace Astarfrompsuedo
{
class methods
{
public static Node newnode(int x, int y)
{
Node toreturn = new Node();
toreturn.X = x;
toreturn.Y = y;
return toreturn;
}
public static List<Node> GetNeighbours(int x, int y, string[] map)
{
List<Node> possiblelocations = new List<Node>()
{newnode( x, y - 1 ),newnode(x,y + 1),newnode(x - 1,y),newnode (x + 1,y )};
return possiblelocations.Where(l => map[l.Y][l.X] == ' ' || map[l.Y][l.X] == 'B').ToList();
}
public static int GetH(int x, int y, int targetX, int targetY)
{
return (targetX - x) + (targetY - y);
}
}
}