PPP Week 1

Overview

This week was my week to ramp up on speech recognition and refine my world generation so that I’ll have an area to test around in.

Voice Recognition

I created a SpeechManager class to handle different inputs in a somewhat organized fashion. I created a few different functions to handle input. Ultimately, all input gets sent to place where I can search the phrase said for keywords.

    private Vector2Int LoopThroughCommands(string fileName)
    {
        // Retrieve lists of keywords
        List<TextAsset> identifiers = new List<TextAsset>(Resources.LoadAll<TextAsset>("CommandTypeIdentifiers/" + fileName));
        // Loop through each list
        for (int i = 0; i < identifiers.Count; ++i)
        {
            // Split the list into keywords
            string[] lines = identifiers[i].text.Split("\n"[0]);
            // Loop through each keyword in the list
            for (int lineIndex = 0; lineIndex < lines.Length; ++lineIndex)
            {
                // Check for the keyword
                if (mSpeechCommand.IndexOf(lines[lineIndex]) != -1)
                {
                    return new Vector2Int(i, lineIndex);
                }
            }
        }
        return new Vector2Int(-1, -1);
    }

World Generation

I hadn’t played RTSs in a little bit, having gotten interested in other genres recently. I wanted to refresh my perspective, so I picked up a game I’d had on my wishlist on Steam for a while which had recently gone on sale: Circle Empires. Along with giving me some great ideas to incorporate into my simplified game, I liked the game’s map, for a couple of reasons.

Circle Empires Map

Circle Empires’ map is fun. It breaks up what would be a large flat space into multiple sections. This leaves focusing on each area simple and engaging. And the connections between each circle are small, leaving a small area for fighting. Next, it fits in wonderfully with the hex tiles I had already set up. Even further, each circle represents an area owned by a player, where only that player can build. As I didn’t want to allow the user to build anywhere, this simplifies things both in letting them know where they can build and for allowing it to happen in code. And possibly most importantly, it makes it very simple to traverse using speech and voice recognition. Instead of zooming in on a random pixel on the screen, the user can select a hex. They can ask to go left, right, up, or down. Navigating becomes simple and intuitive.

I did a little bit of math to be able to form my grid. I wanted to place each hex so that it had a single connection to all adjacent hexes. I don’t know if this is how I want it to be in its finished form yet, and I might rearrange my grid so that it’s more of a hexagon in shape, but it’s definitely a start.

Procedurally Generated Hex Grid
        int numRows = size * 2 - 1;
        float startingX = 0;
        float offset = oddRowOffset;

        // Loop through top of hexagon
        for (int r = size; r < numRows; ++r)
        {
            for (int c = 0; c < r; ++c)
            {
                Vector3 position = new Vector3(r * xDistance, 0, startingX + c * zDistance);
                GameObject hex = Instantiate(tiles.biomes[(int)biome].list[grids[(int)biome][r, c]].HexToPlace.gameObject, position, Quaternion.identity, parent.transform);;
                hex.name = "(" + r + ", " + c + ")";
            }
            startingX -= offset;
        }
        // Loop through bottom of hexagon
        for (int r = numRows; r >= size; --r)
        {
            for (int c = 0; c < r; ++c)
            {
                Vector3 position = new Vector3((numRows * 2 - r) * xDistance, 0, startingX + c * zDistance);
                GameObject hex = Instantiate(tiles.biomes[(int)biome].list[grids[(int)biome][r - 1, c]].HexToPlace.gameObject, position, Quaternion.identity, parent.transform);
                hex.name = "(" + r + ", " + c + ")";
            }
            startingX += offset;
        }

One thought on “PPP Week 1

Leave a comment