-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
2,731 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace SoTSolverClassLibrary | ||
{ | ||
public class Class1 | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SoTSolverClassLibrary.Constants | ||
{ | ||
public class ColorConstants | ||
{ | ||
//Empty | ||
public static readonly Color EmptyText = Color.Black; | ||
public static readonly Color EmptyBG = Color.White; | ||
//Coal | ||
public static readonly Color CoalText = Color.White; | ||
public static readonly Color CoalBG = Color.DimGray; | ||
//Player | ||
public static readonly Color PlayerText = Color.Black; | ||
public static readonly Color PlayerBG = Color.DodgerBlue; | ||
//Goal | ||
public static readonly Color GoalText = Color.White; | ||
public static readonly Color GoalBG = Color.DodgerBlue; | ||
//Text | ||
public static readonly Color SuccessColor = Color.LimeGreen; | ||
public static readonly Color FailedColor = Color.Red; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SoTSolverClassLibrary.DataAccess | ||
{ | ||
public class Seed | ||
{ | ||
public int SeedValue { get; } | ||
public int MovesRequired { get; } | ||
public bool Obstructed { get; } | ||
|
||
public Seed(int seedValue, int movesRequired, bool obstructed) | ||
{ | ||
SeedValue = seedValue; | ||
MovesRequired = movesRequired; | ||
Obstructed = obstructed; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Data.SQLite; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SoTSolverClassLibrary.DataAccess | ||
{ | ||
public class SeedDAO | ||
{ | ||
private Random random; | ||
public SeedDAO() | ||
{ | ||
random = new Random(); | ||
} | ||
|
||
public SeedDAO(int randSeed) | ||
{ | ||
random = new Random(randSeed); | ||
} | ||
|
||
public List<Seed> GetRandomSeeds(int minMoves, int maxMoves, bool allowObstructed, int amount) | ||
{ | ||
if (amount <= 0) | ||
{ | ||
throw new ArgumentException("Amount must be larger than 0"); | ||
} | ||
List<Seed> seeds = new List<Seed>(); | ||
using var conn = new SQLiteConnection(@"Data Source=SoTPuzzle.db;New=False;"); | ||
using var cmd = conn.CreateCommand(); | ||
conn.Open(); | ||
cmd.CommandText = "SELECT * FROM Puzzles WHERE moves_required BETWEEN @min AND @max AND obstructed <= @obstructed ORDER BY RANDOM() LIMIT @limit"; | ||
//Values | ||
cmd.Parameters.AddWithValue("@min", minMoves); | ||
cmd.Parameters.AddWithValue("@max", maxMoves); | ||
cmd.Parameters.AddWithValue("@obstructed", allowObstructed ? 1 : 0); | ||
cmd.Parameters.AddWithValue("@limit", amount); | ||
using var reader = cmd.ExecuteReader(); | ||
while (reader.Read()) | ||
{ | ||
Seed seed = new Seed( | ||
reader.GetInt32(0), | ||
reader.GetInt32(1), | ||
reader.GetBoolean(2) | ||
); | ||
seeds.Add(seed); | ||
} | ||
return seeds; | ||
} | ||
|
||
public Seed? GetRandomSeed(int minMoves, int maxMoves, bool allowObstructed) | ||
{ | ||
var seeds = GetRandomSeeds(minMoves, maxMoves, allowObstructed, 1); | ||
if (seeds.Count == 0) | ||
{ | ||
return null; | ||
} | ||
|
||
return seeds[0]; | ||
} | ||
|
||
public Seed? GetRandomSeed(int minMoves, int maxMoves) | ||
{ | ||
return GetRandomSeed(minMoves, maxMoves, false); | ||
} | ||
|
||
public Seed? GetRandomSeed(int moves) | ||
{ | ||
return GetRandomSeed(moves, moves, false); | ||
} | ||
|
||
public Seed? GetRandomSeed(int moves, bool allowObstructed) | ||
{ | ||
return GetRandomSeed(moves, moves, allowObstructed); | ||
} | ||
|
||
void Main() | ||
{ | ||
GetRandomSeed(5); | ||
} | ||
} | ||
} |
Oops, something went wrong.