public ActionResult Index(bool goodWithChildren, bool drools, ELength coatlength, EScale activityLevel, EScale sheddingLevel, EScale groomingLevel, EScale intelligenceLevel, ESize size) { Dog requestedDog = new Dog { GoodWithChildren = goodWithChildren, Drools = drools, Coatlength = coatlength, ActivityLevel = activityLevel, SheddingLevel = sheddingLevel, GroomingLevel = groomingLevel, IntelligenceLevel = intelligenceLevel, Size = size }; Dog returnDog = findDogRecommendation(requestedDog); if (returnDog.BreedName != null) { return(View("DogRecommendation", returnDog)); } else { return(View("NoDogRecommendation")); } }
//public List<Tuple<Note, int>> getSubsequentScaleNotes(bool isUprightBass, EScale scale, bool ascending, Note root, Note startNote, int octave) //{ // var resList = new List<Tuple<Note,int>>(); // var succ = soundLogic.getScaleNotes(true, scale, root, octave, startNote, ascending, ref resList); // return resList; //} public List<Tuple<Note, int>> getSubsequentScaleNotes(EInstrument instrument, EScale scale, bool ascending, Note root, Note startNote, int rootOctave) { var result = new List<Tuple<Note, int>>(); var res = soundLogic.getScaleNotes(instrument, scale, root, rootOctave, startNote, ascending, ref result); return result; }
private int determineBestMatch(bool GoodWithChildren, bool Drools, ELength Coatlength, ESize Size, EScale ActivityLevel, EScale SheddingLevel, EScale GroomingLevel, EScale IntelligenceLevel) { //Make a list to store score values. This is a way of assessing which dog is the best choice. int[] scores = new int[dogList.Count]; for (int i = 0; i < dogList.Count; i++) { //For each matching criteria, increase a score value. //This completely hinges on the fact that dogs in the list ARE NOT SORTED. //The dog list has a very tenuous connection with the score list. if (dogList[i].GoodWithChildren == GoodWithChildren) { scores[i]++; } if (dogList[i].Drools == Drools) { scores[i]++; } if (dogList[i].Coatlength == Coatlength) { scores[i]++; } if (dogList[i].Size == Size) { scores[i]++; } if (dogList[i].ActivityLevel == ActivityLevel) { scores[i]++; } if (dogList[i].SheddingLevel == SheddingLevel) { scores[i]++; } if (dogList[i].GroomingLevel == GroomingLevel) { scores[i]++; } if (dogList[i].IntelligenceLevel == IntelligenceLevel) { scores[i]++; } } //Get max val int highScore = scores.Max(); //Big Caveat: //This will return the index of the first dog that achieved that score. //It's quite common for multiple dogs to get the same score, so some dogs will be over-represented in practice. //This can be prevented by instead creating a list of dogs with equal scores and randomly selecting one from there as the //return dog. I felt it wasn't needed for the scope of this practical (also it's 11:30pm). int indexOf = scores.ToList().IndexOf(highScore); //Return index return indexOf; }
public static Size toProper(TQuantity bytes) { EScale scale = EScale.B; for (; bytes > Base; ++scale) { bytes /= Base; } return(new Size(bytes, scale)); }
private bool checkScalers(EScale dogQualitiesEScaleValue, EScale currentDogEScaleValue) { if (dogQualitiesEScaleValue != EScale.NoPreference) if (currentDogEScaleValue.Equals(dogQualitiesEScaleValue)) return true; else return false; else return true; }
private int whatIfNoPreference(int similarity, EScale selectedDog) { int sim = 0; sim = similarity; if (selectedDog == EScale.No_Preference) { sim++; } return(sim); }
private double calculateDifferenceForValue(EScale userInput, EScale matchScale) { if (userInput == EScale.NO_PREFERENCE) return 0; int userValue = (int)userInput; int matchValue = (int)matchScale; double result = Math.Abs(userValue - matchValue); // get the difference result = Math.Pow(result, DIFFERENCE_POWER); // Make bigger differences even bigger return result; }
public Question_Model(EScale scale, bool ascending, Note rootNote, int octave, Note startNote, string scaleDescription, string directionDescription, string rootNoteDescription, string octaveDescription, string startNoteDescription, bool useSharpNotation) { Scale = scale; Ascending = ascending; RootNote = rootNote; Octave = octave; StartNote = startNote; ScaleDescription = scaleDescription; DirectionDescription = directionDescription; RootNoteDescription = rootNoteDescription; OctaveDescription = octaveDescription; StartNoteDescription = startNoteDescription; this.UseSharpNotation = useSharpNotation; }
public ActionResult ChooseDogPref(bool GoodWithChildren, bool Drools, ELength Coatlength, ESize Size, EScale ActivityLevel, EScale SheddingLevel, EScale GroomingLevel, EScale IntelligenceLevel) { //Call makedatabase, populating a list of dogs dogList = makeDatabase(); //Blank dog object, will be passed into the return view Dog recDog = dogList[0]; //build a return dog by determining the index of the best match. int indexOfBest = determineBestMatch(GoodWithChildren, Drools, Coatlength, Size, ActivityLevel, SheddingLevel, GroomingLevel, IntelligenceLevel); recDog = dogList[indexOfBest]; return View("DogConfirm", recDog); }
public bool getScaleNotes(EInstrument instrument, EScale scale, Note root, int startOctave, Note startNote, bool ascending, ref List<Tuple<Note, int>> result) { var scaleNotes = getScaleNotes(scale, root); var currentIndex = scaleNotes.FindIndex(x => x == startNote); var currentOctave = startOctave; var previousNote = scaleNotes[currentIndex]; var cNote = new Note(new List<string>() {"C"}); var previousIndex = currentIndex; for (var i = 0; i < scaleNotes.Count(); ++i) { var noteToAdd = scaleNotes[currentIndex]; if (previousNote < cNote && noteToAdd >= cNote && ascending == true) { currentOctave++; } else if (previousNote >= cNote && noteToAdd < cNote && ascending == false) { currentOctave--; } previousNote = noteToAdd; var toAdd = new Tuple<Note, int>(noteToAdd, currentOctave); result.Add(toAdd); currentIndex += ascending ? 1 : -1; if (currentIndex < 0 || currentIndex >= scaleNotes.Count()) { currentIndex = ascending ? 0 : scaleNotes.Count() - 1; } } foreach (var element in result) { if (doesInstrumentSupportNoteAndOctave(instrument, element.Item1, element.Item2) == false) { return false; } } return true; }
public ActionResult Result(EScale activityLevel, ELength coatlength, bool drools, bool goodWithChildren, EScale groomingLevel, EScale intelligenceLevel, EScale sheddingLevel, ESize size) { List<Dog> dogs = makeDatabase(); //gets dogs databse //creates dog with properties submitted in by user in html form Dog userDog = new Dog(); userDog.ActivityLevel = activityLevel; userDog.Coatlength = coatlength; userDog.Drools = drools; userDog.GoodWithChildren = goodWithChildren; userDog.GroomingLevel = groomingLevel; userDog.IntelligenceLevel = intelligenceLevel; userDog.SheddingLevel = sheddingLevel; userDog.Size = size; //userDog is set to its best match userDog = findClosestDog(userDog); return View(userDog); }
public ActionResult Result(EScale highActivityLevel, EScale highSheddingLevel, EScale highGroomingLevel, EScale intelligent, EScale goodWithChildren, EScale drools, EScale longCoat, EScale bigDog) { List<Dog> doggyDB = makeDatabase(); // Seems like a sensible enough name Dog userDreamDog = new Dog() { HighActivityLevel = highActivityLevel, HighSheddingLevel = highSheddingLevel, HighGroomingLevel = highGroomingLevel, Intelligent = intelligent, GoodWithChildren = goodWithChildren, DroolingLevel = drools, LongCoat = longCoat, BigDog = bigDog }; Dog result = findBestMatch(userDreamDog, doggyDB); return View(result); }
public ActionResult Result(EScale activityLevel, ELength coatlength, bool drools, bool goodWithChildren, EScale groomingLevel, EScale intelligenceLevel, EScale sheddingLevel, ESize size) { List <Dog> dogs = makeDatabase(); //gets dogs databse //creates dog with properties submitted in by user in html form Dog userDog = new Dog(); userDog.ActivityLevel = activityLevel; userDog.Coatlength = coatlength; userDog.Drools = drools; userDog.GoodWithChildren = goodWithChildren; userDog.GroomingLevel = groomingLevel; userDog.IntelligenceLevel = intelligenceLevel; userDog.SheddingLevel = sheddingLevel; userDog.Size = size; //userDog is set to its best match userDog = findClosestDog(userDog); return(View(userDog)); }
public ActionResult Index(bool goodWithChildren, bool drools, ELength coatlength, EScale activityLevel, EScale sheddingLevel, EScale groomingLevel, EScale intelligenceLevel, ESize size) { Dog requestedDog = new Dog { GoodWithChildren = goodWithChildren, Drools = drools, Coatlength = coatlength, ActivityLevel = activityLevel, SheddingLevel = sheddingLevel, GroomingLevel = groomingLevel, IntelligenceLevel = intelligenceLevel, Size = size }; Dog returnDog = findDogRecommendation(requestedDog); if (returnDog.BreedName != null) return View("DogRecommendation", returnDog); else return View("NoDogRecommendation"); }
public ActionResult ShowSelect(bool GoodWithChildren, bool Drooling, ELength CoatLength, EScale ActivityLevel, EScale SheddingLevel, EScale GroomingLevel, EScale IntelligenceLevel, ESize Size) { //makes the wanted dog Dog wantedDog = new Dog { ActivityLevel = ActivityLevel, SheddingLevel = SheddingLevel, GroomingLevel = GroomingLevel, IntelligenceLevel = IntelligenceLevel, GoodWithChildren = GoodWithChildren, Drools = Drooling, CoatLength = CoatLength, Size = Size }; //calls method to find closest dog Dog closestMatch = findClosestMatch(wantedDog); //returns the view and dog return(View("DogRecomendation", closestMatch)); }
//if values are the same or there is no preference for wanted assign 1 //if it is not medium means must be either short or long //and if the list dog is medium assigns .5 for close public double getEScaleValue(EScale wantedDogInput, EScale listDogInput) { double value = 0; if (wantedDogInput == listDogInput) { value = 1; } if (wantedDogInput == EScale.NoPreference) { value = 1; } if (wantedDogInput != EScale.NoPreference) { if ((wantedDogInput != EScale.Medium) && (listDogInput == EScale.Medium)) { value = 0.5; } } return(value); }
public void SetElements(OrbitalElements elements) { try { if (elements.semilatusrectum > this.body.parent.HillRadius() / AU) { SLRScale.SetRange(1e-8, elements.semilatusrectum); } } catch (NullReferenceException) {} // body has no parent, we cannot check the slr SLRScale.Value = elements.semilatusrectum / AU; if (elements.eccentricity > ECCENTRICITY_MAX) { EScale.SetRange(0, elements.eccentricity); } else { EScale.SetRange(0, ECCENTRICITY_MAX); // there is no way to see the current range, so we'll set it every time } EScale.Value = elements.eccentricity; IncScale.Value = elements.inclination / deg; ANLScale.Value = elements.ascendingNodeLongitude / deg; PAScale.Value = elements.periapsisArgument / deg; TAScale.Value = elements.trueAnomaly / deg; }
public ActionResult SelectedDog(EScale activityLevel, EScale sheddingLevel, EScale groomingLevel, EScale intelligenceLevel, ELength coatlength, ESize size, bool goodWithChildren, bool drools) { DatabaseManager dbm = new DatabaseManager(); db = dbm.makeDatabase(); Dog nDog = new Dog(); nDog.ActivityLevel = activityLevel; nDog.SheddingLevel = sheddingLevel; nDog.GroomingLevel = groomingLevel; nDog.IntelligenceLevel = intelligenceLevel; nDog.Coatlength = coatlength; nDog.Size = size; nDog.GoodWithChildren = goodWithChildren; nDog.Drools = drools; nDog.BreedName = db[0].BreedName; nDog.ImageName = db[0].ImageName; nDog.DisplayName = db[0].DisplayName; Dog recommendation = dbm.FindRecommodation(db, nDog); return View(recommendation); }
private int whatIfNoPreference(int similarity, EScale selectedDog) { int sim = 0; sim = similarity; if(selectedDog == EScale.No_Preference) { sim++; } return sim; }
public List<Note> getScaleNotes(EScale scale, Note rootNote) { var scaleIntervals = scaleIntervalsMap[scale]; var result = new List<Note>(); var noteComparer = new NoteComparer(); var startIndex = notesList.FindIndex((Note n) => noteComparer.Equals(n, rootNote)); var offset = 0; foreach(var interval in scaleIntervals) { var index = startIndex + offset; if(index >= notesList.Count) { index -= notesList.Count; } result.Add(notesList[index]); offset += (Int32)interval; } return result; }
public Size(TQuantity quantity, EScale scale = EScale.B) { Quantity = quantity; Scale = scale; }
private int ComputeSemitoneOffsetFromRootToStartNote(EScale scale, bool ascending, Note rootNote, Note startNote) { var result = 0; if (rootNote == startNote) { return result; } var scaleIntervals = scaleIntervalsMap[scale]; var startNoteIntervalIndex = getStartNoteIntervalIndex(scale, rootNote, startNote); for (var i = 0; i <= startNoteIntervalIndex; ++i) { var interval = scaleIntervals[i]; result += ascending ? (Int32)interval : -(Int32)interval; } return result; }
//if values are the same or there is no preference for wanted assign 1 //if it is not medium means must be either short or long //and if the list dog is medium assigns .5 for close public double getEScaleValue(EScale wantedDogInput, EScale listDogInput) { double value = 0; if (wantedDogInput == listDogInput) { value = 1; } if(wantedDogInput == EScale.NoPreference) { value = 1; } if (wantedDogInput != EScale.NoPreference) { if ((wantedDogInput != EScale.Medium) && (listDogInput == EScale.Medium)) { value = 0.5; } } return value; }
public ActionResult ShowSelect(bool GoodWithChildren, bool Drooling, ELength CoatLength, EScale ActivityLevel, EScale SheddingLevel, EScale GroomingLevel, EScale IntelligenceLevel, ESize Size) { //makes the wanted dog Dog wantedDog = new Dog { ActivityLevel = ActivityLevel, SheddingLevel = SheddingLevel, GroomingLevel = GroomingLevel, IntelligenceLevel = IntelligenceLevel, GoodWithChildren = GoodWithChildren, Drools = Drooling, CoatLength = CoatLength, Size = Size }; //calls method to find closest dog Dog closestMatch = findClosestMatch(wantedDog); //returns the view and dog return View("DogRecomendation", closestMatch); }
int getStartNoteIntervalIndex(EScale scale, Note root, Note startNote) { var scaleIntervals = scaleIntervalsMap[scale]; if (root == startNote) { return -1; } int semitoneOffset = 0; for(int i = 0; i < scaleIntervals.Count; ++i) { semitoneOffset += (Int32)scaleIntervals[i]; var offsetedNote = getOffsetedNote(root, semitoneOffset); if(startNote == offsetedNote) { return i; } } throw new Exception("something went wrong"); }
string getScaleDescription(EScale scale) { return Enum.GetName(typeof(EScale), scale); }
Note getRandomStartNote(EScale scale, Note rootNote) { var scaleNotes = soundLogic.getScaleNotes(scale, rootNote); return scaleNotes[random.Next(0, scaleNotes.Count)]; }