Пример #1
0
 /// <summary>
 /// Creates a basic search suggestion for the given suggest result.
 /// </summary>
 private SearchSuggestion SuggestResultToSearchSuggestion(SuggestResult r)
 {
     return(new SearchSuggestion(r.Label, this)
     {
         IsCollection = r.IsCollection, UnderlyingObject = r
     });
 }
Пример #2
0
        private void Suggest(IHttpRequest request, IHttpResponse response)
        {
            using (ITabularWriter writer = WriterForFormat("json", response))
            {
                try
                {
                    string query = Require(request, "q");

                    DateTime      asOfDate = ParseOrDefault(request.QueryString["asof"], _xDatabaseContext.RequestedAsOfDateTime);
                    SuggestResult result   = _suggester.Suggest(query, asOfDate);

                    // If the query is valid and there are no extra values valid next, just return valid
                    if (result.IsValid == true && result.Context == null)
                    {
                        writer.SetColumns(new string[] { "Valid" });
                        writer.Write(true);
                        writer.NextRow();
                    }
                    else
                    {
                        WriteException(result, writer);
                    }
                }
                catch (Exception ex)
                {
                    WriteException(ex, writer, false);
                }
            }
        }
Пример #3
0
 private static string Values(SuggestResult result)
 {
     if (result.Context == null || result.Context.ValidValues == null)
     {
         return(null);
     }
     return(string.Join("|", result.Context.ValidValues.OrderBy((s) => s)));
 }
        /// <summary>
        /// Method returns a task that returns a list of suggestion objects
        /// that are associated to the <paramref name="input"/> string
        /// and given <paramref name="location"/> object.
        ///
        /// This sample is really easy because it simply takes the input
        /// string and add an output as suggestion to the given input.
        ///
        /// This always returns 2 suggestions.
        /// </summary>
        /// <param name="location"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        public Task <ISuggestResult> SuggestAsync(object location,
                                                  string input)
        {
            var result = new SuggestResult();

            // returns a collection of anynymous objects
            // each with a Header and Value property
            result.Suggestions.Add(new { Header = input + "-add xyz", Value = input + "xyz" });
            result.Suggestions.Add(new { Header = input + "-add abc", Value = input + "abc" });

            return(Task.FromResult <ISuggestResult>(result));
        }
Пример #5
0
        public async Task UpdateSearch()
        {
            // Get the text in the search bar
            string enteredText = SearchTerm;

            // Clear existing marker
            MapView.GraphicsOverlays.Clear();

            // Return gracefully if the textbox is empty or the geocoder isn't ready
            if (String.IsNullOrWhiteSpace(enteredText) || _geocoder == null)
            {
                return;
            }

            try
            {
                // Get suggestions based on the input text
                IReadOnlyList <SuggestResult> suggestions = await _geocoder.SuggestAsync(enteredText);

                // Stop gracefully if there are no suggestions
                if (suggestions.Count < 1)
                {
                    return;
                }

                // Get the full address for the first suggestion
                SuggestResult firstSuggestion           = suggestions.First();
                IReadOnlyList <GeocodeResult> addresses = await _geocoder.GeocodeAsync(firstSuggestion.Label);

                // Stop gracefully if the geocoder does not return a result
                if (addresses.Count < 1)
                {
                    return;
                }

                // Place a marker on the map - 1. Create the overlay
                GraphicsOverlay resultOverlay = new GraphicsOverlay();
                // 2. Get the Graphic to display
                Graphic point = await GraphicForPoint(addresses.First().DisplayLocation);

                // 3. Add the Graphic to the GraphicsOverlay
                resultOverlay.Graphics.Add(point);
                // 4. Add the GraphicsOverlay to the MapView
                MapView.GraphicsOverlays.Add(resultOverlay);

                // Update the map extent to show the marker
                MapView.SetViewpoint(new Viewpoint(addresses.First().Extent));
            }
            catch (Exception e)
            {
                await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK");
            }
        }
        private async void UpdateSearch()
        {
            // Get the text in the search bar.
            string enteredText = _addressSearchBar.Text;

            // Clear existing marker.
            _myMapView.GraphicsOverlays.Clear();

            // Return gracefully if the textbox is empty or the geocoder isn't ready.
            if (String.IsNullOrWhiteSpace(enteredText) || _geocoder == null)
            {
                return;
            }

            try
            {
                // Get suggestions based on the input text.
                IReadOnlyList <SuggestResult> suggestions = await _geocoder.SuggestAsync(enteredText);

                // Stop gracefully if there are no suggestions.
                if (suggestions.Count < 1)
                {
                    return;
                }

                // Get the full address for the first suggestion.
                SuggestResult firstSuggestion           = suggestions.First();
                IReadOnlyList <GeocodeResult> addresses = await _geocoder.GeocodeAsync(firstSuggestion.Label);

                // Stop gracefully if the geocoder does not return a result.
                if (addresses.Count < 1)
                {
                    return;
                }

                // Place a marker on the map - 1. Create the overlay.
                GraphicsOverlay resultOverlay = new GraphicsOverlay();
                // 2. Get the Graphic to display.
                Graphic point = await GraphicForPoint(addresses.First().DisplayLocation);

                // 3. Add the Graphic to the GraphicsOverlay.
                resultOverlay.Graphics.Add(point);
                // 4. Add the GraphicsOverlay to the MapView.
                _myMapView.GraphicsOverlays.Add(resultOverlay);

                // Update the map extent to show the marker.
                _myMapView.SetViewpoint(new Viewpoint(addresses.First().Extent));
            }
            catch (Exception e)
            {
                new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
Пример #7
0
        private void SuggestionChosen(object sender, SelectionChangedEventArgs e)
        {
            SuggestResult suggestion = SuggestionList.SelectedItem as SuggestResult;

            if (suggestion == null)
            {
                return;
            }

            AddressTextBox.Text = suggestion.Label;

            _viewModel.ShowAddressLocation(suggestion);
        }
Пример #8
0
        public void Suggest_FullErrorFidelity()
        {
            SampleDatabase.EnsureBuilt();
            QuerySuggester suggester = new QuerySuggester(SampleDatabase.XDatabaseContext);

            SuggestResult result = suggester.Suggest(@"
                read UsageError.WebRequest.MissingColumn");

            Assert.AreEqual(false, result.IsValid);
            Assert.AreEqual("UsageError.WebRequest.MissingColumn", result.Context.TableName);
            Assert.AreEqual(2, result.Context.QueryLineNumber);
            Assert.AreEqual("where {Expression}", result.Context.Usage);
            Assert.AreEqual("BadColumnName", result.Context.InvalidValue);
            Assert.AreEqual("[Column]", result.Context.InvalidValueCategory);
            Assert.AreEqual(s_columnNames, string.Join("|", result.Context.ValidValues));
        }
Пример #9
0
        private static string Values(SuggestResult result)
        {
            if (result.Context == null)
            {
                return(null);
            }

            var values = result.Context.FilteredValues;

            if (values == null)
            {
                return(null);
            }

            return(string.Join("|", result.Context.FilteredValues));
        }
Пример #10
0
        public void Suggest_FullErrorFidelity()
        {
            SampleDatabase.EnsureBuilt();
            QuerySuggester suggester = new QuerySuggester(SampleDatabase.XDatabaseContext);

            SuggestResult result = suggester.Suggest(@"
                read WebRequest
                where [BadColumnName] != ""X""");

            Assert.AreEqual(false, result.IsValid);
            Assert.AreEqual(null, result.Context.TableName);
            Assert.AreEqual(3, result.Context.QueryLineNumber);
            Assert.AreEqual("where {Expression}", result.Context.Usage);
            Assert.AreEqual("[BadColumnName]", result.Context.InvalidValue);
            Assert.AreEqual("[Column]", result.Context.InvalidValueCategory);
            Assert.AreEqual("[ClientBrowser]|[ClientIP]|[ClientOs]|[ClientRegion]|[DataCenter]|[DaysSinceJoined]|[EventTime]|[HttpMethod]|[HttpStatus]|[ID]|[IsPremiumUser]|[Protocol]|[RequestBytes]|[ResponseBytes]|[ServerName]|[ServerPort]|[TimeTakenMs]|[UriStem]|[UserGuid]|[UserName]|[WasCachedResponse]|[WasEncrypted]", string.Join("|", result.Context.ValidValues));
        }
Пример #11
0
        /// <summary>
        /// Deplacement sur le resultat du geocodage au clic sur la liste
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        async private void suggestList_Selected(object sender, RoutedEventArgs e)
        {
            if (suggestList.SelectedItem != null)
            {
                // on récupère le suggest result
                SuggestResult currentSuggest = suggestList.SelectedItem as SuggestResult;
                // et on geocode avec ce résultat.
                IReadOnlyList <GeocodeResult> geocodeResults = await myLocator.GeocodeAsync(currentSuggest);

                // si on récupère bien un résultat
                if (geocodeResults.Count > 0)
                {
                    // on demande a la vue de zoomer sur l'étendue du premier résultat.
                    await mapView1.SetViewpointGeometryAsync(geocodeResults[0].Extent);
                }
            }
        }
Пример #12
0
        private async void UpdateSearch()
        {
            // Get the text in the search bar
            string enteredText = SearchBox.Text;

            // Clear existing marker
            MyMapView.GraphicsOverlays.Clear();

            // Return gracefully if the textbox is empty or the geocoder isn't ready
            if (String.IsNullOrWhiteSpace(enteredText) || _geocoder == null)
            {
                return;
            }

            // Get suggestions based on the input text
            IReadOnlyList <SuggestResult> suggestions = await _geocoder.SuggestAsync(enteredText);

            // Stop gracefully if there are no suggestions
            if (suggestions.Count < 1)
            {
                return;
            }

            // Get the full address for the first suggestion
            SuggestResult firstSuggestion           = suggestions.First();
            IReadOnlyList <GeocodeResult> addresses = await _geocoder.GeocodeAsync(firstSuggestion.Label);

            // Stop gracefully if the geocoder does not return a result
            if (addresses.Count < 1)
            {
                return;
            }

            // Place a marker on the map - 1. Create the overlay
            GraphicsOverlay resultOverlay = new GraphicsOverlay();
            // 2. Get the Graphic to display
            Graphic point = await GraphicForPoint(addresses.First().DisplayLocation);

            // 3. Add the Graphic to the GraphicsOverlay
            resultOverlay.Graphics.Add(point);
            // 4. Add the GraphicsOverlay to the MapView
            MyMapView.GraphicsOverlays.Add(resultOverlay);

            // Update the map extent to show the marker
            await MyMapView.SetViewpointGeometryAsync(addresses.First().Extent);
        }
Пример #13
0
        private void AddressTextChanged(object sender, TextChangedEventArgs e)
        {
            string address = AddressTextBox.Text.Trim();

            if (string.IsNullOrEmpty(address) || address.Length < 3)
            {
                return;
            }

            SuggestResult suggestion = SuggestionList.SelectedItem as SuggestResult;

            if (suggestion != null && suggestion.Label == address)
            {
                return;
            }

            _viewModel.GetAddressSuggestions(address);
        }
Пример #14
0
        public async void ShowAddressLocation(SuggestResult suggestion)
        {
            IReadOnlyList <GeocodeResult> matches = await _geocoder.GeocodeAsync(suggestion);

            GeocodeResult bestMatch = (from match in matches orderby match.Score select match).FirstOrDefault();

            if (bestMatch == null)
            {
                return;
            }

            GraphicsOverlay matchOverlay = MapView.GraphicsOverlays.FirstOrDefault();

            matchOverlay.Graphics.Clear();

            Graphic matchGraphic = new Graphic(bestMatch.DisplayLocation);

            matchGraphic.Symbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Cyan, 16);
            matchOverlay.Graphics.Add(matchGraphic);

            MapView.SetViewpointAsync(new Viewpoint(bestMatch.DisplayLocation, 24000));
        }
 /// <summary>
 ///
 /// </summary>
 public SuggestResultViewModel(SuggestResult <ECADocument> suggestedResult)
 {
     Contract.Requires(suggestedResult != null, "The suggested result must not be null.");
     this.Document = new ECADocumentViewModel(suggestedResult.Document);
     this.Text     = suggestedResult.Text;
 }
Пример #16
0
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        static void Main()
        {
            const int N = 5000;

            Stopwatch sw = new Stopwatch();
            ////Tile[] tiles = { new WanTile(2), new WanTile(1), new WanTile(1), new WanTile(1), new WanTile(2), new WanTile(3), new WanTile(4), new WanTile(5), new WanTile(6), new WanTile(7), new WanTile(8), new WanTile(9), new WanTile(9), new WanTile(9) };
            //var game = new TenhouGame();
            //var tiles = game.GetTiles(Mahjong.Parse("一万 一万 一万 一万 二万 二万 二万 三万 三万 三万 三万 四万 四万 二万"));
            ////var tiles = game.GetTiles(Mahjong.Parse("一万 一万 一万 一万 二万 三万 五万 六万 七万 八万 九万 九万 九万 四万 "));
            //////var tiles = game.GetTiles(Mahjong.Parse("一万 一万 二万 三万 一万"));
            ////sw.Restart();
            //List<Group[]> result = null;
            ////for (int i = 0; i < N; i++)
            //result = Mahjong.Analysis(game, tiles);
            ////sw.Stop();
            ////Console.WriteLine($"平均耗时:{TimeSpan.FromTicks(sw.ElapsedTicks / N)}");
            //Console.WriteLine($"返回数量:{result.Count}");
            //foreach (Group[] groups in result) {
            //	Console.Write($"[{groups[0]}]");
            //	for (int i = 1; i < groups.Length; i++) {
            //		Console.Write($", [{groups[i]}]");
            //	}
            //	Console.WriteLine();
            //}

            ////Tile[] tiles2 = { new WanTile(1), new WanTile(1), new WanTile(1), new WanTile(2), new WanTile(3), new WanTile(4), new WanTile(5), new WanTile(6), new WanTile(7), new WanTile(8), new WanTile(9), new WanTile(9), new WanTile(9) };
            //var tiles2 = Mahjong.Parse("一万 一万 一万 二万 三万 四万 五万 六万 七万 八万 九万 九万 九万");

            //sw.Restart();
            //List<BaseTile> result2 = null;
            //for (int i = 0; i < N; i++)
            //	result2 = Mahjong.AllReadyHand(tiles2);
            //sw.Stop();
            //Console.WriteLine($"平均耗时:{TimeSpan.FromTicks(sw.ElapsedTicks / N)}");
            //foreach (var tile in result2) {
            //	Console.WriteLine(tile);
            //}
            //Console.WriteLine();

            //SortedTiles tiles3 = new SortedTiles(Mahjong.CreateRandomTiles(13));
            // Tile[] tiles3 = { new WanTile(1), new WanTile(2), new WanTile(3), new SouTile(1), new SouTile(3), new SouTile(5), new PinTile(2), new PinTile(4), new PinTile(8), new PinTile(9), new PinTile(9), new KanjiTile(KanjiTile.Kanji.南), new KanjiTile(KanjiTile.Kanji.南), };
            // Tile[] tiles3 = Mahjong.Parse("一万 三万 五万 六万 九万 九万 二饼 五饼 九饼 三索 七索 东 中");
            // Tile[] tiles3 = Mahjong.Parse("一万 一万 一万 二万 三万 四万 五万 六万 七万 八万 九万 九万 一索");
            // Tile[] tiles3 = Mahjong.Parse("一万 九万 一饼 一饼 九饼 一索 九索 南 北 白 白 发 中");
            //foreach (Tile tile in tiles3) {
            //	Console.Write($"{tile} ");
            //}
            //Console.WriteLine();
            //sw.Restart();
            //int listenNumber = 0;
            //for (int i = 0; i < N; i++)
            //	listenNumber = Mahjong.ListenNumber(tiles3);
            //sw.Stop();
            //Console.WriteLine($"平均耗时:{TimeSpan.FromTicks(sw.Elapsed.Ticks / N)}");
            //Console.WriteLine($"最小向听数:{listenNumber}");
            ////Console.WriteLine($"SBT操作次数:{Mahjong.sbtCount}");
            ////Console.WriteLine($"SBT操作耗时:{Mahjong.sw.Elapsed}");

            ////Application.EnableVisualStyles();
            ////Application.SetCompatibleTextRenderingDefault(false);
            ////Application.Run(new Form1());

            ////Tile[] tiles = Mahjong.Parse("一万 二万 一饼 一饼 九饼 一索 九索 南 北 白 白 发 中");
            ////SortedTiles sortedTiles = new SortedTiles(tiles);
            ////Console.WriteLine(sortedTiles.HasNextTile(tiles[0]));
            ////Console.WriteLine(sortedTiles.DifferentNext(tiles[2]));

            ////sortedTiles.Remove(tiles[2]);
            ////sortedTiles.Add(tiles[0]);
            ////Console.WriteLine("===");
            ////foreach (var tile in sortedTiles) {
            ////	Console.WriteLine(tile);
            ////}

            //for (int m = 0; m < 100; m++) {
            //	SortedTiles tiles = new SortedTiles(Mahjong.CreateRandomTiles(13));
            //	// SortedTiles tiles = new SortedTiles(Mahjong.Parse("二万 五万 六万 七万 九万 三饼 五索 六索 九索   东   南   白   中"));
            //	foreach (Tile tile in tiles) {
            //		Console.Write(tile is KanjiTile ? $"  {tile} " : $"{tile} ");
            //	}

            //	sw.Restart();
            //	int listenNumber = 0;
            //	for (int i = 0; i < N; i++)
            //		listenNumber = Mahjong.ListenNumber(tiles);
            //	Console.Write($"| {listenNumber} | ");
            //	Console.WriteLine($"{TimeSpan.FromTicks(sw.ElapsedTicks / N)}");
            //	sw.Stop();
            //}

            // 三万 三万 三万 九饼 九饼 三索 三索 三索 六索   南   白   白   中
            //var tiles = Mahjong.Parse("一万 一万 二万 二万 二万 三万 四万 五万 六万 七万 中 发 发");
            //var tiles = Mahjong.Parse("一万 一万 一万 二万 三万 四万 五万 六万 七万 八万 九万 九万 白");
            //int listenNumber = 0;
            //sw.Restart();
            //for (int i = 0; i < N; i++) {
            //	listenNumber = Mahjong.ListenNumber(tiles);
            //}
            //sw.Stop();
            //Console.WriteLine(listenNumber);
            //Console.WriteLine(sw.Elapsed);
            //Console.WriteLine(TimeSpan.FromTicks(sw.Elapsed.Ticks / N));


            //for (int m = 0; m < 30; m++) {
            //	while (true) {
            //		SortedTiles tiles = new SortedTiles(Mahjong.CreateRandomTiles(13));
            //		int listenNumber = Mahjong.ListenNumber(tiles);
            //		if (listenNumber == 0) {
            //			foreach (Tile tile in tiles) {
            //				Console.Write(tile is KanjiTile ? $"  {tile} " : $"{tile} ");
            //			}
            //			Console.WriteLine();
            //			break;
            //		}
            //	}
            //}

            //for (int k = 0; k < 300; k++) {
            //	var tiles = new SortedTilesEnumerator(Mahjong.CreateRandomTiles(14));
            //	int r1 = 0, r2 = 0;
            //	TimeSpan t1 = TimeSpan.Zero, t2 = TimeSpan.Zero;

            //	sw.Restart();
            //	r1 = Mahjong.ListenNumber2(tiles) + 1;
            //	sw.Stop();
            //	t1 = sw.Elapsed;

            //	for (int i = 0; i < r1; i++) Console.Write('☆');
            //	for (int i = r1; i < 7; i++) Console.Write('★');
            //	Console.Write($"{t1} ");
            //	foreach (var t in tiles) Console.Write($"{t}");
            //	Console.WriteLine();

            //	// if (r1 >= 3) break;
            //}

            //int c1 = 0, c2 = 0;
            //TimeSpan tt1 = TimeSpan.Zero, tt2 = TimeSpan.Zero;
            //while (true) {
            //	int r1 = 0, r2 = 0;
            //	TimeSpan t1, t2;
            //	//var tiles = new SortedTilesEnumerator(Mahjong.CreateRandomTiles(14));
            //	var tiles = Mahjong.Parse("一万 一万 一万 二万 三万 四万 五万 六万 七万 八万 九万 一索 一索 一索");
            //	//var tiles = Mahjong.Parse("一万 一万 一万 一万");
            //	sw.Restart();
            //	r1 = Mahjong.ListenNumber(tiles);
            //	sw.Stop();
            //	t1 = sw.Elapsed;
            //	sw.Restart();
            //	r2 = Mahjong.ListenNumber2(tiles);
            //	sw.Stop();
            //	t2 = sw.Elapsed;

            //	tt1 += t1;
            //	tt2 += t2;

            //	if (r1 != r2) {
            //		Console.WriteLine($"{r1},{r2}");
            //		Console.WriteLine(string.Join<BaseTile>("", tiles));
            //		Console.WriteLine(TimeSpan.FromTicks(t1.Ticks / N));
            //		Console.WriteLine(TimeSpan.FromTicks(t2.Ticks / N));
            //		break;
            //	} else {
            //		//if (t1 < t2) c1++; else c2++;
            //		//Console.Write($"\r{c1},{c2}");
            //		//Console.Write($"\r{tt1},{tt2}");

            //		Console.WriteLine($"{r1},{r2}");
            //		Console.WriteLine(string.Join<BaseTile>("", tiles));
            //		Console.WriteLine(TimeSpan.FromTicks(t1.Ticks / N));
            //		Console.WriteLine(TimeSpan.FromTicks(t2.Ticks / N));
            //		break;
            //	}
            //}



            //var tiles = Mahjong.Parse("七万 八万 九万 五饼 五饼 七饼 八饼 一索 二索 三索 七索 八索 九索 东");
            //var tiles = Mahjong.Parse(" 一万 一万 一万 二万 二万 二万 二万 三万 三万 三万 三万 四万 四万 一万");

            //Console.WriteLine(string.Join("", tiles.Select(t => t.BaseTile).OrderBy(t => t)));
            //Tile last = tiles[tiles.Length - 1];
            //last.Owner = Wind.东;
            //var a = game.Analysis(tiles);
            //var score = game.GetScore(tiles, null, YakuEnvironment.门前清 | YakuEnvironment.自摸 | YakuEnvironment.场风东 | YakuEnvironment.自风东);
            //var basePoint = game.ScoreSystem.GetBasePoint(score);
            //var point = game.ScoreSystem.GetPoint(basePoint, 2);


            //var tiles = game.GetTiles(Mahjong.Parse(" 二万 二万 三万 三万 四万 四万 五万 五万 六万 六万 七万 七万 八万 八万"));
            //var tiles = game.GetTiles(Mahjong.Parse(" 一万 一万 一万 二万 二万 二万 二万 三万 三万 三万 三万 四万 四万 一万"));
            //var tiles = game.GetTiles(Mahjong.Parse(" 一万 一万 一万 二万 二万 二万 三万 三万 三万 四万 四万 四万 五万 五万"));
            //var tiles = game.GetTiles(Mahjong.Parse("东 东 东 南 南 南 西 西 西 北 北 北 发 发"));
            //var tiles = game.GetTiles(Mahjong.Parse("东 东 南 南 西 西 北 北 白 白 发 发 中 中"));
            var game = Game.Instance;
            //var tiles = new SortedTilesEnumerator(game.GetRandomTiles(14).Select(t => t.BaseTile));
            //var tiles = BaseTile.ParseSuffixExpr("1112340677899m9m");
            //var s = game.Syanten(tiles);

            var tiles = BaseTile.ParseSuffixExpr("22334456677885m");

            //var tiles = BaseTile.ParseSuffixExpr("123789m123s999s11z");
            //var tiles = BaseTile.ParseSuffixExpr("1112345678999m5m");
            //var tiles = BaseTile.ParseSuffixExpr("11122233344554m");
            //var tiles = BaseTile.ParseSuffixExpr("2233445566788m7m");
            //var tiles = BaseTile.ParseSuffixExpr("11122233344455z");
            //var tiles = BaseTile.ParseSuffixExpr("18m23p19s1234567z1m");
            Console.WriteLine(string.Concat <BaseTile>(tiles));
            Console.WriteLine(BaseTile.ToSuffixExpr(tiles));
            Console.WriteLine();
            SuggestResult suggest = null;

            sw.Restart();
            for (int i = 0; i < N; i++)
            {
                suggest = game.Suggest(tiles);
            }
            sw.Stop();
            Console.WriteLine($"提供建议平均耗时:{TimeSpan.FromTicks(sw.Elapsed.Ticks / N)}");
            Console.WriteLine(suggest);
            Console.WriteLine(string.Join(Environment.NewLine, suggest.Values));
            Console.WriteLine();

            IReadOnlyList <AdvancedGroups> a = null;
            var tiles2 = game.GetTiles(tiles).ToArray();

            tiles2.Last().Owner = Wind.东;
            if (game.TestRon(tiles2))
            {
                sw.Restart();
                for (int i = 0; i < N; i++)
                {
                    a = game.Analysis(tiles2);
                }
                sw.Stop();
                if (a != null)
                {
                    Console.WriteLine($"牌面拆解平均用时:{TimeSpan.FromTicks(sw.Elapsed.Ticks / N)}");
                    Console.WriteLine(string.Join(Environment.NewLine, a));
                    Console.WriteLine();
                }
                var score = game.GetScore(tiles2, null, YakuEnvironment.门前清 | YakuEnvironment.自摸 | YakuEnvironment.自风东);
                Console.WriteLine(score);
                Console.WriteLine(string.Join <YakuValue>(Environment.NewLine, score.YakuValues));
                Console.WriteLine();
            }
        }
Пример #17
0
 private void WriteException(SuggestResult result, ITabularWriter writer)
 {
     WriteException(result.Context, result.IsValid, writer);
 }