Problem WITH!!!!! Ai

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Ar4er
Engineer
Engineer
Posts: 45
Joined: 11 Jul 2010 01:48

Re: Problem WITH!!!!! Ai

Post by Ar4er »

Can i try doing this and create more 2 nut files where is code my trucks

Code: Select all

               AILog.Info("Max amount of road vehicles reached");
               RoadPathFind.manageOnly = true;
            }
            else
            {
			if (AIBase.Chance(64, 100)) {
			// build trucks
			...
			} else {
			// build buses
			...
            }
         }
         else
         {
            AILog.Info("Sleeping because there is nothing to build");
            this.Sleep(25);
         }
      }
   }
Brumi
President
President
Posts: 921
Joined: 18 Jul 2009 17:54

Re: Problem WITH!!!!! Ai

Post by Brumi »

I'm not particularly sure what you're asking, but of course you can create more files for different things, actually it is recommended to do so.
User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2369
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: Problem WITH!!!!! Ai

Post by Lord Aro »

2 nut files: yes, although it is possible to shove it all into 1 file (i think JAMI does something like that)
your code snippet: no...


here is what i would/will do...

Code: Select all

if(AIGameSettings.GetValue("vehicle.max_roadveh") <=  numOfVehs)
         {
               AILog.Info("Max amount of road vehicles reached");
               RoadPathFind.manageOnly = true;
         }
         else
         {
               local vehpicker = AIBase.RandRange(2)
               if (vehpicker == 0)
               {
                       // build trucks
                          ...
               } else {
                       // build buses
                        ...
               }
         }
AroAI - A really feeble attempt at an AI

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
Ar4er
Engineer
Engineer
Posts: 45
Joined: 11 Jul 2010 01:48

Re: Problem WITH!!!!! Ai

Post by Ar4er »

This is in my Main.nut...So i am trying to make that my Ai makes Bus and Mail Trucks So i have 2 Nut files for bus and 2 Nut files for truck And one more question what is the name of truck station stop and mail engine what is the name on this language

Code: Select all

if(AIGameSettings.GetValue("vehicle.max_roadveh") <=  numOfVehs)
         {
               AILog.Info("Max amount of road vehicles reached");
               RoadPathFind.manageOnly = true;
         }
         else
         {
               local vehpicker = AIBase.RandRange(2)
               if (vehpicker == 0)
               {
                       // build trucks
                          ...
               } else {
                       // build buses
                        ...
               }
         }
User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2369
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: Problem WITH!!!!! Ai

Post by Lord Aro »

add this line to your info.nut:

Code: Select all

  function GetAPIVersion()    { return "1.0"; }
then go here:
http://noai.openttd.org/docs/1.0.3/
AroAI - A really feeble attempt at an AI

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 5 guests