Skip to content

Commit e94372f

Browse files
authored
Merge pull request #164 from NosCoreIO/AddDotnet6
Add dotnet6
2 parents f817a7e + 59e4bde commit e94372f

11 files changed

Lines changed: 19 additions & 99 deletions

File tree

documentation/brushfire.png

3.77 KB
Loading
3.71 KB
Loading
63 Bytes
Loading

src/NosCore.PathFinder.Gui/NosCore.PathFinder.Gui.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
1818
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
1919
<PackageReference Include="NetEscapades.Configuration.Yaml" Version="2.1.0" />
20-
<PackageReference Include="NosCore.Dao" Version="1.7.4" />
21-
<PackageReference Include="NosCore.Shared" Version="1.14.4" />
20+
<PackageReference Include="NosCore.Dao" Version="2.0.0" />
21+
<PackageReference Include="NosCore.Shared" Version="2.0.0" />
2222
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.0" />
2323
<PackageReference Include="OpenTK.NetStandard" Version="1.0.5.32" />
2424
</ItemGroup>

src/NosCore.PathFinder/Brushfire/IMapGridExtension.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,21 @@ public static BrushFire LoadBrushFire(this IMapGrid mapGrid, (short X, short Y)
3939
return new BrushFire(user, new Dictionary<(short X, short Y), Node?>(), mapGrid.Width, mapGrid.Height);
4040
}
4141

42-
var path = new MinHeap();
42+
var path = new PriorityQueue<Node, double>();
4343
var cellGrid = new Dictionary<(short X, short Y), Node?>();
4444
var grid = new Node?[mapGrid.Width, mapGrid.Height];
4545
grid[user.X, user.Y] = new Node(user, mapGrid[user.X, user.Y])
4646
{
4747
Closed = true
4848
};
49-
path.Push(grid[user.X, user.Y]!);
49+
path.Enqueue(grid[user.X, user.Y]!, 0);
5050
cellGrid[user] = new Node(user, null);
5151

5252
// while the open list is not empty
5353
while (path.Count > 0)
5454
{
5555
// pop the position of Cell which has the minimum `f` value.
56-
var cell = path.Pop();
56+
var cell = path.Dequeue();
5757
cellGrid[cell.Position] ??= new Node(cell.Position, mapGrid[cell.Position.X, cell.Position.Y]);
5858
grid[cell.Position.X, cell.Position.Y] ??= new Node(cell.Position, mapGrid[cell.Position.X, cell.Position.Y]);
5959
grid[cell.Position.X, cell.Position.Y]!.Closed = true;
@@ -78,7 +78,7 @@ public static BrushFire LoadBrushFire(this IMapGrid mapGrid, (short X, short Y)
7878
grid[neighbors[i]!.Position.X, neighbors[i]!.Position.Y] = neighbors[i];
7979
}
8080

81-
path.Push(neighbors[i]!);
81+
path.Enqueue(neighbors[i]!, neighbors[i]!.F);
8282
neighbors[i]!.Closed = true;
8383
}
8484
}

src/NosCore.PathFinder/Brushfire/JumpNode.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,16 @@
88

99
namespace NosCore.PathFinder.Brushfire
1010
{
11-
public class JumpNode : Node, IComparable<JumpNode>
11+
public class JumpNode : Node
1212
{
13-
public JumpNode((short X, short Y) position, double? value)
13+
public JumpNode((short X, short Y) position, double? value) : base(position, value)
1414
{
15-
Value = value;
16-
Position = position;
1715
}
1816

1917
public double G { get; set; }
2018

2119
public double? H { get; set; }
2220

2321
public bool Opened { get; set; }
24-
25-
public int CompareTo(JumpNode? other)
26-
{
27-
return F > other?.F ? 1 : F < other?.F ? -1 : 0;
28-
}
2922
}
3023
}

src/NosCore.PathFinder/Brushfire/MinHeap.cs

Lines changed: 0 additions & 65 deletions
This file was deleted.

src/NosCore.PathFinder/Brushfire/Node.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,14 @@
88

99
namespace NosCore.PathFinder.Brushfire
1010
{
11-
public class Node : IComparable<Node>
11+
public class Node
1212
{
1313
public Node((short X, short Y) position, double? value)
1414
{
1515
Value = value;
1616
Position = position;
1717
}
18-
19-
public Node()
20-
{
21-
}
22-
23-
public int CompareTo(Node? other)
24-
{
25-
return F > other?.F ? 1 : F < other?.F ? -1 : 0;
26-
}
18+
2719
public bool Closed { get; set; }
2820

2921
public Node? Parent { get; set; }

src/NosCore.PathFinder/NosCore.PathFinder.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<RepositoryUrl>https://github.com/NosCoreIO/NosCore.PathFinder.git</RepositoryUrl>
1313
<PackageIconUrl></PackageIconUrl>
1414
<PackageTags>nostale, noscore, nostale private server source, nostale emulator</PackageTags>
15-
<Version>1.0.0</Version>
15+
<Version>1.1.0</Version>
1616
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
1717
<Description>NosCore's PathFinder</Description>
1818
<PackageLicenseExpression></PackageLicenseExpression>

src/NosCore.PathFinder/Pathfinder/JumpPointSearchPathfinder.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ public JumpPointSearchPathfinder(IMapGrid mapGrid, IHeuristic heuristic)
7979
{
8080
var startNode = new JumpNode(start, _mapGrid[start.X, start.Y]) { F = 0, G = 0, Opened = true };
8181
nodes[start.X, start.Y] = startNode;
82-
var heap = new MinHeap();
83-
heap.Push(startNode);
82+
var heap = new PriorityQueue<JumpNode, double>();
83+
heap.Enqueue(startNode, 0);
8484

8585
while (heap.Count != 0)
8686
{
87-
var node = heap.Pop();
87+
var node = heap.Dequeue();
8888
node.Closed = true;
8989
if (node.Position == end)
9090
{
@@ -109,7 +109,7 @@ public JumpPointSearchPathfinder(IMapGrid mapGrid, IHeuristic heuristic)
109109
return path.Select(s => s.Position).ToList();
110110
}
111111

112-
private void IdentifySuccessors(JumpNode node, JumpNode?[,] nodes, (short X, short Y) end, MinHeap heap)
112+
private void IdentifySuccessors(JumpNode node, JumpNode?[,] nodes, (short X, short Y) end, PriorityQueue<JumpNode, double> heap)
113113
{
114114
foreach (var neighbour in _mapGrid.GetNeighbors(node.Position))
115115
{
@@ -143,7 +143,7 @@ private void IdentifySuccessors(JumpNode node, JumpNode?[,] nodes, (short X, sho
143143

144144
if (!jumpNode.Opened)
145145
{
146-
heap.Push(jumpNode);
146+
heap.Enqueue(jumpNode, jumpNode.F);
147147
jumpNode.Opened = true;
148148
}
149149
}

0 commit comments

Comments
 (0)