Beispiel #1
0
    public AnalysisGraph getAnalysisGraph()
    {
        AnalysisGraph toReturn = new AnalysisGraph();

        Dictionary <Vector3, AnalysisNode> tempIndex = new Dictionary <Vector3, AnalysisNode>();

        foreach (VoronoiNode node in workingVoronoi)
        {
            AnalysisNode temp = new AnalysisNode(node.getPosition(), node.getRadius());
            toReturn.addNode(temp);
            tempIndex.Add(node.getPosition(), temp);
        }

        foreach (VoronoiNode node in workingVoronoi)
        {
            AnalysisNode temp = tempIndex[node.getPosition()];

            foreach (VoronoiNode neighbour in node.getNeighbours())
            {
                if (tempIndex.ContainsKey(neighbour.getPosition()))
                {
                    temp.addNeighbour(tempIndex[neighbour.getPosition()]);
                }
            }
        }

        return(toReturn);
    }
Beispiel #2
0
        static void ShowMobilityScorePairs()
        {
            Game game = new Game();

            game.Begin(null, null, 10);

            AnalysisGraph analysisGraph = new AnalysisGraph();

            analysisGraph.BuildAnalysis(game.CurrentBoard.PieceGrid, game.CurrentPlayer);

            foreach (var p in game.CurrentBoard.PieceGrid.Amazon1Points.Union(game.CurrentBoard.PieceGrid.Amazon2Points))
            {
                Console.WriteLine($"{analysisGraph.W:0.00},{analysisGraph.AmazonMobilityScores[p]:0.00}");
            }

            Random rnd = new Random();

            while (!game.IsComplete())
            {
                int randomMoveNum = rnd.Next(0, game.CurrentMoves.Count - 1);
                game.ApplyMove(game.CurrentMoves.ElementAt(randomMoveNum));

                analysisGraph.BuildAnalysis(game.CurrentBoard.PieceGrid, game.CurrentPlayer);

                foreach (var p in game.CurrentBoard.PieceGrid.Amazon1Points.Union(game.CurrentBoard.PieceGrid.Amazon2Points))
                {
                    Console.WriteLine($"{analysisGraph.W:0.00},{analysisGraph.AmazonMobilityScores[p]:0.00}");
                }
            }
        }
Beispiel #3
0
        public static void PlayFourRandomMovesAhead()
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();

            AnalysisGraph analysisGraph          = new AnalysisGraph();
            List <(Game, IAnalysisResult)> games = new List <(Game, IAnalysisResult)>();

            for (int i = 0; i < 100; i++)
            {
                Random rnd  = new Random();
                Game   game = new Game();
                game.Begin(null, null, 10);
                int n = 4;
                while (n > 0 && !game.IsComplete())
                {
                    int randomMoveNum = rnd.Next(0, game.CurrentMoves.Count - 1);
                    game.ApplyMove(game.CurrentMoves.ElementAt(randomMoveNum));
                    n--;
                }

                games.Add((game, analysisGraph.Analyze(game.CurrentBoard)));
            }
            sw.Stop();

            Console.WriteLine($"Elapsed: {sw.Elapsed}");
        }
Beispiel #4
0
        static void PlayRandomGame()
        {
            Game game = new Game();

            game.Begin(null, null, 10);

            AnalysisGraph analysisGraph = new AnalysisGraph();

            analysisGraph.BuildAnalysis(game.CurrentBoard.PieceGrid, game.CurrentPlayer);

            AmazonConsoleRenderer.Render(game, analysisGraph);

            Random rnd = new Random();

            while (!game.IsComplete())
            {
                int randomMoveNum = rnd.Next(0, game.CurrentMoves.Count - 1);
                game.ApplyMove(game.CurrentMoves.ElementAt(randomMoveNum));

                analysisGraph.BuildAnalysis(game.CurrentBoard.PieceGrid, game.CurrentPlayer);

                AmazonConsoleRenderer.Render(game, analysisGraph);
            }
            Console.WriteLine(game.GetGameResult().ToString());
        }
Beispiel #5
0
 private void gizmosPrintAnalysisGraph(AnalysisGraph a)
 {
     foreach (AnalysisNode node in a.getGraph())
     {
         Gizmos.DrawSphere(node.getPosition(), 10f);
         foreach (AnalysisNode node2 in node.getNeighbours())
         {
             Gizmos.DrawLine(node.getPosition(), node2.getPosition());
         }
     }
 }
Beispiel #6
0
        static void Main(string[] args)
        {
            Game game = new Game();

            game.Begin(null, null, 10);

            foreach (Move move in game.CurrentMoves)
            {
                var analysisGraph = new AnalysisGraph();
                analysisGraph.BuildAnalysis(game.CurrentBoard.PieceGrid, Owner.Player1);
            }
        }
Beispiel #7
0
    private void gizmosPrintAnalysisGraphWithAttribute(AnalysisGraph a, string attributeId)
    {
        foreach (AnalysisNode node in a.getGraph())
        {
            Gizmos.DrawSphere(node.getPosition(), node.getAttribute(attributeId).getValue() * 30);

            foreach (AnalysisNode node2 in node.getNeighbours())
            {
                Gizmos.DrawLine(node.getPosition(), node2.getPosition());
            }
        }
    }
        public void AllFirstMovesAnalyzed()
        {
            Game game = new Game();

            game.Begin(null, null, 10);

            Parallel.ForEach(game.CurrentMoves, (move) =>
            {
                var analysisGraph = new AnalysisGraph();
                Board nextBoard   = game.CurrentBoard.Clone();
                nextBoard.ApplyMove(move);
                analysisGraph.BuildAnalysis(nextBoard.PieceGrid, Owner.Player1);
            });
        }
        public void EvaluationValues()
        {
            PieceGrid grid          = GetPieceGrid();
            var       analysisGraph = new AnalysisGraph();

            analysisGraph.BuildAnalysis(grid, Owner.Player1);
            Assert.AreEqual("43.38", $"{analysisGraph.W:0.00}");
            Assert.AreEqual("8.40", $"{analysisGraph.T1:0.00}");
            Assert.AreEqual("-3.20", $"{analysisGraph.T2:0.00}");
            Assert.AreEqual("3.88", $"{analysisGraph.C1:0.00}");
            Assert.AreEqual("1.83", $"{analysisGraph.C2:0.00}");
            Assert.AreEqual("0.87", $"{analysisGraph.T:0.00}");
            Assert.AreEqual("17.51", $"{analysisGraph.M:0.00}");
            Assert.AreEqual("18.38", $"{analysisGraph.T + analysisGraph.M:0.00}");
        }
Beispiel #10
0
        static void PlayRandomVsOptimusDeepGame()
        {
            Game game = new Game();

            game.Begin(null, null, 10);

            AnalysisGraph analysisGraph = new AnalysisGraph();

            analysisGraph.BuildAnalysis(game.CurrentBoard.PieceGrid, game.CurrentPlayer);

            AmazonConsoleRenderer.Render(game, analysisGraph);
            OptimusDeep optimusDeep = new OptimusDeep(3, analysisGraph);

            optimusDeep.BeginNewGame(Owner.Player2, 10);

            Random rnd = new Random();

            while (!game.IsComplete())
            {
                int randomMoveNum = rnd.Next(0, game.CurrentMoves.Count - 1);
                game.ApplyMove(game.CurrentMoves.ElementAt(randomMoveNum));

                analysisGraph.BuildAnalysis(game.CurrentBoard.PieceGrid, game.CurrentPlayer);

                AmazonConsoleRenderer.Render(game, analysisGraph);

                if (game.IsComplete())
                {
                    continue;
                }

                var cancellationTokenSrc = new CancellationTokenSource();
                var bestMoveTask         = Task <Move> .Run(() => optimusDeep.PickBestMoveAsync(game.CurrentBoard, cancellationTokenSrc.Token));

                Task.Delay(1000).Wait();
                if (!bestMoveTask.IsCompleted)
                {
                    cancellationTokenSrc.Cancel();
                }
                Move bestMove = bestMoveTask.Result;
                game.ApplyMove(bestMove);

                analysisGraph.BuildAnalysis(game.CurrentBoard.PieceGrid, game.CurrentPlayer);
                AmazonConsoleRenderer.Render(game, analysisGraph);
            }
            Console.WriteLine(game.GetGameResult().ToString());
        }
        public void Distances()
        {
            Dictionary <Point, double> player1QueenDistancesAnswer = new Dictionary <Point, double> {
                { Point.Get(0, 1), 2 }, { Point.Get(0, 2), 2 }, { Point.Get(0, 3), 1 }, { Point.Get(0, 4), 2 }, { Point.Get(0, 6), 1 }, { Point.Get(0, 7), 2 }, { Point.Get(0, 8), 1 }, { Point.Get(0, 9), 2 }, { Point.Get(1, 0), 2 }, { Point.Get(1, 1), 1 }, { Point.Get(1, 3), 1 }, { Point.Get(1, 5), 2 }, { Point.Get(1, 7), 1 }, { Point.Get(1, 8), 1 }, { Point.Get(1, 9), 1 }, { Point.Get(2, 0), 2 }, { Point.Get(2, 1), 2 }, { Point.Get(2, 2), 1 }, { Point.Get(2, 3), 1 }, { Point.Get(2, 5), 2 }, { Point.Get(3, 0), 2 }, { Point.Get(3, 2), 1 }, { Point.Get(3, 4), 1 }, { Point.Get(3, 5), 1 }, { Point.Get(3, 6), 1 }, { Point.Get(4, 0), 2 }, { Point.Get(4, 1), 2 }, { Point.Get(4, 2), 1 }, { Point.Get(4, 3), 1 }, { Point.Get(4, 4), 1 }, { Point.Get(4, 5), 2 }, { Point.Get(5, 0), 2 }, { Point.Get(5, 1), 1 }, { Point.Get(5, 2), 1 }, { Point.Get(5, 3), 1 }, { Point.Get(5, 6), 1 }, { Point.Get(5, 8), 3 }, { Point.Get(5, 9), 3 }, { Point.Get(6, 0), 1 }, { Point.Get(6, 2), 1 }, { Point.Get(6, 3), 1 }, { Point.Get(6, 5), 1 }, { Point.Get(6, 8), 3 }, { Point.Get(6, 9), 3 }, { Point.Get(7, 1), 1 }, { Point.Get(7, 5), 1 }, { Point.Get(7, 6), 1 }, { Point.Get(7, 8), 3 }, { Point.Get(7, 9), 3 }, { Point.Get(8, 0), 2 }, { Point.Get(8, 1), 1 }, { Point.Get(8, 2), 1 }, { Point.Get(8, 3), 1 }, { Point.Get(8, 4), 1 }, { Point.Get(8, 5), 2 }, { Point.Get(8, 8), 3 }, { Point.Get(8, 9), 3 }, { Point.Get(9, 0), 1 }, { Point.Get(9, 1), 2 }, { Point.Get(9, 3), 1 }, { Point.Get(9, 4), 1 }, { Point.Get(9, 5), 2 }, { Point.Get(9, 6), 2 }, { Point.Get(9, 7), 2 }, { Point.Get(9, 8), 2 }, { Point.Get(9, 9), 2 },
            };
            Dictionary <Point, double> player2QueenDistancesAnswer = new Dictionary <Point, double> {
                { Point.Get(0, 1), 1 }, { Point.Get(0, 2), 2 }, { Point.Get(0, 3), 2 }, { Point.Get(0, 4), 1 }, { Point.Get(0, 6), 3 }, { Point.Get(0, 7), 4 }, { Point.Get(0, 8), 4 }, { Point.Get(0, 9), 4 }, { Point.Get(1, 0), 2 }, { Point.Get(1, 1), 1 }, { Point.Get(1, 3), 1 }, { Point.Get(1, 5), 2 }, { Point.Get(1, 7), 4 }, { Point.Get(1, 8), 5 }, { Point.Get(1, 9), 5 }, { Point.Get(2, 0), 1 }, { Point.Get(2, 1), 1 }, { Point.Get(2, 2), 1 }, { Point.Get(2, 3), 2 }, { Point.Get(2, 5), 1 }, { Point.Get(3, 0), 1 }, { Point.Get(3, 2), 1 }, { Point.Get(3, 4), 1 }, { Point.Get(3, 5), 2 }, { Point.Get(3, 6), 1 }, { Point.Get(4, 0), 1 }, { Point.Get(4, 1), 1 }, { Point.Get(4, 2), 1 }, { Point.Get(4, 3), 1 }, { Point.Get(4, 4), 2 }, { Point.Get(4, 5), 2 }, { Point.Get(5, 0), 1 }, { Point.Get(5, 1), 1 }, { Point.Get(5, 2), 1 }, { Point.Get(5, 3), 1 }, { Point.Get(5, 6), 1 }, { Point.Get(5, 8), 1 }, { Point.Get(5, 9), 2 }, { Point.Get(6, 0), 1 }, { Point.Get(6, 2), 1 }, { Point.Get(6, 3), 1 }, { Point.Get(6, 5), 1 }, { Point.Get(6, 8), 2 }, { Point.Get(6, 9), 1 }, { Point.Get(7, 1), 1 }, { Point.Get(7, 5), 2 }, { Point.Get(7, 6), 2 }, { Point.Get(7, 8), 2 }, { Point.Get(7, 9), 2 }, { Point.Get(8, 0), 2 }, { Point.Get(8, 1), 1 }, { Point.Get(8, 2), 2 }, { Point.Get(8, 3), 2 }, { Point.Get(8, 4), 2 }, { Point.Get(8, 5), 2 }, { Point.Get(8, 8), 2 }, { Point.Get(8, 9), 2 }, { Point.Get(9, 0), 2 }, { Point.Get(9, 1), 1 }, { Point.Get(9, 3), 2 }, { Point.Get(9, 4), 3 }, { Point.Get(9, 5), 2 }, { Point.Get(9, 6), 3 }, { Point.Get(9, 7), 3 }, { Point.Get(9, 8), 2 }, { Point.Get(9, 9), 2 },
            };
            Dictionary <Point, double> player1KingDistancesAnswer = new Dictionary <Point, double> {
                { Point.Get(0, 1), 3 }, { Point.Get(0, 2), 3 }, { Point.Get(0, 3), 3 }, { Point.Get(0, 4), 3 }, { Point.Get(0, 6), 2 }, { Point.Get(0, 7), 2 }, { Point.Get(0, 8), 2 }, { Point.Get(0, 9), 2 }, { Point.Get(1, 0), 3 }, { Point.Get(1, 1), 2 }, { Point.Get(1, 3), 2 }, { Point.Get(1, 5), 3 }, { Point.Get(1, 7), 1 }, { Point.Get(1, 8), 1 }, { Point.Get(1, 9), 1 }, { Point.Get(2, 0), 3 }, { Point.Get(2, 1), 2 }, { Point.Get(2, 2), 1 }, { Point.Get(2, 3), 1 }, { Point.Get(2, 5), 2 }, { Point.Get(3, 0), 3 }, { Point.Get(3, 2), 1 }, { Point.Get(3, 4), 1 }, { Point.Get(3, 5), 2 }, { Point.Get(3, 6), 3 }, { Point.Get(4, 0), 3 }, { Point.Get(4, 1), 2 }, { Point.Get(4, 2), 1 }, { Point.Get(4, 3), 1 }, { Point.Get(4, 4), 1 }, { Point.Get(4, 5), 2 }, { Point.Get(5, 0), 3 }, { Point.Get(5, 1), 2 }, { Point.Get(5, 2), 2 }, { Point.Get(5, 3), 2 }, { Point.Get(5, 6), 1 }, { Point.Get(5, 8), 8 }, { Point.Get(5, 9), 8 }, { Point.Get(6, 0), 2 }, { Point.Get(6, 2), 1 }, { Point.Get(6, 3), 1 }, { Point.Get(6, 5), 1 }, { Point.Get(6, 8), 7 }, { Point.Get(6, 9), 7 }, { Point.Get(7, 1), 1 }, { Point.Get(7, 5), 1 }, { Point.Get(7, 6), 1 }, { Point.Get(7, 8), 6 }, { Point.Get(7, 9), 6 }, { Point.Get(8, 0), 2 }, { Point.Get(8, 1), 1 }, { Point.Get(8, 2), 1 }, { Point.Get(8, 3), 1 }, { Point.Get(8, 4), 2 }, { Point.Get(8, 5), 2 }, { Point.Get(8, 8), 5 }, { Point.Get(8, 9), 6 }, { Point.Get(9, 0), 2 }, { Point.Get(9, 1), 2 }, { Point.Get(9, 3), 2 }, { Point.Get(9, 4), 2 }, { Point.Get(9, 5), 3 }, { Point.Get(9, 6), 3 }, { Point.Get(9, 7), 4 }, { Point.Get(9, 8), 5 }, { Point.Get(9, 9), 6 },
            };
            Dictionary <Point, double> player2KingDistancesAnswer = new Dictionary <Point, double> {
                { Point.Get(0, 1), 3 }, { Point.Get(0, 2), 3 }, { Point.Get(0, 3), 3 }, { Point.Get(0, 4), 3 }, { Point.Get(0, 6), 4 }, { Point.Get(0, 7), 5 }, { Point.Get(0, 8), 6 }, { Point.Get(0, 9), 7 }, { Point.Get(1, 0), 2 }, { Point.Get(1, 1), 2 }, { Point.Get(1, 3), 2 }, { Point.Get(1, 5), 3 }, { Point.Get(1, 7), 5 }, { Point.Get(1, 8), 6 }, { Point.Get(1, 9), 7 }, { Point.Get(2, 0), 1 }, { Point.Get(2, 1), 1 }, { Point.Get(2, 2), 1 }, { Point.Get(2, 3), 2 }, { Point.Get(2, 5), 2 }, { Point.Get(3, 0), 1 }, { Point.Get(3, 2), 1 }, { Point.Get(3, 4), 3 }, { Point.Get(3, 5), 2 }, { Point.Get(3, 6), 1 }, { Point.Get(4, 0), 1 }, { Point.Get(4, 1), 1 }, { Point.Get(4, 2), 1 }, { Point.Get(4, 3), 2 }, { Point.Get(4, 4), 3 }, { Point.Get(4, 5), 2 }, { Point.Get(5, 0), 1 }, { Point.Get(5, 1), 1 }, { Point.Get(5, 2), 1 }, { Point.Get(5, 3), 2 }, { Point.Get(5, 6), 1 }, { Point.Get(5, 8), 1 }, { Point.Get(5, 9), 2 }, { Point.Get(6, 0), 1 }, { Point.Get(6, 2), 1 }, { Point.Get(6, 3), 2 }, { Point.Get(6, 5), 2 }, { Point.Get(6, 8), 2 }, { Point.Get(6, 9), 2 }, { Point.Get(7, 1), 1 }, { Point.Get(7, 5), 3 }, { Point.Get(7, 6), 3 }, { Point.Get(7, 8), 3 }, { Point.Get(7, 9), 3 }, { Point.Get(8, 0), 2 }, { Point.Get(8, 1), 2 }, { Point.Get(8, 2), 2 }, { Point.Get(8, 3), 3 }, { Point.Get(8, 4), 4 }, { Point.Get(8, 5), 4 }, { Point.Get(8, 8), 4 }, { Point.Get(8, 9), 4 }, { Point.Get(9, 0), 3 }, { Point.Get(9, 1), 3 }, { Point.Get(9, 3), 3 }, { Point.Get(9, 4), 4 }, { Point.Get(9, 5), 5 }, { Point.Get(9, 6), 5 }, { Point.Get(9, 7), 5 }, { Point.Get(9, 8), 5 }, { Point.Get(9, 9), 5 },
            };

            ;
            PieceGrid grid = GetPieceGrid();

            var analysisGraph = new AnalysisGraph();

            analysisGraph.BuildAnalysis(grid, Owner.Player1);

            foreach (var kvp in player1QueenDistancesAnswer)
            {
                Assert.IsTrue(analysisGraph.Player1QueenMinDistances.ContainsKey(kvp.Key));
                Assert.AreEqual(kvp.Value, analysisGraph.Player1QueenMinDistances[kvp.Key]);
            }
            foreach (var kvp in player2QueenDistancesAnswer)
            {
                Assert.IsTrue(analysisGraph.Player2QueenMinDistances.ContainsKey(kvp.Key));
                Assert.AreEqual(kvp.Value, analysisGraph.Player2QueenMinDistances[kvp.Key]);
            }
            foreach (var kvp in player1KingDistancesAnswer)
            {
                Assert.IsTrue(analysisGraph.Player1KingMinDistances.ContainsKey(kvp.Key));
                Assert.AreEqual(kvp.Value, analysisGraph.Player1KingMinDistances[kvp.Key]);
            }
            foreach (var kvp in player2KingDistancesAnswer)
            {
                Assert.IsTrue(analysisGraph.Player2KingMinDistances.ContainsKey(kvp.Key));
                Assert.AreEqual(kvp.Value, analysisGraph.Player2KingMinDistances[kvp.Key]);
            }
        }
Beispiel #12
0
        static void RenderSpecificState()
        {
            Point[] arrowPoints = { Point.Get(2, 9), Point.Get(4, 9), Point.Get(3, 8), Point.Get(4, 8), Point.Get(2, 7), Point.Get(3, 7), Point.Get(5, 7), Point.Get(6, 7), Point.Get(7, 7), Point.Get(8, 7), Point.Get(1, 6), Point.Get(2, 6), Point.Get(4, 6), Point.Get(8, 6), Point.Get(0, 5), Point.Get(5, 5), Point.Get(1, 4), Point.Get(2, 4), Point.Get(5, 4), Point.Get(6, 4), Point.Get(7, 4), Point.Get(7, 3), Point.Get(1, 2), Point.Get(9, 2), Point.Get(0, 0), Point.Get(7, 0), };
            Dictionary <Point, Amazon> amazonsDict = new Dictionary <Point, Amazon> {
                { Point.Get(2, 8), AmazonPlayer1.Get() }, { Point.Get(6, 6), AmazonPlayer1.Get() }, { Point.Get(3, 3), AmazonPlayer1.Get() }, { Point.Get(7, 2), AmazonPlayer1.Get() },
                { Point.Get(3, 9), AmazonPlayer2.Get() }, { Point.Get(4, 7), AmazonPlayer2.Get() }, { Point.Get(3, 1), AmazonPlayer2.Get() }, { Point.Get(6, 1), AmazonPlayer2.Get() }
            };
            PieceGrid grid = new PieceGrid(10, amazonsDict);

            foreach (Point p in arrowPoints)
            {
                grid.PointPieces[p] = ArrowPlayer1.Get();
            }

            Game game = new Game();

            game.Begin(null, null, 10);
            game.CurrentBoard.PieceGrid = grid;

            AnalysisGraph analysisGraph = new AnalysisGraph();

            analysisGraph.BuildAnalysis(game.CurrentBoard.PieceGrid, game.CurrentPlayer);
            AmazonConsoleRenderer.Render(game, analysisGraph);
        }
Beispiel #13
0
    // Use this for initialization
    void Start()
    {
        #region Basic Initialization
        terrain              = gameObject.GetComponent <Terrain>();
        maxTraversableSlope *= Mathf.Min(gridXPercentage, gridYPercentage);

        terrainXGrid = 100f / gridXPercentage;
        terrainYGrid = 100f / gridYPercentage;

        gridXSpacing = terrainX / 100f * gridXPercentage;
        gridYSpacing = terrainY / 100f * gridYPercentage;
        #endregion

        #region Algorithm
        //Create grid of heights
        grid = new float[(int)terrainXGrid, (int)terrainYGrid];

        for (int x = 0; x < terrainXGrid; x++)
        {
            for (int y = 0; y < terrainYGrid; y++)
            {
                grid[x, y] = terrain.SampleHeight(new Vector3(x * gridXSpacing + gridXSpacing / 2f, 0, y * gridYSpacing + gridYSpacing / 2f));
            }
        }

        //Create a new analyzer
        analyzer = new Analyzer(grid, gridXSpacing, gridYSpacing, maxReachableHeight, maxTraversableSlope);

        //Convert a pruned Voronoi to VoronoiGraph
        convertToVoronoiGraph(pruneVoronoi(analyzer.getVEdgeList()));

        //Calculate the radius of each node
        foreach (VoronoiNode node in workingVoronoi)
        {
            node.setRadius(computeRadius(node));
        }

        //Perform culling algorithms
        cullVeronoi();
        #endregion

        //Set up Analysis Graph
        analysisGraph = getAnalysisGraph();


        //ROB!!

        /*
         * Calling addAttribute() lets you put in an interface of type IAttribute. I have given you two examples below.
         *
         * ChokeValue's constructor ONLY takes a string because caluations to get choke value can be done without calling unity functions.
         *
         * UpHill's constructor takes a string and a HillCalculator. It's annoying, but this is necessary because it requires MonoBehaviour to do it's calculations.
         * Whenever you're trying to make an attribute that requires extra infomation from the gameworld, you need to make it like UpHill. Basically you need another
         * MonoBehaviour Object (Like hill Calculator), and you need to attach it to the terrain you'r analyzing. Again this is annoying but it's necessary because
         * of how unity objects work. Take a look at upHill and you should see how it's working.
         */


        analysisGraph.addAttribute(new ChokeValue("choke"));

        HillCalculator calc = gameObject.GetComponent <HillCalculator>();
        calc.getTerrain();
        analysisGraph.addAttribute(new UpHill("hill", calc));
    }
Beispiel #14
0
        public static void Render(Game game, AnalysisGraph analysisGraph)
        {
            for (int x = 0; x < game.BoardSize + 2; x++)
            {
                Console.Write('#');
            }
            Console.WriteLine();

            for (int y = game.BoardSize - 1; y >= 0; y--)
            {
                Console.Write('#');

                StringBuilder mobilityStringBuilder = new StringBuilder(" ");
                for (int x = 0; x < game.BoardSize; x++)
                {
                    Piece piece = game.CurrentBoard.PieceGrid.PointPieces[Point.Get(x, y)];
                    Console.Write(GetPieceCharacter(piece));
                    if (piece is Amazon)
                    {
                        mobilityStringBuilder.Append($"{analysisGraph.AmazonMobilityScores[Point.Get(x,y)]:0.00}, ");
                    }
                }

                Console.Write('#');

                Console.Write($"{mobilityStringBuilder.ToString(),30}");

                if (y == game.BoardSize - 1)
                {
                    Console.Write($" W: {analysisGraph.W,6:0.00}");
                }
                if (y == game.BoardSize - 2)
                {
                    Console.Write($" T1: {analysisGraph.T1,5:0.00}");
                }
                if (y == game.BoardSize - 3)
                {
                    Console.Write($" T2: {analysisGraph.T2,5:0.00}");
                }
                if (y == game.BoardSize - 4)
                {
                    Console.Write($" C1: {analysisGraph.C1,5:0.00}");
                }
                if (y == game.BoardSize - 5)
                {
                    Console.Write($" C2: {analysisGraph.C2,5:0.00}");
                }
                if (y == game.BoardSize - 6)
                {
                    Console.Write($" T: {analysisGraph.T,6:0.00}");
                }
                if (y == game.BoardSize - 7)
                {
                    Console.Write($" M: {analysisGraph.M,6:0.00}");
                }
                if (y == game.BoardSize - 8)
                {
                    Console.Write($" T+M: {analysisGraph.T + analysisGraph.M,4:0.00}");
                }
                if (y == game.BoardSize - 9)
                {
                    Console.Write($" Moves: {game.CurrentMoves.Count(),2:0}");
                }

                Console.WriteLine();
            }

            for (int x = 0; x < game.BoardSize + 2; x++)
            {
                Console.Write('#');
            }
            Console.WriteLine();
        }