コード例 #1
0
        public async Task <bool> PostEvaluation(Evaluation2 evaluation)
        {
            try
            {
                var series = await _db.Series.SingleOrDefaultAsync((s) => s.Id == evaluation.Series.Id);

                var user = await _db.User.SingleOrDefaultAsync((s) => s.Id == evaluation.User.Id);

                if (series is null || user is null)
                {
                    return(false);
                }
                if (!await EvaluationExist(evaluation, 0))
                {
                    evaluation.Series = series;
                }
                evaluation.User = user;

                await _db.AddAsync(evaluation);

                await _db.SaveChangesAsync();

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
        private async Task <bool> EvaluationExist(Evaluation2 evaluation, int id)
        {
            var count = await _db.Evaluation.CountAsync(ev => ev.Series.Id == evaluation.Series.Id && ev.User.Id == evaluation.User.Id &&
                                                        ev.EvaluationId != id);

            return(count > 1 ? false : true);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: shayan1998/Shutranj
        static void TestIDAS()
        {
            Board board = new Board();

            TestingHelper.MakeSomeMoves(board);
            Evaluation2.Initialise();

            Stopwatch sw = new Stopwatch();

            sw.Start();
            Tuple <UInt16, int, long, int> bestMoveAndScore = AlphaBeta2.IDASParallel(board, Side.White);

            // AlphaBeta2.IterativeDeepeningParallel(board, Side.White);


            //Tuple<UInt16, int> bestMoveAndScore = AlphaBeta2.RootAlphaBetaTTParallel(board, Side.White, 6);
            //bestMoveAndScore = AlphaBeta2.RootAlphaBetaTTParallel(board, Side.White, 7);
            //, -120, -60);
            sw.Stop();

            //Console.WriteLine("Best Move For White: {0}. Depth: {1}. Score:{2}. TIME: {3} milliseconds",
            //   board.ConvertToAlgebraicNotation(bestMoveAndScore.Item1), 7, bestMoveAndScore.Item2, sw.ElapsedMilliseconds);

            Console.WriteLine("Best Move For White: {0}. Depth: {1}. Score:{2}. TIME: {3} milliseconds",
                              board.ConvertToAlgebraicNotation(bestMoveAndScore.Item1), bestMoveAndScore.Item2, bestMoveAndScore.Item4, sw.ElapsedMilliseconds);
        }