This commit is contained in:
2024-06-05 16:46:37 +02:00
34 changed files with 207 additions and 291 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,23 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\tosl1\\source\\repos\\Roommapper\\src\\Client\\Mapper\\",
"Documents": [],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": -1,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}"
}
]
}
]
}
]
}

15
src/Client/Mapper/Map.cs Normal file
View File

@@ -0,0 +1,15 @@
using RobotController;
namespace Mapper
{
public class Map
{
private Coordinate bottomLeft, bottomRight;
public Map(Coordinate bottomLeft, Coordinate bottomRight)
{
this.bottomLeft = bottomLeft;
this.bottomRight = bottomRight;
}
}
}

View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\RobotController\RobotController.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,31 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.34916.146
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mapper", "Mapper.csproj", "{52F1797E-0731-43F4-AC45-68B7CF563336}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RobotController", "..\RobotController\RobotController.csproj", "{A753DACA-164C-417C-8AFD-D53AB375A53D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{52F1797E-0731-43F4-AC45-68B7CF563336}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{52F1797E-0731-43F4-AC45-68B7CF563336}.Debug|Any CPU.Build.0 = Debug|Any CPU
{52F1797E-0731-43F4-AC45-68B7CF563336}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52F1797E-0731-43F4-AC45-68B7CF563336}.Release|Any CPU.Build.0 = Release|Any CPU
{A753DACA-164C-417C-8AFD-D53AB375A53D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A753DACA-164C-417C-8AFD-D53AB375A53D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A753DACA-164C-417C-8AFD-D53AB375A53D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A753DACA-164C-417C-8AFD-D53AB375A53D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4759B206-A14D-4659-AAFE-412F937D8E4B}
EndGlobalSection
EndGlobal

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -6,11 +6,11 @@ using System.Threading.Tasks;
namespace RobotController
{
internal class Coordinate
public class Coordinate
{
private int x;
private int y;
private Boolean accesible;
public Coordinate(int x, int y)
{
this.x = x;

View File

@@ -1,13 +0,0 @@
namespace RobotController
{
internal class Map
{
private Coordinate bottomLeft, topRight;
public Map(Coordinate bottomLeft, Coordinate topRight)
{
this.bottomLeft = bottomLeft;
this.topRight = topRight;
}
}
}

View File

@@ -1,22 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AStarPathfinding", "AStarPathfinding\AStarPathfinding.csproj", "{97647F1E-1A0A-444D-A437-A809F9EB855F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{97647F1E-1A0A-444D-A437-A809F9EB855F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{97647F1E-1A0A-444D-A437-A809F9EB855F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{97647F1E-1A0A-444D-A437-A809F9EB855F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{97647F1E-1A0A-444D-A437-A809F9EB855F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -1,59 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{97647F1E-1A0A-444D-A437-A809F9EB855F}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AStarPathfinding</RootNamespace>
<AssemblyName>AStarPathfinding</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>

View File

@@ -1,146 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AStarPathfinding
{
class Location
{
public int X;
public int Y;
public int F;
public int G;
public int H;
public Location Parent;
}
class Program
{
static void Main(string[] args)
{
Console.Title = "A* Pathfinding";
// draw map
string[] map = new string[]
{
"+------+",
"| |",
"|A X |",
"|XXX |",
"| X |",
"| B |",
"| |",
"+------+",
};
foreach (var line in map)
Console.WriteLine(line);
// algorithm
Location current = null;
var start = new Location { X = 1, Y = 2 };
var target = new Location { X = 2, Y = 5 };
var openList = new List<Location>();
var closedList = new List<Location>();
int g = 0;
// start by adding the original position to the open list
openList.Add(start);
while (openList.Count > 0)
{
// get the square with the lowest F score
var lowest = openList.Min(l => l.F);
current = openList.First(l => l.F == lowest);
// add the current square to the closed list
closedList.Add(current);
// show current square on the map
Console.SetCursorPosition(current.X, current.Y);
Console.Write('.');
Console.SetCursorPosition(current.X, current.Y);
System.Threading.Thread.Sleep(1000);
// remove it from the open list
openList.Remove(current);
// if we added the destination to the closed list, we've found a path
if (closedList.FirstOrDefault(l => l.X == target.X && l.Y == target.Y) != null)
break;
var adjacentSquares = GetWalkableAdjacentSquares(current.X, current.Y, map);
g++;
foreach(var adjacentSquare in adjacentSquares)
{
// if this adjacent square is already in the closed list, ignore it
if (closedList.FirstOrDefault(l => l.X == adjacentSquare.X
&& l.Y == adjacentSquare.Y) != null)
continue;
// if it's not in the open list...
if (openList.FirstOrDefault(l => l.X == adjacentSquare.X
&& l.Y == adjacentSquare.Y) == null)
{
// compute its score, set the parent
adjacentSquare.G = g;
adjacentSquare.H = ComputeHScore(adjacentSquare.X, adjacentSquare.Y, target.X, target.Y);
adjacentSquare.F = adjacentSquare.G + adjacentSquare.H;
adjacentSquare.Parent = current;
// and add it to the open list
openList.Insert(0, adjacentSquare);
}
else
{
// test if using the current G score makes the adjacent square's F score
// lower, if yes update the parent because it means it's a better path
if (g + adjacentSquare.H < adjacentSquare.F)
{
adjacentSquare.G = current.G + 1;
adjacentSquare.F = adjacentSquare.G + adjacentSquare.H;
adjacentSquare.Parent = current;
}
}
}
}
// assume path was found; let's show it
while (current != null)
{
Console.SetCursorPosition(current.X, current.Y);
Console.Write('_');
Console.SetCursorPosition(current.X, current.Y);
current = current.Parent;
System.Threading.Thread.Sleep(1000);
}
// end
Console.ReadLine();
}
static List<Location> GetWalkableAdjacentSquares(int x, int y, string[] map)
{
var proposedLocations = new List<Location>()
{
new Location { X = x, Y = y - 1 },
new Location { X = x, Y = y + 1 },
new Location { X = x - 1, Y = y },
new Location { X = x + 1, Y = y },
};
return proposedLocations.Where(l => map[l.Y][l.X] == ' ' || map[l.Y][l.X] == 'B').ToList();
}
static int ComputeHScore(int x, int y, int targetX, int targetY)
{
return Math.Abs(targetX - x) + Math.Abs(targetY - y);
}
}
}

View File

@@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("AStarPathfinding")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AStarPathfinding")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("41c6c38d-e6f0-4437-b8a8-fa0a8ea19eab")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>

View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RoutePlanner
{
internal class Controller
{
private Mapper.Map map;
public void RoutePlanner()
{
}
public void fetchMap()
{
// get map from client
}
public void sendRoute()
{
// send route to client
}
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RoutePlanner
{
internal class Route
{
public Routepoint[] routepoints;
}
}

View File

@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Client\Mapper\Mapper.csproj" />
<ProjectReference Include="..\..\Client\RobotController\RobotController.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,39 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.34916.146
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RoutePlanner", "RoutePlanner.csproj", "{9BEFD90E-D1AB-4E98-A7F3-41577B136144}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D0EC1416-23D0-4A38-8225-5420F2C0A890}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mapper", "..\..\Client\Mapper\Mapper.csproj", "{C9016E3C-4794-4B7A-AA05-070013A2FCBF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RobotController", "..\..\Client\RobotController\RobotController.csproj", "{5CC35547-8E0C-42A2-B1A7-F9AB0B149BAC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9BEFD90E-D1AB-4E98-A7F3-41577B136144}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9BEFD90E-D1AB-4E98-A7F3-41577B136144}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9BEFD90E-D1AB-4E98-A7F3-41577B136144}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9BEFD90E-D1AB-4E98-A7F3-41577B136144}.Release|Any CPU.Build.0 = Release|Any CPU
{C9016E3C-4794-4B7A-AA05-070013A2FCBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C9016E3C-4794-4B7A-AA05-070013A2FCBF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9016E3C-4794-4B7A-AA05-070013A2FCBF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C9016E3C-4794-4B7A-AA05-070013A2FCBF}.Release|Any CPU.Build.0 = Release|Any CPU
{5CC35547-8E0C-42A2-B1A7-F9AB0B149BAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5CC35547-8E0C-42A2-B1A7-F9AB0B149BAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5CC35547-8E0C-42A2-B1A7-F9AB0B149BAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5CC35547-8E0C-42A2-B1A7-F9AB0B149BAC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {330E6F70-8C10-4ADE-BE14-D01EA868D4BB}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,15 @@
using RobotController;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RoutePlanner
{
internal class Routepoint
{
private int step { get; set; }
private Coordinate coordinate { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RoutePlanner
{
internal class Routing
{
}
}