Announcement

Collapse
No announcement yet.

CTPII GameState information

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • CTPII GameState information

    Hello,

    I was trying to understand the CTPII interface, so as to connect it to a decision system. I wanted to know how the GameState and player information is transmitted. Is it sent out on demand or is it broadcast over the network every cycle? Could you please guide me to the files/functions that I need to look at? I was looking at the civ3_main.cpp and the civapp.cpp, but could not track the exact place this is done. I have also had a look at the network.cpp and the GameWatch.cpp files.

    Thanks

  • #2
    So you want to know how multiplayer works?

    At first all these net_* files are a good choice to look at. All these files contain classes derived from the class Packetizer. Each of these classes contain methods called Packetize and Unpacketize. I think these methods are used to send the data over the net. Or better to make the data ready for sending and to interpret the received data.

    So these Packetize and Unpacketize methods determine what is sent over the net.

    These Packetize and Unpacketize methods are called from a place I don't know. However the order for Packetizing is put into a queue, these packetize stuff is called from various places of the code.

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

    Comment


    • #3
      Thanks Martin.

      Are there any AI script files that are used to control the Game? If there are, where can I look for them and is there some kind of documentation available to help me understand?

      From what I understand, the Game AI seems to be controlled by using strategies and personalities settings for the different players.

      Thanks

      Comment


      • #4
        Originally posted by ushhan
        Are there any AI script files that are used to control the Game? If there are, where can I look for them and is there some kind of documentation available to help me understand?
        There are no scriptfiles that controll the AI, well you can do it by slic but that is more fore mods and scenarios.

        Originally posted by ushhan
        From what I understand, the Game AI seems to be controlled by using strategies and personalities settings for the different players.
        These settings are loacated in database files check out:

        ..\ctp2_data\default\aidata\strategies.txt
        ..\ctp2_data\default\aidata\personalities.txt

        - Martin
        Civ2 military advisor: "No complaints, Sir!"

        Comment


        • #5
          Thanks Martin for the info. I have CPT2 set up and running on VS 6.0. The problem is that when I start the game in Debug mode and it hits a break point, it does not give the screen control back to VS. Is there a way so that we could start the game in windowed mode rather than the full screen mode, thereby allowing me to use breakpoints and stuff?

          Comment


          • #6
            Originally posted by ushhan
            Thanks Martin for the info. I have CPT2 set up and running on VS 6.0. The problem is that when I start the game in Debug mode and it hits a break point, it does not give the screen control back to VS.
            Well so far I just used the logs via DPRINTF, not very useful for some task.

            Originally posted by ushhan
            Is there a way so that we could start the game in windowed mode rather than the full screen mode, thereby allowing me to use breakpoints and stuff?
            No windowed mode, however you could try the command line options. nonexclusive and runinbackground should be the most interesting ones.

            -Martin
            Civ2 military advisor: "No complaints, Sir!"

            Comment


            • #7
              Hi Martin,

              Thanks. I tried the 'nonexclusive' command line option and it does give the control back to VS, enabling me to use break points. Just wanted to let everyone know

              Cheers,
              Ushhan

              Comment


              • #8
                I was looking at the main game loop, specifically the beginTurn() func in the ctpai.cpp code. There are functions in SLIC which allow us to manually control units and player actions. Is it possible to use SLIC commands in the code itself? If not, how could we control manual unit movements/actions? Are there some high level commands that can be used for the same?

                Thanks

                Cheers,
                Ushhan

                Comment


                • #9
                  from what i saw slic is sometimes used in the code like to cut improvements. But what are you trying to do? it might be easier to answer your question that way.
                  Formerly known as "E" on Apolyton

                  See me at Civfanatics.com

                  Comment


                  • #10
                    Hi,

                    I want to control the actions of the human player units by using an intelligent decision making system. This system will get the game/player state information from the game server, and based on this information, provide actions for the units. Hence I wanted functions that will allow me to give high level commands to the game, for example 'move north 2 tiles'. I have seen such functions in SLIC, but am not sure how to use these commands in the game code, say in the beginturn() method in ctpai.cpp. If we can’t use the SLIC functions, are there any other functions in the game itself that will let me do this?

                    Thanks

                    Cheers,
                    Ushhan

                    Comment


                    • #11
                      The slic events are called within the game, it should be something like the g_theSlicEngine, or g_SlicEngine. There is a pathed move order command, note this is just an order that is executed when the time comes and not immediately. But you can force the order execution. This pathed move order allow you to tell your army that it should move to pointXY at the next occasion. For that you need a start, a goal and with that you can generate a path.

                      -Martin
                      Civ2 military advisor: "No complaints, Sir!"

                      Comment


                      • #12
                        How would one use the portable Activision networking code to create a TCP connection from within the ctp2 code? This connection would be to an external TCP/IP server. A code sample would be great.

                        Thanks

                        Cheers,
                        Ushhan

                        Comment


                        • #13
                          I was trying to move a unit right when the game starts in beginturn function in ctpai.cpp

                          ------
                          Unit u;
                          Army *a = new Army(1);
                          ArmyData *aData;

                          u = player_ptr->m_all_units->Access(0);

                          if (round == 3)
                          {
                          a->Insert(u);

                          aData = a->AccessData();

                          //a->AddOrders(UNIT_ORDER_MOVE, mp);
                          }

                          if (round >= 3)
                          {
                          MapPoint *mp = new MapPoint();

                          u.GetPos(*mp);
                          //Keep moving SE
                          mp->x = mp->x + 1;
                          mp->y = mp->y + 1;

                          aData->MoveUnits(*mp);
                          }
                          -------

                          It gives me an assertion failure in "a->Insert(u);". Can someone let me know what is the error here. If possible, could someone provide a simple code snipet to move a unit to some position.

                          Thanks

                          Cheers,
                          Ushhan

                          Comment


                          • #14
                            I can now move a unit in the game, but the game crashes the next turn. I have the following code in the ctpai.cpp file in the BeginTurn method:


                            Code:
                            if (player_ptr != NULL && player_ptr->m_playerType == PLAYER_TYPE_HUMAN) 
                            {
                            	if (round >= 3)
                            	{
                            		a = player_ptr->m_all_armies->Access(0);
                            
                            		for (int dir = 0; !found && (dir < NOWHERE); ++dir)
                            		{
                            			MapPoint dest;
                            
                            			if (pos.GetNeighborPosition (static_cast(dir), dest) 
                            				&& a.CanEnter(dest))
                            			{
                            				Path * tmpPath = new Path;
                            				tmpPath->SetStart(pos);
                            				tmpPath->AddDir(static_cast(dir));
                            				tmpPath->Start(pos);
                            
                            				g_gevManager->AddEvent(GEV_INSERT_Tail, GEV_MoveOrder,
                            					   GEA_Army,		a,
                            					   GEA_Path,		tmpPath,
                            					   GEA_MapPoint,	dest,
                            					   GEA_Int,			FALSE,
                            					   GEA_End
                            					  );
                            
                            				found = true;
                            			}
                            		}
                            	}
                            }
                            --------------------

                            What I think is that I am not updating some game state information and hence the is some synchronization problem the next turn. Can someone please let me know what am I doing wrong/what else I need to do to move a unit?

                            Thanks

                            Cheers,
                            Ushhan
                            Last edited by ushhan; December 2, 2005, 17:05.

                            Comment


                            • #15
                              usshan

                              Martin or Fromafar probably could help you better than I can but could you do a few things:

                              1) tell what file this code goes in, it might help understand the crash better

                              2) post the crash.txt from the game where you test it out and it crashes, it might show where it runs into something

                              3) start the code snippet by typing [ code ] (without the spaces between the brackets) and ending it with [ /code ] (again without spaces. it makes it easier to read. Also you may want to put this stuff in a need thread, maybe ushhan's source code attempts, like mine is
                              Formerly known as "E" on Apolyton

                              See me at Civfanatics.com

                              Comment

                              Working...
                              X