RTS Project

This is a discussion on RTS Project within the Game Programming forums, part of the General Programming Boards category; Hi, Can anyone help? I am looking to create a simple game with AI using C or C++ Simplicity with ...

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    224

    RTS Project

    Hi,

    Can anyone help?

    I am looking to create a simple game with AI using C or C++

    Simplicity with the option to be more creative would be nice.

    Can anyone advise me as to what type of game would be best and any advice would be appreciated.

    Thanks

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    pong? The opponent in pong can have a certain amount of simple AI.

    edit: but I guess you're looking for a RTS game... err... dunno how to make that too simple.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #3
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    pong with a twist then?

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    TicTacToe is pretty simple.

    I wrote a computer-player that is competent enough that I have a very hard time to beat it even when I start in the middle position. It basicly does the the first that "succeeds" of these:
    * Try all available moves and see if it's a win.
    * Try all moves for the competitor and block any winning move.
    * Pick the middle.
    * Pick a random corner - try all four corners at random.
    * Pick a random point.

    I had to tune it down a bit to make it not win or draw all the time (it is certainly possible to make it a draw if I don't make a mistake, by blocking). The tuning I made was to take the proportion of my win vs (comptuer wins + draws) and only allow it to take a corner on a corresponding proportion of the times it got there.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,831
    I guess I don't understand what AI means these days. Any game employing some non-trivial strategy?

  6. #6
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    I'd say any game using "external" factors to make a decision.

  7. #7
    Registered User
    Join Date
    Nov 2006
    Posts
    224

    Wink

    Thanks for your replies. Still not sure what to do yet.

    Basically, this is a project for uni. We will have about 6/7 months to do it (whilst studying). I have some experience (just past beginner) with C. The game must have a pretty decent degree of AI.

    I would like to have a good, clear idea which can allow creativity as we get the basic code down.

    Taking all this into account does anyone have a good game idea?

    Thanks

  8. #8
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    If you want to make an RTS, and the focus of your project is AI, then have a look at ORTS. Its a free OSS RTS engine specifically designed to test out experimental AI.

    If you're a beginner this may be a bit out of your league though.

  9. #9
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    > Taking all this into account does anyone have a good game idea?
    I do!

    * A game like Close Combat
    * A game like RecWar

    Neither is too hard as far as graphics go (in comparison to other types of games) -- but still a large challenge.

  10. #10
    Registered User
    Join Date
    Jan 2008
    Posts
    70
    I can tell you a couple things that you probably want to watch out for given your time constraints. Or you can go with the ORTS which will hopefully keep you from worrying about the following. If you don't do the following it will help keep the project from ballooning out of proportion as mine has :P.

    Too many units, too large a world:
    This will likely cause you to have to split up the world into a quad tree for fast collision detection.
    Not basing the world on a grid:
    This will cause a whole lot of things to become monumentally more complex.
    Simple graphics:
    You might want to just go 2D since you are just trying to exhibit AI.

  11. #11
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    If it doesn't have to be real time, I would advise a turn based game, so you ll have more control of what you are doing.

  12. #12
    Registered User
    Join Date
    Nov 2006
    Posts
    224
    Thanks for your replies guys, really appreciated.

    A bit of a change - we have decided to create a 'tanks' game - similar to the tanks game that on 'wii play'. Check it out on youtube.

    The next question I must then ask (since Ive never done this before) - where to start?

    Thanks again

  13. #13

  14. #14
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Too many units, too large a world:
    This will likely cause you to have to split up the world into a quad tree for fast collision detection.
    Creating a quad-tree from world data is very very simple. It's even more simple if it's 2D since the bounding checks are just simple comparisons. Also if you provide links to left, top, right, and bottom neighbors whenever a unit breaches one of the current node's boundaries you just place it into the appropriate node's list. If you set these references at startup time then crossing quad-tree boundaries is a snap.

    Code:
    if (object.pos.x > right)
    {
       removeFromList(object);
       addToList(right,object);
    }
    ...
    ...
    One way to traverse a quad tree.
    Code:
    void CTerrain::TraverseQTree(TerrainPatch *pNode)
    {
         if (pNode->isLeaf)
        {
            float patch_world_width2 = m_PatchExtents.patch_width_world * 0.5f;
            D3DXVECTOR3 vecPatchPos = getPatchPos(pNode->patchID);
            
            vecPatchPos.x -= fmodf(vecPatchPos.x,patch_world_width2);
            vecPatchPos.z -= fmodf(vecPatchPos.z,patch_world_width2);
            D3DXVECTOR3 camPos = m_pCamera->GetPosition();
    
            pNode->distToCamera = D3DXVec3Length(&(camPos - vecPatchPos));
            m_RenderList.push_back(pNode);
        }
        else
        {
            if (m_pFrustum->IsVisibleFast(pNode->Bounds.GetMin(),
                                          pNode->Bounds.GetMax()))
            {
                TraverseQTree(pNode->NW);
                TraverseQTree(pNode->NE);
                TraverseQTree(pNode->SW);
                TraverseQTree(pNode->SE);
            }
        }
    }
    And a way to build a quad tree. Ignore the creation of vertices section. This is from a terrain renderer but it should illustrate the general concept.
    Code:
    void CTerrain::BuildQuadTree(TerrainPatch *pNode,
                                 float Width,
                                 float wx,
                                 float wz,
                                 float wx2,
                                 float wz2)
    {
        HRESULT hr = 0;
        float patch_width = (wx2 - wx);
          
        D3DXVECTOR3 vecPatchPos;
        vecPatchPos.x = (wx + wx2) * 0.5f;
        vecPatchPos.y = 0.0f;
        vecPatchPos.z = (wz + wz2) * 0.5f;
    
        pNode->patchID = addPatchPos(vecPatchPos,pNode);
    
        D3DXVECTOR3 min = D3DXVECTOR3(vecPatchPos.x - (patch_width * 0.8f),
                                      -(patch_width * 0.8f),
                                      vecPatchPos.z - (patch_width * 0.8f));
    
        D3DXVECTOR3 max = D3DXVECTOR3(vecPatchPos.x + (patch_width * 0.8f),
                                      (patch_width * 0.8f),
                                      vecPatchPos.z + (patch_width * 0.8f));
    
        pNode->Bounds.SetBounds(min,max);
        m_num_nodes++;
    
        if (patch_width == Width)
        {
            CreateVertexBuffer(pNode,wx,wz);
            CreateIndexBuffer(pNode,m_PatchExtents.NumRows,m_PatchExtents.NumCols);
            pNode->pTreeMgr = new CTreeMgr();
            pNode->pTreeMgr->Create(this,m_RNG.RandomRange(MIN_TREES,MAX_TREES),pNode->patchID,m_PatchExtents);
            pNode->pTreeMgr->SetTexture("..\\Textures\\tree2.dds");
            pNode->isLeaf = true;
            m_num_patches++;
            return;
        }
       
        pNode->isLeaf = false;
    
        float midwx = (wx2 + wx) * 0.5f;
        float midwz = (wz2 + wz) * 0.5f;
          
        pNode->NW =  new TerrainPatch();
        pNode->NW->patch_direction = NORTH_WEST;
        pNode->NW->Parent = pNode;
        BuildQuadTree(pNode->NW,Width,wx,wz,midwx,midwz);
    
        pNode->NE =  new TerrainPatch();
        pNode->NE->Parent = pNode;
        pNode->NE->patch_direction = NORTH_EAST;
        BuildQuadTree(pNode->NE,Width,midwx,wz,wx2,midwz);
        
        pNode->SW =  new TerrainPatch();
        pNode->SW->Parent = pNode;
        pNode->SW->patch_direction = SOUTH_WEST;
        BuildQuadTree(pNode->SW,Width,wx,midwz,midwx,wz2);
        
        pNode->SE =  new TerrainPatch();
        pNode->SE->Parent = pNode;
        pNode->SE->patch_direction = SOUTH_EAST;
        BuildQuadTree(pNode->SE,Width,midwx,midwz,wx2,wz2);
    
        pNode->NW->E_id = pNode->NE->patchID;
        pNode->NW->S_id = pNode->SW->patchID;
    
        pNode->NE->W_id = pNode->NW->patchID;
        pNode->NE->S_id = pNode->SE->patchID;
        
        pNode->SW->N_id = pNode->NW->patchID;
        pNode->SW->E_id = pNode->SE->patchID;
        
        pNode->SE->W_id = pNode->SW->patchID;
        pNode->SE->N_id = pNode->NE->patchID;
    
    }
    Last edited by VirtualAce; 10-03-2008 at 05:06 PM.

  15. #15
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Quote Originally Posted by nonoob View Post
    I guess I don't understand what AI means these days. Any game employing some non-trivial strategy?
    Game AI is generally any set of algorithms that allow the computer to play against the human. Randomly moving is in fact AI, although quite poor if thats all it does. Good AI is generally considered any algorithm that provides a challenge. The concept of AI in games and AI in acedemia are mostly seperate entities.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem Displaying a Struct
    By rockstarpirate in forum C++ Programming
    Replies: 16
    Last Post: 05-05-2008, 09:05 AM
  2. Forming RTS Demo Team Sixth Extinction
    By SteelRain4eva in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 06-08-2006, 08:47 PM
  3. Dynamic Binding
    By gpr1me in forum C++ Programming
    Replies: 1
    Last Post: 03-24-2006, 08:01 AM
  4. Game Independent Anti-cheat Project Needs Programmers
    By GIA Project Lea in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 09-15-2005, 07:41 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21