Skip to content

Commit 5040cd2

Browse files
committed
Added IBreedingPoolGenerator and implementation IndexBasedPoolGenerator
1 parent 49baadd commit 5040cd2

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace NeuralBotMasterFramework.Interfaces
8+
{
9+
public interface IBreedingPoolGenerator
10+
{
11+
List<IWeightedNetwork> GenerateBreedingPool(Dictionary<IWeightedNetwork, double> networksAndFitness);
12+
}
13+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using NeuralBotMasterFramework.Interfaces;
7+
8+
namespace NeuralBotMasterFramework.Logic.PoolGenerators
9+
{
10+
public class IndexBasedPoolGenerator : IBreedingPoolGenerator
11+
{
12+
public List<IWeightedNetwork> GenerateBreedingPool(Dictionary<IWeightedNetwork, double> networksAndFitness)
13+
{
14+
List<IWeightedNetwork> poolList = new List<IWeightedNetwork>();
15+
for (int networkIndex = 0; networkIndex < networksAndFitness.Count; ++networkIndex)
16+
{
17+
IWeightedNetwork currentNetwork = networksAndFitness.Keys.ElementAt(networkIndex);
18+
for (int i = 0; i < networksAndFitness.Count - networkIndex; ++i)
19+
{
20+
poolList.Add(currentNetwork);
21+
}
22+
}
23+
return poolList;
24+
}
25+
}
26+
}

NeuralBotMasterFramework/NeuralBotMasterFramework/NeuralBotMasterFramework.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<ItemGroup>
4444
<Compile Include="Helper\RandomNumberGenerator.cs" />
4545
<Compile Include="Interfaces\IBaseLayer.cs" />
46+
<Compile Include="Interfaces\IBreedingPoolGenerator.cs" />
4647
<Compile Include="Interfaces\IGeneticAlgorithm.cs" />
4748
<Compile Include="Interfaces\ILayer.cs" />
4849
<Compile Include="Interfaces\INetwork.cs" />
@@ -52,6 +53,7 @@
5253
<Compile Include="Interfaces\INode.cs" />
5354
<Compile Include="Logic\Algorithms\GeneticAlgorithm.cs" />
5455
<Compile Include="Logic\Networks\WeightedNetwork.cs" />
56+
<Compile Include="Logic\PoolGenerators\IndexBasedPoolGenerator.cs" />
5557
<Compile Include="Models\Layer.cs" />
5658
<Compile Include="Models\Node.cs" />
5759
<Compile Include="Models\WeightedLayer.cs" />

0 commit comments

Comments
 (0)