/// <summary> /// Creates a new FastestMirrorResolver with a provided scoring algorithm. /// </summary> /// <param name="score">Scoring algorithm.</param> public FastestMirrorResolver(IScore score) { if (score == null) throw new ArgumentNullException("score"); _score = score; }
void init() { friendScoreLoaded = false; #if UNITY_EDITOR testMode = true; #endif if (testMode) { // Test values for Unity Editor IScore[] testScores = new IScore[4]; for (int i = 0; i < testScores.Length; i++) { testScores[i] = new IScoreTestImpl(50 * i, testScores.Length - i, "TEST_USER_" + i); } scores = testScores; SocialPlatformManager.cache.myProfile = new IUserProfileTestImpl("TESTMYSELF", null, false, "TEST_MYSELF!!!"); friendScoreLoaded = true; } else { if (SocialPlatformManager.isAuthenticated()) { lb = Social.CreateLeaderboard(); lb.id = SocialPlatformManager.spm.leaderboardInfoMap[AchievementManager.LB_SINGLE]; lb.range = new Range(1, SocialPlatformManager.cache.MaxLoadCount); lb.userScope = SocialPlatformManager.cache.userScope; lb.timeScope = TimeScope.AllTime; lb.LoadScores(loadFriendScores); } } }
private void SetScorePosition(IScore score, GroupCollection parts) { var offset = string.IsNullOrEmpty(parts[2].Value) ? parts[1].Length : Convert.ToInt32(parts[2].Value); var timing = parts[1].Value.Last() == '\\' ? OffsetTiming.Early : OffsetTiming.Late; score.SetPosition(timing == OffsetTiming.Early ? -offset : offset); }
internal iOSScore (IScore _scoreData, User _user) { // Initialize properties LeaderboardID = _scoreData.leaderboardID; User = _user; Value = _scoreData.value; Date = _scoreData.date; Rank = _scoreData.rank; }
public void Interpret(IScore score) { foreach (var key in Sample) { score.AddSample(new Sample(key.ToString())); } score.Progress(); }
public void Interpret(IScore score) { var parts = GetParts(); SetScorePosition(score, parts); var sampleExpression = new SampleExpression(parts[4].Value); sampleExpression.Interpret(score); }
public Result<IScore> Insert(IScore aScore, Result<IScore> aResult) { ArgCheck.NotNull("aScore", aScore); ArgCheck.NotNull("aResult", aResult); Coroutine.Invoke(CreateHelper, aScore, new Result<IScore>()).WhenDone( aResult.Return, aResult.Throw ); return aResult; }
void ProcessLoadedScores(IScore[] scores) { if(scores.Length ==0) { Debug.Log("No Scores Found !!!"); } else { Debug.Log("Got"+scores.Length.ToString () + "scores"); } }
public Leaderboard() { this.id = "Invalid"; this.range = new Range(1, 10); this.userScope = UserScope.Global; this.timeScope = TimeScope.AllTime; this.m_Loading = false; this.m_LocalUserScore = (IScore) new Score("Invalid", 0L); this.m_MaxRange = 0U; this.m_Scores = (IScore[]) new Score[0]; this.m_Title = "Invalid"; this.m_UserIDs = new string[0]; }
public void LogOutcome(IWord word, IScore score) { int rank; if (record.TryGetValue (word, out rank) == false) { rank = 0; } if (score.IsCorrect) { rank /= 2; } else { rank++; } record [word] = rank; }
public async void PractiseCompleted(IScore score, IApplicationInitializer applicationInitializer) { var name = score.Name; var numberOfCorrectAnswers = score.NumberOfCorrectAnswers; var numberOfQuestions = score.NumberOfQuestions; var percentageCompleted = score.PercentageCompleted; var newLine = Environment.NewLine; await _windowManager.ShowMessage( $"Practise of {name} completed!{newLine}{newLine}You passed {numberOfCorrectAnswers} of {numberOfQuestions} ({percentageCompleted:P0})."); applicationInitializer.StartOver(); }
public void PractiseCompleted(IScore score, IApplicationInitializer applicationInitializer) { WriteTitle(string.Format("Practies of {0} completed!", score.Name)); Console.WriteLine( "You passed {0} of {1} ({2:P0}).", score.NumberOfCorrectAnswers, score.NumberOfQuestions, score.PercentageCompleted); Console.ReadKey(true); applicationInitializer.StartOver(); }
public static void Create(Transform leaderboardTform, IUserProfile user, IScore scores) { if (pref == null) { pref = Resources.Load <GameObject>("Prefabs/UI/RecordPanel"); } GameObject lb = Instantiate(pref); lb.transform.parent = leaderboardTform; LbRecord lbComp = lb.GetComponent <LbRecord>(); lbComp.Init(user, scores); }
public Commands( IMovement movement, IRoomActions roomActions, IDebug debug, ISkills skills, ISpells spells, IObject objects, IInventory inventory, Icommunication communication, IEquip equipment, IScore score, ICombat combat, ICache cache, ISocials socials, ICommandHandler commandHandler, ICore core, IMobFunctions mobFunctions, IHelp help, IMobScripts mobScripts, ICrafting crafting, ICooking cooking, IUtilSkills utilSkills, IPassiveSkills passiveSkills, IHealer healer ) { _movement = movement; _roomActions = roomActions; _debug = debug; _skills = skills; _spells = spells; _object = objects; _inventory = inventory; _communication = communication; _equipment = equipment; _score = score; _combat = combat; _cache = cache; _socials = socials; _commandHandler = commandHandler; _core = core; _mobFunctions = mobFunctions; _help = help; _mobScripts = mobScripts; _crafting = crafting; _cooking = cooking; _utilSkills = utilSkills; _passiveSkills = passiveSkills; _healer = healer; }
public void AddScore(IScore other) { foreach (KeyValuePair <MassType, List <double> > item in (other as WeightedScore).matches) { if (matches.ContainsKey(item.Key)) { matches[item.Key].AddRange(item.Value); } else { matches[item.Key] = item.Value; } } }
public async Task <IScore> InsertScoreAsync(IScore score) { //TODO: fetch this data from the data access layer try { await _context.Scores.InsertOneAsync((Score)score); return(score); } catch (Exception ex) { throw ex; } }
public void LinearEquationSolver() { LearningApi api = new LearningApi(); api.UseActionModule <object, double[][]>((notUsed, ctx) => { const int maxSamples = 12; ctx.DataDescriptor = getDescriptorForRbm_sample1(); double[][] data = new double[maxSamples][]; data[0] = new double[] { 1, 1, 0, 0, 0, 0 }; // A data[1] = new double[] { 0, 0, 1, 1, 0, 0 }; // B data[2] = new double[] { 0, 0, 0, 0, 1, 1 }; // C data[3] = new double[] { 1, 1, 0, 0, 0, 1 }; // noisy A data[4] = new double[] { 0, 0, 1, 1, 0, 0 }; // B data[5] = new double[] { 0, 0, 0, 0, 1, 1 }; // C data[6] = new double[] { 1, 0, 0, 0, 0, 0 }; // weak A data[7] = new double[] { 0, 0, 1, 0, 0, 0 }; // weak B data[8] = new double[] { 0, 0, 0, 0, 1, 0 }; // weak C data[9] = new double[] { 1, 1, 0, 1, 0, 0 }; // noisy A data[10] = new double[] { 1, 0, 1, 1, 0, 0 }; // noisy B data[11] = new double[] { 0, 0, 1, 0, 1, 1 }; // noisy C return(data); }); api.UseRbm(0.2, 1000, 6, 3); IScore score = api.Run() as IScore; double[][] testData = new double[4][]; testData[0] = new double[] { 1, 1, 0, 0, 0, 0 }; testData[1] = new double[] { 0, 0, 0, 0, 1, 1 }; testData[2] = new double[] { 0, 1, 0, 0, 0, 0 }; testData[3] = new double[] { 0, 0, 0, 0, 1, 0 }; var result = api.Algorithm.Predict(testData, api.Context); // NOT FINISHED. //Assert.True(result[0] == 1); //Assert.True(result[1] == 0); //Assert.True(result[2] == 0); //Assert.True(result[3] == 0); //Assert.True(result[4] == 1); //Assert.True(result[5] == 0); }
void OnLocalUserScoreLoaded(string leaderboardName, IScore score) { if (score != null) { if (playerFinalDistance > score.value) { SubmitScoreToLeaderboard(); } } else { Debug.Log("No score found"); } }
public void Actualize() { ViewBox.Text = Visualizer.Visualize(CurrentGame); while (CurrentGame.Logs.Count > 0) { LogEntry logEntry = CurrentGame.Logs.Dequeue(); if (logEntry.Level <= LogLevel.INFO) { TxtPlayLog.Text += $"[{logEntry.BlockType}] - {logEntry.Location}: {logEntry.Text}\n"; } } TxtPlayLog.ScrollToEnd(); if (CurrentGame.State == State.RUNNING && !BtnStart.IsEnabled) { TxtPlayer1.Text = $"* Calculating solutions *** {CurrentGame.CurrentPlayer} ***" + Environment.NewLine; TxtPlayer1.AppendText( $"... with depth: {(int)SlidMaxDepth.Value} and width: {(int)SlidMaxWidth.Value} ..." + Environment.NewLine); var worker = new BackgroundWorker { WorkerReportsProgress = true }; worker.DoWork += worker_DoWork; worker.ProgressChanged += worker_ProgressChanged; worker.RunWorkerCompleted += worker_RunWorkerCompleted; IScore scoring = CurrentGame.CurrentPlayer == CurrentGame.Player1 ? GuiHelper.GetScoring((Strategy)CboxAi1.SelectedValue) : GuiHelper.GetScoring((Strategy)CboxAi2.SelectedValue); worker.RunWorkerAsync(new List <object> { (int)SlidMaxDepth.Value, (int)SlidMaxWidth.Value, scoring }); BtnStart.Content = $"{CurrentGame.CurrentPlayer} Move!"; } else if (CurrentGame.State == SabberStoneCore.Enums.State.COMPLETE) { TxtPlayer1.Text = ".. Game is finished!" + Environment.NewLine + $"P1: {CurrentGame.Player1} => {CurrentGame.Player1.PlayState}" + Environment.NewLine + $"P2: {CurrentGame.Player2} => {CurrentGame.Player2.PlayState}" + Environment.NewLine; BtnStart.IsEnabled = true; BtnStart.Content = "Finished!" + Environment.NewLine + "..new game?"; CboxDeck1.IsEnabled = true; CboxDeck2.IsEnabled = true; CboxAi1.IsEnabled = true; CboxAi2.IsEnabled = true; } }
public void SimpleSequenceTest() { LearningApi api = new LearningApi(); api.UseActionModule <object, double[][]>((notUsed, ctx) => { const int maxSamples = 10; ctx.DataDescriptor = getDescriptor(); double[][] data = new double[maxSamples][]; // // We generate following input vectors: // IN Val - Expected OUT Val // 1 - 0 // 2 - 0, // ... // maxSamples / 2 - 1, // maxSamples / 2 + 1 - 1, // maxSamples / 2 + 2 - 1, for (int i = 0; i < maxSamples; i++) { data[i] = new double[2]; data[i][0] = i; data[i][1] = (i > (maxSamples / 2)) ? 1 : 0; } return(data); }); api.UseDeltaLearning(0.2, 1000); IScore score = api.Run() as IScore; double[][] testData = new double[4][]; testData[0] = new double[] { 2.0, 0.0 }; testData[1] = new double[] { 4.0, 0.0 }; testData[2] = new double[] { 6.0, 0.0 }; testData[3] = new double[] { 8.0, 0.0 }; var result = api.Algorithm.Predict(testData, api.Context) as DeltaLearningResult; Assert.True(result.PredictedResults[0] == 0); Assert.True(result.PredictedResults[1] == 0); Assert.True(result.PredictedResults[2] == 1); Assert.True(result.PredictedResults[3] == 1); }
public static void OnAndroidDataRetrieved(LeaderboardScoreData data, Action <LeaderboardData> OnComplete) { LeaderboardData lb = new LeaderboardData(); if (data.Valid) { IScore curScore = data.Scores[0]; lb.init = true; lb.round = curScore.value; lb.position = curScore.rank; Debug.Log("curScore.rank"); } OnComplete(lb); }
public int Normalize( IScore score, IScore maxScore, RankingSet rankingSet) { // We don't want to deal with null, negative, or zero values, return early if (rankingSet == null || score == null || score.Score <= 0 || maxScore == null) { return(0); } // Normalize Score var normalizedScore = (int)Math.Ceiling((double)Math.Min(score.Score, maxScore.Score) / maxScore.Score * rankingSet.GetMaxScore()); return(normalizedScore); }
public async void PractiseCompleted(IScore score, IApplicationInitializer applicationInitializer) { var name = score.Name; var numberOfCorrectAnswers = score.NumberOfCorrectAnswers; var numberOfQuestions = score.NumberOfQuestions; var percentageCompleted = score.PercentageCompleted; const string hideCancelButton = null; await _app.MainPage.DisplayActionSheet( "Practise Completed!", hideCancelButton, $"Practise of {name} completed! You passed {numberOfCorrectAnswers} of {numberOfQuestions} ({percentageCompleted:P0}).", "OK"); applicationInitializer.StartOver(); }
public async Task <IActionResult> CreateAsync(Score score) { IScore insertedScore = null; try { insertedScore = await scoreManager.InsertScoreAsync(score); } catch (Exception ex) { throw ex; } var output = StatusCode((int)HttpStatusCode.Created, insertedScore); return(output); }
public void LoadHighscores() { resetOnlineList(); var board = GetAllTimeLeaderboard(); Social.localUser.Authenticate((succes) => { board.LoadScores(success => { if (success) { Debug.Log("Loading scores for scope: " + board.userScope.ToString()); var scores = board.scores; if (scores.Length > 0) { Debug.Log("Loaded scores: " + scores.Length); var maxIndex = Mathf.Min((int)5, (int)scores.Length); var userIds = new string[maxIndex]; for (int i = 0; i < maxIndex; i++) { int index = i; IScore score = scores[i]; Debug.Log("Score: " + score.value); onlineScoreList.Insert(i, (int)score.value); userIds[i] = score.userID; } // Load usernames; Debug.Log("uidArray: " + userIds); Debug.Log("Loading usernames..."); Social.Active.LoadUsers(userIds, users => { for (int i = 0; i < userIds.Length; i++) { IUserProfile user = users[i]; Debug.Log("Loaded username: "******" for ID: " + user.id); onlinePlayerList.Insert(i, user.userName); } }); } } }); if (!isLocal) { ClickedGlobal(); } }); }
public MCTSSimulatorExt(int playerId, IScore scoring, MCTSParameters mctsParameters, PredictionParameters predictionParameters, BigramMap map) : base(playerId, scoring, mctsParameters) { _predictionParameters = predictionParameters; _map = map; _oppHistory = null; _oppBoardCards = new BoardCards(); // the delta time for each simulation is: // a) depth * 2, because we simulation for every depth the opponent and the player at once // b) + 1, because we always simulation the player first _deltaTime = (_mctsParameters.SimulationTime - ((_predictionParameters.SimulationDepth * 2) + 1) * _mctsParameters.AggregationTime) / ((_predictionParameters.SimulationDepth * 2) + 1); }
public void PrintScoreTest() { player = new Player() { Name = "Ivan" }; score = Score.ScoreInstance; player.UpdatePoints(); var printScoreMock = new Mock <IScore>(); bool isScorePrinted = false; printScoreMock.Setup(s => s.PrintScoreBoard()).Callback(() => { isScorePrinted = true; }); printScoreMock.Object.PrintScoreBoard(); Assert.IsTrue(isScorePrinted); }
public void SimpleSequence2DTest() { LearningApi api = new LearningApi(); api.UseActionModule <object, double[][]>((notUsed, ctx) => { const int maxSamples = 10000; ctx.DataDescriptor = get2DDescriptor(); double[][] data = new double[maxSamples][]; for (int i = 0; i < maxSamples / 2; i++) { data[2 * i] = new double[3]; data[2 * i][0] = i; data[2 * i][1] = 5.0; data[2 * i][2] = 1.0; data[2 * i + 1] = new double[3]; data[2 * i + 1][0] = i; data[2 * i + 1][1] = -5.0; data[2 * i + 1][2] = 0.0; } return(data); }); api.UseDeltaLearning(0.2, 1000); IScore score = api.Run() as IScore; double[][] testData = new double[6][]; testData[0] = new double[] { 2.0, 5.0, 0.0 }; testData[1] = new double[] { 2, -5.0, 0.0 }; testData[2] = new double[] { 100, -5.0, 0.0 }; testData[3] = new double[] { 100, -5.0, 0.0 }; testData[4] = new double[] { 490, 5.0, 0.0 }; testData[5] = new double[] { 490, -5.0, 0.0 }; var result = api.Algorithm.Predict(testData, api.Context) as DeltaLearningResult; Assert.True(result.PredictedResults[0] == 1); Assert.True(result.PredictedResults[1] == 0); Assert.True(result.PredictedResults[2] == 0); Assert.True(result.PredictedResults[3] == 0); Assert.True(result.PredictedResults[4] == 1); Assert.True(result.PredictedResults[5] == 0); }
public async Task <IActionResult> UpdateAsync(string _id, Score score) { IScore insertedScore = null; try { score._id = new ObjectId(_id); insertedScore = await scoreManager.UpdateScoreAsync(score); } catch (Exception ex) { throw ex; } var output = StatusCode((int)HttpStatusCode.Created, insertedScore); return(output); }
/////////////////////////////////////////////////// // INITAL AUTHENTICATION (MUST BE DONE FIRST) /////////////////////////////////////////////////// // THIS FUNCTION GETS CALLED WHEN AUTHENTICATION COMPLETES // NOTE THAT IF THE OPERATION IS SUCCESSFUL Social.localUser WILL CONTAIN DATA FROM THE GAME CENTER SERVER void ProcessAuthentication(bool success) { if (success) { Debug.Log("Authenticated, checking achievements"); // MAKE REQUEST TO GET LOADED ACHIEVEMENTS AND REGISTER A CALLBACK FOR PROCESSING THEM //Social.LoadAchievements(ProcessLoadedAchievements); // ProcessLoadedAchievements FUNCTION CAN BE FOUND BELOW DoLeaderboard(); Debug.Log(leaderboardName); Social.LoadScores(leaderboardName, scores => { if (scores.Length > 0) { // SHOW THE SCORES RECEIVED Debug.Log("Received " + scores.Length + " scores"); testSCore = scores[0]; string myScores = "Leaderboard: \n"; foreach (IScore score in scores) { result += score.formattedValue + System.Environment.NewLine; listscores.Add(score); myScores += "\t" + "id: " + score.userID + " score: " + score.value + " date: " + score.date + "\n"; point = (int)scores[0].value; Debug.Log(myScores); } } else { Debug.Log("No scores have been loaded."); } }); } else { Debug.Log("Failed to authenticate with Game Center."); } }
public void CreateOddBarScore() { ScoreFactory sf = new ScoreFactory(); IScore score = sf.CreateScore(); score.Measures.Add(sf.CreateMeasure(4, false)); score.Measures.Add(sf.CreateMeasure(3, false)); score.Measures.Add(sf.CreateMeasure(4, false)); score.Measures.Add(sf.CreateMeasure(3, false)); score.Measures.Add(sf.CreateMeasure(3, false)); score.Measures.Add(sf.CreateMeasure(4, false)); ScoreWriter sw = new ScoreWriter(score, 6); Image img = sw.RenderPage(0); img.Save("c:\\tmp\\varBarScore.bmp"); Assert.IsNotNull(img); }
/// <summary>If any of the alpha's of the opponents is worse then the test score: break. /// /// Otherwise update if a better alpha is found for the player. /// </summary> public bool ContinueProccesingAlphas(ScoreCollection test, PlayerType player, out ScoreCollection alphasOut) { foreach (var other in PlayerTypes.Other[player]) { if (Compare(test, other) < 0) { alphasOut = this; return(false); } } IScore s1 = score1; IScore s2 = score2; IScore s3 = score3; IScore s4 = score4; switch (player) { case PlayerType.Hero1: if (Compare(test, player) > 0) { s1 = test.score1; } break; case PlayerType.Hero2: if (Compare(test, player) > 0) { s2 = test.score2; } break; case PlayerType.Hero3: if (Compare(test, player) > 0) { s3 = test.score3; } break; case PlayerType.Hero4: if (Compare(test, player) > 0) { s4 = test.score4; } break; } alphasOut = new ScoreCollection(s1, s2, s3, s4); return(true); }
public void LogisticRegression_Test_iterations_10_learningrate_015() { var desc = loadMetaData(); LearningApi api = new LearningApi(desc); //Real dataset must be defined as object type, because data can be numeric, binary and classification api.UseActionModule <object[][], object[][]>((input, ctx) => { return(loadRealDataSample()); }); // Use mapper for data, which will extract (map) required columns api.UseDefaultDataMapper(); api.UseMinMaxNormalizer(); //run logistic regression for 10 iteration with learningRate=0.15 api.UseLogisticRegression(0.15, 10); var task = api.Run(); IScore score = api.GetScore(); //Errors during each iteration Assert.Equal(Math.Round(score.Errors[0], 5), 0.24236); Assert.Equal(Math.Round(score.Errors[1], 5), 0.23707); Assert.Equal(Math.Round(score.Errors[2], 5), 0.23358); Assert.Equal(Math.Round(score.Errors[3], 5), 0.23001); Assert.Equal(Math.Round(score.Errors[4], 5), 0.22806); Assert.Equal(Math.Round(score.Errors[5], 5), 0.22506); Assert.Equal(Math.Round(score.Errors[6], 5), 0.22409); Assert.Equal(Math.Round(score.Errors[7], 5), 0.22134); Assert.Equal(Math.Round(score.Errors[8], 5), 0.22105); Assert.Equal(Math.Round(score.Errors[9], 5), 0.21840); //LG Model Best Found model in 10 iteration Assert.Equal(Math.Round(score.Weights[0], 5), 0.17820); Assert.Equal(Math.Round(score.Weights[1], 5), 0.28781); Assert.Equal(Math.Round(score.Weights[2], 5), 1.01732); Assert.Equal(Math.Round(score.Weights[3], 5), 0.63396); Assert.Equal(Math.Round(score.Weights[4], 5), -0.26733); Assert.Equal(Math.Round(score.Weights[5], 5), -0.26733); Assert.Equal(Math.Round(score.Weights[6], 5), -0.91266); }
/// <summary> /// 更新榜单排名 /// </summary> /// <param name="boardid"></param> /// <param name="score"></param> public void UpdateRank(string boardid, IScore score) { LevelScore levelScore = GetScoreByBoardId(boardid); if (levelScore.BestScore <= score.value) { levelScore.BestScore = (int)score.value; levelScore.Rank = score.rank; Save2File(); } else { this.ReportScore(boardid, levelScore.BestScore, (ok) => { levelScore.NeedReported = !ok; }); } }
public void LogOutcome(IWord word, IScore score) { int rank; if (record.TryGetValue(word, out rank) == false) { rank = 0; } if (score.IsCorrect) { rank /= 2; } else { rank++; } record [word] = rank; }
/// <summary> /// ハイスコア取得コルーチン /// </summary> /// <param name="rankingBoard"></param> /// <returns></returns> private IEnumerator DoGetHighScore(RankingInfo rankingBoard, string userObjectId, UnityAction <NCMBObject> onCompleted) { var highScoreCheck = new YieldableNcmbQuery <NCMBObject>(rankingBoard.ClassName); highScoreCheck.WhereEqualTo(ObjectId, userObjectId); yield return(highScoreCheck.FindAsync()); var ncmbRecord = highScoreCheck.Result.FirstOrDefault(); // キャッシュ更新 if (ncmbRecord != null) { (var name, var highScore) = GetInformation(ncmbRecord); _highScore = highScore; } onCompleted?.Invoke(ncmbRecord); }
public void LogisticsRegression_Test_iterations_10_learningrate_013() { var desc = loadMetaData(); LearningApi api = new LearningApi(desc); //Real dataset must be defined as object type, because data can be numeric, binary and classification api.UseActionModule <object[][], object[][]>((input, ctx) => { return(loadRealDataSample()); }); // Use mapper for data, which will extract (map) required columns api.UseDefaultDataMapper(); api.UseMinMaxNormalizer(); //run logistic regression for 10 iterations with learningRate=0.13 api.UseLogisticRegression(0.13, 10); api.Run(); IScore score = api.GetScore(); //Errors during each iteration. IF the learningRate is suitable erros is descrising for every next iteration Assert.Equal(Math.Round(score.Errors[0], 5), 0.24278); Assert.Equal(Math.Round(score.Errors[1], 5), 0.23749); Assert.Equal(Math.Round(score.Errors[2], 5), 0.23359); Assert.Equal(Math.Round(score.Errors[3], 5), 0.23010); Assert.Equal(Math.Round(score.Errors[4], 5), 0.22740); Assert.Equal(Math.Round(score.Errors[5], 5), 0.22476); Assert.Equal(Math.Round(score.Errors[6], 5), 0.22271); Assert.Equal(Math.Round(score.Errors[7], 5), 0.22065); Assert.Equal(Math.Round(score.Errors[8], 5), 0.21902); Assert.Equal(Math.Round(score.Errors[9], 5), 0.21739); //LG Model Best Found model in 10 iteration Assert.Equal(Math.Round(score.Weights[0], 5), 0.06494); Assert.Equal(Math.Round(score.Weights[1], 5), 0.21584); Assert.Equal(Math.Round(score.Weights[2], 5), 0.89901); Assert.Equal(Math.Round(score.Weights[3], 5), 0.51497); Assert.Equal(Math.Round(score.Weights[4], 5), -0.30213); Assert.Equal(Math.Round(score.Weights[5], 5), -0.30213); Assert.Equal(Math.Round(score.Weights[6], 5), -0.85624); }
public void CreateScoreWithFlats() { ScoreFactory sf = new ScoreFactory(); IScore score = sf.CreateScore(true); score.Measures.Add(sf.CreateMeasure(4, false)); score.Measures.Add(sf.CreateMeasure(3, false)); score.Measures[0].Notes.Add(sf.CreateNote(0, 13, 4)); score.Measures[0].Notes.Add(sf.CreateNote(2, 14, 4)); score.Measures[0].Notes.Add(sf.CreateNote(4, 15, 4)); score.Measures[0].Notes.Add(sf.CreateNote(14, 39, 4)); score.Measures[0].Notes.Add(sf.CreateNote(14, 40, 4)); score.Measures[1].Notes.Add(sf.CreateNote(0, 42, 4)); ScoreWriter sw = new ScoreWriter(score, 6); Image img = sw.RenderPage(0); img.Save("c:\\tmp\\flatScore.bmp"); Assert.IsNotNull(img); }
// Use this for initialization void Start() { scoreData = new Score(); leaderboardsData = new Leaderboards(); foreach (var loadedLeaderboard in LeaderboardsDataManager.Load()) { leaderboardsData.SetLeaderboard(loadedLeaderboard.leaderboard); } currUI = Instantiate(uiControllerPrefab); currUI.Initialize( leaderboardsData, scoreData, this ); currTetris = Instantiate(tetrisPrefab); }
public void ReceiveScore(int nrUsersNeed, LeaderboardStart startLocation, string leaderboardId, Action <LeaderboardPlayerModel[]> result) { platform.LoadScores( leaderboardId, startLocation, nrUsersNeed, LeaderboardCollection.Public, LeaderboardTimeSpan.AllTime, (data) => { Debug.Log("-> Leaderboard data valid: " + data.Valid); Debug.Log("-> Leaderboard status: " + data.Status); if (data.Valid) { int nrUsersReal = Math.Min(nrUsersNeed, data.Scores.Length); Debug.Log("-> Scores count returned: " + nrUsersReal); //Show LocalUser score IScore playerScore = data.PlayerScore; Debug.LogFormat("LocalPlayer. Name: {0}; Score: {1}", platform.GetUserDisplayName(), playerScore.value); //Get Data about the rest users LeaderboardPlayerModel[] players = new LeaderboardPlayerModel[nrUsersReal]; string[] ids = new string[nrUsersReal]; for (int a = 0; a < nrUsersReal; ++a) { IScore score = data.Scores[a]; players[a] = new LeaderboardPlayerModel(); players[a].score = (int)score.value; players[a].rank = score.rank; ids[a] = score.userID; } LoadUsers(ids, players, result); } else { Debug.LogWarning("Leaderboard: Leaderboard data is invalid."); result.Invoke(null); } }); }
public void UpdateProgress(IScore score) { var totalSquaresForLevelUp = ((Level.CurrentLevel - 1)*_nextLevel.AmountOfSquaresForLevelUp) + Level.SquaresToNextLevel; if (totalSquaresForLevelUp > score.TotalSquaresMade) { Level.SquaresToNextLevel = totalSquaresForLevelUp - score.TotalSquaresMade; } else { var tempTotalSquaresMade = score.TotalSquaresMade; while (tempTotalSquaresMade >= _nextLevel.AmountOfSquaresForLevelUp) { tempTotalSquaresMade -= _nextLevel.AmountOfSquaresForLevelUp; Level.CurrentLevel++; GameEvents.Raise(new LevelUpEvent(Level.CurrentLevel - 1, Level.CurrentLevel)); } Level.SquaresToNextLevel = _nextLevel.AmountOfSquaresForLevelUp - tempTotalSquaresMade; } }
public Result<IScore> AttachMusicXml(IScore aScore, XDoc xdoc, bool overwriteMusicXmlValues, Result<IScore> aResult) { Coroutine.Invoke(AttachMusicXmlHelper, aScore, xdoc, overwriteMusicXmlValues, new Result<IScore>()).WhenDone( aResult.Return, aResult.Throw ); return aResult; }
/// <summary> /// Callback for receiving the list of scores. /// </summary> /// <param name='scores'> /// Scores. /// </param> void RetrieveScoreCallback(IScore[] scores) { this.scores = scores; }
/// <summary> /// Displays score data. /// </summary> /// <param name="scores">Scores.</param> static void DisplayScoreData (IScore[] scores) { foreach (var score in scores) { GUILayout.BeginHorizontal(); GUILayout.Label(score.rank.ToString()); GUILayout.Label(LumosSocialGUI.defaultAvatarIcon); GUILayout.BeginVertical(); GUILayout.Label(score.userID); GUILayout.Label(score.value.ToString()); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } }
public bool HasAuthorization(IScore aScore) { ArgCheck.NotNull("aScore", aScore); return Context.Current.User != null && (IsCreator(aScore) || IsCollaborator(aScore)); }
public void SetScores(IScore[] scores) { this.m_Scores = scores; }
public Result<IScore> Update(string aScoreId, string aScoreRev, IScore aDoc, Result<IScore> aResult) { Coroutine.Invoke(UpdateHelper, aScoreId, aScoreRev, aDoc, new Result<IScore>()).WhenDone( aResult.Return, aResult.Throw ); return aResult; }
public void SetLocalUserScore(IScore score){}
public void SetScores(IScore[] scores){}
private Yield AttachMusicXmlHelper(IScore aScore, XDoc aMusicXmlDoc, bool overwriteMusicXmlValues, Result<IScore> aResult) { XScore musicXml = new XScore(aMusicXmlDoc); bool hasNotes = false; foreach (var p in musicXml.Parts) { foreach (var m in p.Measures) { if (m.Notes.Count() > 0) { hasNotes = true; break; } } if(hasNotes) break; } if(!hasNotes) { aResult.Return(aScore); yield break; } if (overwriteMusicXmlValues) { aScore.CodageMelodiqueRISM = musicXml.GetCodageMelodiqueRISM(); aScore.CodageParIntervalles = musicXml.GetCodageParIntervalle(); //aScore.Title = musicXml.MovementTitle; //aScore.Composer = musicXml.Identification.Composer; aScore.Verses = musicXml.GetText(); } Result<IScore> result = new Result<IScore>(); if (aScore.Id != null) { yield return Update(aScore.Id, aScore.Rev, aScore, result); } else { yield return Insert(aScore, result); } using(TemporaryFile inputFile = new TemporaryFile(".xml",false)) using(TemporaryFile outputFile = new TemporaryFile(".png",false)) { theLogger.Info("Saving xdoc to " + inputFile.Path); File.Delete(inputFile.Path); aMusicXmlDoc.Save(inputFile.Path); theLogger.Info("XDoc saved"); theLogger.Info("Getting Converter and converting"); //yield return Context.Current.Instance.SourceController.Exists("bla", new Result<bool>()); IList<string> pngsFilePath = Context.Current.Instance.ConverterFactory.GetConverter(MimeType.PNG).Convert(inputFile.Path, outputFile.Path); int i = 1; foreach (string pngFile in pngsFilePath) { using(Stream pngStream = File.OpenRead(pngFile)) { yield return AddAttachment(result.Value.Id, pngStream,pngStream.Length, "$partition" + i + ".png", new Result<bool>()); } File.Delete(pngFile); i++; } } //attach music xml to the created /updated score using(Stream stream = new MemoryStream(aMusicXmlDoc.ToBytes())) { yield return AddAttachment(result.Value.Id, stream,stream.Length, "$musicxml.xml", new Result<bool>()); } aResult.Return(result.Value); }
private static bool IsCreator(IScore aDoc) { return aDoc.CreatorId == Context.Current.User.Id; }
public string ToJson(IScore aScore) { return theScoreDataMapper.ToJson(aScore); }
public void SetLocalUserScore(IScore score) { this.m_LocalUserScore = score; }
private void OnRequestScoresCompleted(AGSRequestScoresResponse response) { // Put scores in leaderboard. AGSSocialLeaderboard leaderboard = leaderboardForRequest.ContainsKey (response.userData) ? leaderboardForRequest[response.userData] : null; if (null != leaderboard && !response.IsError()) { leaderboard.scores = new IScore[response.scores.Count]; for (int i = 0; i < response.scores.Count; i++) { leaderboard.scores[i] = new AGSSocialLeaderboardScore(response.scores[i], response.leaderboard); } } // Handle any callbacks Action<bool> callback = simpleCallbacks.ContainsKey(response.userData) ? simpleCallbacks[response.userData] : null; if (null != callback) { callback(!response.IsError()); } Action<IScore[]> scoreCallback = loadScoresCallbacks.ContainsKey (response.userData) ? loadScoresCallbacks[response.userData] : null; if (null != scoreCallback) { IScore[] scores = new IScore[response.scores.Count]; for (int i = 0; i < response.scores.Count; i++) { scores[i] = new AGSSocialLeaderboardScore(response.scores[i], response.leaderboard); } scoreCallback(scores); } // cleanup leaderboardForRequest.Remove (response.userData); simpleCallbacks.Remove (response.userData); }
public ScoringEngine(IScore scoreCounter) { _scoreCounter = scoreCounter; }
internal void SetLocalUserScore(PlayGamesScore score) { mLocalUserScore = score; }
private Yield UpdateHelper(string id, string rev, IScore aDoc, Result<IScore> aResult) { //Check if a score with this id exists. Result<IScore> validScoreResult = new Result<IScore>(); yield return theScoreDataMapper.Retrieve(aDoc.Id, validScoreResult); if (validScoreResult.Value == null) { aResult.Throw(new ArgumentException()); yield break; } //Check if the sources in the score exists and are not null. Coroutine.Invoke(CheckSources, aDoc, new Result()); //Update and return the updated score. Result<IScore> scoreResult = new Result<IScore>(); yield return theScoreDataMapper.Update(id, rev, aDoc, scoreResult); aResult.Return(scoreResult.Value); }
private static bool IsCollaborator(IScore aDoc) { IUser current = Context.Current.User; foreach (string collab in aDoc.CollaboratorsId) { if (current.Groups.Contains(collab) || collab == current.Id) return true; } return false; }
private static Yield CheckSources(IScore aScore, Result aResult) { // if this source exists if (aScore.TextualSource != null) { if (aScore.TextualSource.SourceId == null) { aResult.Throw(new ArgumentException()); yield break; } Result<bool> validSourceResult = new Result<bool>(); yield return Context.Current.Instance.SourceController.Exists(aScore.TextualSource.SourceId, validSourceResult); if (!validSourceResult.Value) { aResult.Throw(new ArgumentException()); yield break; } } //if this source exists if (aScore.MusicalSource != null) { if (aScore.MusicalSource.SourceId == null) { aResult.Throw(new ArgumentException()); yield break; } Result<bool> validSourceResult = new Result<bool>(); yield return Context.Current.Instance.SourceController.Exists(aScore.MusicalSource.SourceId, validSourceResult); if (!validSourceResult.Value) { aResult.Throw(new ArgumentException()); yield break; } } aResult.Return(); }
private Yield CreateHelper(IScore aDoc, Result<IScore> aResult) { //Check that the sources aren't null and does exists yield return Coroutine.Invoke(CheckSources, aDoc, new Result()); //Insert a the score and return Result<IScore> resultCreate = new Result<IScore>(); yield return theScoreDataMapper.Create(aDoc, resultCreate); aResult.Return(resultCreate.Value); }