diff --git a/JeuHoyEtudiants/JeuHoy_WPF_Natif/Model/GestionFichiersSorties.cs b/JeuHoyEtudiants/JeuHoy_WPF_Natif/Model/GestionFichiersSorties.cs index c34288a..0627f33 100644 --- a/JeuHoyEtudiants/JeuHoy_WPF_Natif/Model/GestionFichiersSorties.cs +++ b/JeuHoyEtudiants/JeuHoy_WPF_Natif/Model/GestionFichiersSorties.cs @@ -8,11 +8,15 @@ namespace JeuHoy_WPF_Natif.Model { public GestionFichiersSorties(){} public List ChargerCoordonnees(string fichier) { - StreamReader lecteur = new StreamReader(fichier); List lstSql = new List(); string sLigne = ""; string[] sTabElements = null; + if (!File.Exists(fichier)) + return lstSql; + + StreamReader lecteur = new StreamReader(fichier); + if (!lecteur.EndOfStream) { sLigne = lecteur.ReadLine(); int nbElements = Convert.ToInt32(sLigne); diff --git a/JeuHoyEtudiants/JeuHoy_WPF_Natif/Model/GestionPerceptrons.cs b/JeuHoyEtudiants/JeuHoy_WPF_Natif/Model/GestionPerceptrons.cs index aceaa0e..bb884f2 100644 --- a/JeuHoyEtudiants/JeuHoy_WPF_Natif/Model/GestionPerceptrons.cs +++ b/JeuHoyEtudiants/JeuHoy_WPF_Natif/Model/GestionPerceptrons.cs @@ -4,19 +4,25 @@ using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using JeuHoy_WPF_Natif.Model; namespace JeuHoy_WPF_Natif.Model { public class GestionPerceptrons { private Dictionary _lstPerceptrons = new Dictionary(); - private Model.IGestionFichiers _gestionSortie = new GestionFichiersSorties(); - private List _lstData = new List(); + private IGestionFichiers _gestionSortie = new GestionFichiersSorties(); + private List _lstData; /// /// Constructeur /// public GestionPerceptrons() { + _lstData = _gestionSortie.ChargerCoordonnees("train.txt"); + for (char x = '0'; x <= '9'; ++x) _lstPerceptrons.Add(x.ToString(), new Perceptron(x.ToString())); + + foreach (Squelette sql in _lstData) + Entrainement(sql, sql.Reponse); } /// @@ -44,6 +50,7 @@ namespace JeuHoy_WPF_Natif.Model { if (reponse != "") { coordo.Reponse = reponse; _lstData.Add(coordo); + SauvegarderCoordonnees("train.txt"); } if (_lstData is null) diff --git a/JeuHoyEtudiants/JeuHoy_WPF_Natif/Presenter/PresentateurWEntrainement.cs b/JeuHoyEtudiants/JeuHoy_WPF_Natif/Presenter/PresentateurWEntrainement.cs index 6d98195..2328309 100644 --- a/JeuHoyEtudiants/JeuHoy_WPF_Natif/Presenter/PresentateurWEntrainement.cs +++ b/JeuHoyEtudiants/JeuHoy_WPF_Natif/Presenter/PresentateurWEntrainement.cs @@ -30,8 +30,8 @@ namespace JeuHoy_WPF_Natif.Presenter private void _vue_EntrainementEvt(object sender, EventArgs e) { // Perceptron!!! - string position = _vue.GetPositionEnCour().ToString(); - Squelette sq = new Squelette(new double[1], position); + string position = (_vue.GetPositionEnCour() - 1).ToString(); + Squelette sq = new Squelette(_gestionnaireKinect.Body, position); _vue.Console = _gestionnairePerceptron.Entrainement(sq, position); } diff --git a/JeuHoyEtudiants/JeuHoy_WPF_Natif/View/wEntrainement.xaml.cs b/JeuHoyEtudiants/JeuHoy_WPF_Natif/View/wEntrainement.xaml.cs index 3f822bb..d5ccdbd 100644 --- a/JeuHoyEtudiants/JeuHoy_WPF_Natif/View/wEntrainement.xaml.cs +++ b/JeuHoyEtudiants/JeuHoy_WPF_Natif/View/wEntrainement.xaml.cs @@ -3,6 +3,7 @@ using JeuHoy_WPF_Natif.View; using Microsoft.Kinect; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Windows; @@ -42,6 +43,10 @@ namespace JeuHoy_WPF.View _presentateur = new PresentateurWEntrainement(this); + for (int x = 1; x <= CstApplication.NBFIGURE; ++x) + if (File.Exists("HoyContent/fig" + x.ToString() + ".png")) + _dicImgFigure.Add("fig" + x, new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"./HoyContent/fig" + x.ToString() + ".png", UriKind.Absolute))); + ChargerFigure(); _son.JouerSonAsync(@"./HoyContent/hoy.wav"); }