From 2915fec180a3eacc9db9e7317514c811a6c974ad Mon Sep 17 00:00:00 2001 From: htamas1210 Date: Mon, 10 Mar 2025 10:38:51 +0100 Subject: [PATCH] csucs class --- ora1gyak/Keres.cs | 78 +++++++++++++++--- .../obj/Debug/net8.0/ora1gyak.assets.cache | Bin 147 -> 147 bytes .../ora1gyak.csproj.FileListAbsolute.txt | 14 ++++ .../obj/ora1gyak.csproj.nuget.dgspec.json | 10 +-- ora1gyak/obj/project.assets.json | 6 +- ora1gyak/obj/project.nuget.cache | 4 +- 6 files changed, 92 insertions(+), 20 deletions(-) diff --git a/ora1gyak/Keres.cs b/ora1gyak/Keres.cs index bf2384b..78f6dee 100644 --- a/ora1gyak/Keres.cs +++ b/ora1gyak/Keres.cs @@ -2,29 +2,87 @@ using System; using System.Collections.Generic; using System.Linq; -namespace Keres{ - abstract class Feladat { +namespace Keres +{ + public class Feladat + { public T Kezdo { get; } - public T Cel{ get; protected set;} + public T Cel { get; protected set; } - public Feladat(T kezdo, T cel){ + public Feladat(T kezdo, T cel) + { Kezdo = kezdo; Cel = cel; } - public virtual bool Celteszt(T allapot){ + public virtual bool Celteszt(T allapot) + { return EqualityComparer.Default.Equals(allapot, Cel); } - public abstract IEnumerable<(string, T)> Rakovetkezo(T allapot); + public virtual IEnumerable<(string, T)> Rakovetkezo(T allapot){ + throw new NotImplementedException(); + } - public virtual int Utkoltseg(int c, T allapot1, string lepes, T allapot2){ - return c+1; + public virtual int Utkoltseg(int c, T allapot1, string lepes, T allapot2) + { + return c + 1; } } - public class Csucs{ - + public class Csucs + { + public T Allapot { get; } // The state of this node + public Csucs? Szulo { get; } // Parent node + public string? Lepes { get; } // Action taken to reach this node + public int Utkoltseg { get; } // Path cost (g(n)) + public int Melyseg { get; } // Depth in the tree + + + public Csucs(T allapot, Csucs? szulo = null, string? lepes = null, int utkoltseg = 0) + { + Allapot = allapot; + Szulo = szulo; + Lepes = lepes; + Utkoltseg = utkoltseg; + Melyseg = szulo?.Melyseg + 1 ?? 0; + } + + public override string ToString() + { + return $""; + } + + /// + /// Returns the path from the root to this node. + /// + public List> Ut(){ + List> valasz = new List>(); + + for(Csucs? x = this; x != null; x = x.Szulo){ + valasz.Add(x); + } + + valasz.Reverse(); + + return valasz; + } + + + /// + /// Returns the sequence of steps taken to reach this node. + /// + public List Megoldas(){ + return Ut().Skip(1).Select(csucs => csucs.Lepes).ToList(); + } + + public IEnumerable> Kiterjeszt(Feladat feladat){ + foreach(var (muvelet, kovetkezo) in feladat.Rakovetkezo(Allapot)){ + if(!Ut().Select(csucs => csucs.Allapot).Contains(kovetkezo)){ + yield return new Csucs(kovetkezo, this, muvelet, feladat.Utkoltseg(Utkoltseg, Allapot, muvelet, kovetkezo)); + } + } + } } } \ No newline at end of file diff --git a/ora1gyak/obj/Debug/net8.0/ora1gyak.assets.cache b/ora1gyak/obj/Debug/net8.0/ora1gyak.assets.cache index 4a075378057287d5d31419d42d9c916ea8beafc2..38692a78193e71a9c774c6d8a14d5f6c4bffbeb2 100644 GIT binary patch delta 55 zcmV-70LcH70h0kKP)kQa3;+NC+2uZ!pi=mLNByHT)LDWZ-nf~jbkXd@(%=5J%Ybzp NkC8DWkw6HMR6n3=8QlN? delta 55 zcmV-70LcH70h0kKP)kQa3;+NCArII7YBHJM2Z@8Ty~XvnEzLN8^qq?V0ScC#KoKdk NkC8DWkw6HMR6ja%6*vF@ diff --git a/ora1gyak/obj/Debug/net8.0/ora1gyak.csproj.FileListAbsolute.txt b/ora1gyak/obj/Debug/net8.0/ora1gyak.csproj.FileListAbsolute.txt index e69de29..fe77266 100644 --- a/ora1gyak/obj/Debug/net8.0/ora1gyak.csproj.FileListAbsolute.txt +++ b/ora1gyak/obj/Debug/net8.0/ora1gyak.csproj.FileListAbsolute.txt @@ -0,0 +1,14 @@ +/home/tom/Dev/MestInt/ora1gyak/obj/Debug/net8.0/ora1gyak.GeneratedMSBuildEditorConfig.editorconfig +/home/tom/Dev/MestInt/ora1gyak/obj/Debug/net8.0/ora1gyak.AssemblyInfoInputs.cache +/home/tom/Dev/MestInt/ora1gyak/obj/Debug/net8.0/ora1gyak.AssemblyInfo.cs +/home/tom/Dev/MestInt/ora1gyak/obj/Debug/net8.0/ora1gyak.csproj.CoreCompileInputs.cache +/home/tom/Dev/MestInt/ora1gyak/bin/Debug/net8.0/ora1gyak +/home/tom/Dev/MestInt/ora1gyak/bin/Debug/net8.0/ora1gyak.deps.json +/home/tom/Dev/MestInt/ora1gyak/bin/Debug/net8.0/ora1gyak.runtimeconfig.json +/home/tom/Dev/MestInt/ora1gyak/bin/Debug/net8.0/ora1gyak.dll +/home/tom/Dev/MestInt/ora1gyak/bin/Debug/net8.0/ora1gyak.pdb +/home/tom/Dev/MestInt/ora1gyak/obj/Debug/net8.0/ora1gyak.dll +/home/tom/Dev/MestInt/ora1gyak/obj/Debug/net8.0/refint/ora1gyak.dll +/home/tom/Dev/MestInt/ora1gyak/obj/Debug/net8.0/ora1gyak.pdb +/home/tom/Dev/MestInt/ora1gyak/obj/Debug/net8.0/ora1gyak.genruntimeconfig.cache +/home/tom/Dev/MestInt/ora1gyak/obj/Debug/net8.0/ref/ora1gyak.dll diff --git a/ora1gyak/obj/ora1gyak.csproj.nuget.dgspec.json b/ora1gyak/obj/ora1gyak.csproj.nuget.dgspec.json index 556bf91..c07ce58 100644 --- a/ora1gyak/obj/ora1gyak.csproj.nuget.dgspec.json +++ b/ora1gyak/obj/ora1gyak.csproj.nuget.dgspec.json @@ -1,17 +1,17 @@ { "format": 1, "restore": { - "/home/tom/Dev/mestint/ora1gyak/ora1gyak.csproj": {} + "/home/tom/Dev/MestInt/ora1gyak/ora1gyak.csproj": {} }, "projects": { - "/home/tom/Dev/mestint/ora1gyak/ora1gyak.csproj": { + "/home/tom/Dev/MestInt/ora1gyak/ora1gyak.csproj": { "version": "1.0.0", "restore": { - "projectUniqueName": "/home/tom/Dev/mestint/ora1gyak/ora1gyak.csproj", + "projectUniqueName": "/home/tom/Dev/MestInt/ora1gyak/ora1gyak.csproj", "projectName": "ora1gyak", - "projectPath": "/home/tom/Dev/mestint/ora1gyak/ora1gyak.csproj", + "projectPath": "/home/tom/Dev/MestInt/ora1gyak/ora1gyak.csproj", "packagesPath": "/home/tom/.nuget/packages/", - "outputPath": "/home/tom/Dev/mestint/ora1gyak/obj/", + "outputPath": "/home/tom/Dev/MestInt/ora1gyak/obj/", "projectStyle": "PackageReference", "configFilePaths": [ "/home/tom/.nuget/NuGet/NuGet.Config" diff --git a/ora1gyak/obj/project.assets.json b/ora1gyak/obj/project.assets.json index 73d64d5..73b0811 100644 --- a/ora1gyak/obj/project.assets.json +++ b/ora1gyak/obj/project.assets.json @@ -13,11 +13,11 @@ "project": { "version": "1.0.0", "restore": { - "projectUniqueName": "/home/tom/Dev/mestint/ora1gyak/ora1gyak.csproj", + "projectUniqueName": "/home/tom/Dev/MestInt/ora1gyak/ora1gyak.csproj", "projectName": "ora1gyak", - "projectPath": "/home/tom/Dev/mestint/ora1gyak/ora1gyak.csproj", + "projectPath": "/home/tom/Dev/MestInt/ora1gyak/ora1gyak.csproj", "packagesPath": "/home/tom/.nuget/packages/", - "outputPath": "/home/tom/Dev/mestint/ora1gyak/obj/", + "outputPath": "/home/tom/Dev/MestInt/ora1gyak/obj/", "projectStyle": "PackageReference", "configFilePaths": [ "/home/tom/.nuget/NuGet/NuGet.Config" diff --git a/ora1gyak/obj/project.nuget.cache b/ora1gyak/obj/project.nuget.cache index 95d5a1e..83d7124 100644 --- a/ora1gyak/obj/project.nuget.cache +++ b/ora1gyak/obj/project.nuget.cache @@ -1,8 +1,8 @@ { "version": 2, - "dgSpecHash": "6++IdPzGwkAIg/uzl5ldolEqJu61iAjLnWh+qV2PgIiRbX9Ix9XOBePbaLs9qaF5jyMOOgmAOXn3h9eMTkHlaA==", + "dgSpecHash": "TmB9rBKg2O3dJIEyjAoFHeHzE4yeHzDGtzDXp6FD5dgvRPnHhiiDl3UcbmoJRuK4sHRdNFwixioP5NT+dLYafw==", "success": true, - "projectFilePath": "/home/tom/Dev/mestint/ora1gyak/ora1gyak.csproj", + "projectFilePath": "/home/tom/Dev/MestInt/ora1gyak/ora1gyak.csproj", "expectedPackageFiles": [], "logs": [] } \ No newline at end of file