-
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.
updated decision engine to calculate 2 layers deep
- Loading branch information
Showing
13 changed files
with
128 additions
and
126 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 |
---|---|---|
|
@@ -560,3 +560,4 @@ FodyWeavers.xsd | |
|
||
# training data | ||
*train_data.csv | ||
*train_data.txt |
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
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
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,8 @@ | ||
namespace DecisionEngine.Models | ||
{ | ||
public class EvaluatedMove | ||
{ | ||
public int[] Position { get; set; } | ||
public float Evaluation { get; set; } | ||
} | ||
} |
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,20 @@ | ||
namespace DecisionEngine.Models | ||
{ | ||
public class FutureCalculation | ||
{ | ||
public int[] Position { get; set; } | ||
public List<EvaluatedMove> NextMoves { get; set; } | ||
internal (float, float) MinAndMaxEvals() | ||
{ | ||
if (NextMoves == null || NextMoves.Count < 1) | ||
{ | ||
throw new ArgumentException(nameof(NextMoves)); | ||
} | ||
|
||
var minValue = NextMoves.Min(nm => nm.Evaluation); | ||
var maxValue = NextMoves.Max(nm => nm.Evaluation); | ||
|
||
return (minValue, maxValue); | ||
} | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,25 +1,31 @@ | ||
import os | ||
import json | ||
from keras.models import load_model | ||
import numpy as np | ||
|
||
# Load the model | ||
model = load_model('./sbrunaugh_chess_model_v3.keras') | ||
model = load_model('./sbrunaugh_chess_model_v3-lite.keras') | ||
|
||
inputFilePath = './input.csv' | ||
outputFilePath = './output.txt' | ||
inputFilePath = './input.json' | ||
outputFilePath = './output.json' | ||
|
||
if os.path.exists(outputFilePath): | ||
os.remove(outputFilePath) | ||
|
||
# Open the input file and output file | ||
with open(inputFilePath, 'r') as infile, open(outputFilePath, 'w') as outfile: | ||
for line in infile: | ||
input_data = np.array(line.strip().split(','), dtype=int).reshape(1, -1) | ||
data = [] | ||
|
||
# Run the forward pass | ||
prediction = model.predict(input_data) | ||
with open(inputFilePath, 'r') as inputJson: | ||
data = json.load(inputJson) | ||
for futureCalc in data: | ||
for nextMove in futureCalc['NextMoves']: | ||
model_input = np.array(nextMove['Position'], dtype=int).reshape(1, -1) | ||
|
||
# Write the prediction to the output file | ||
outfile.write(f'{prediction[0][0]}\n') | ||
# Run the forward pass | ||
eval = model.predict(model_input) | ||
nextMove['Evaluation'] = float(eval[0][0]) | ||
print(nextMove['Evaluation']) | ||
|
||
print("Index-specific evaluations saved to ", outputFilePath) | ||
with open(outputFilePath, 'w') as outputJson: | ||
json.dump(data, outputJson) | ||
|
||
print("JSON data has been written to ", outputFilePath) |
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.