Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

MinchinWeb's MetaLibrary for writing AI's in OpenTTD

License

NotificationsYou must be signed in to change notification settings

minchinweb/openttd-metalibrary

Repository files navigation

MetaLibrary is the collection of code I've written forWmDOT, my AI forOpenTTD, that I felt should properly be in alibrary. Separating my AI from this library has made it easier to write myAI, but I also hope will this code will help some aspiring AI writer get offthe ground a little bit faster. ;)

GameScript

A GameScript version of this library is also available. All functions areavailable, although some may require an active company context.

Sub-Libraries Available {#sublibraries}

  • %MinchinWeb.Atlas ← _MinchinWeb_Atlas_
    • given a list of 'sources' and 'attractions', will weight the combinationsand generate a list of pairs to connect.
  • %MinchinWeb.Array ← _MinchinWeb_Array_
    • Array functions
  • %MinchinWeb.Constants ← _MinchinWeb_C_
  • %MinchinWeb.DLS ← _MinchinWeb_DLS_
    • Dominion Land System -- a wrapper on the road pathfinder to encourageroads to be built on a grid.
  • %MinchinWeb.Extras ← _MinchinWeb_Extras_
    • Extra functions, for things like math, map geometry, ship support, etc.
  • %MinchinWeb.Lakes ← _MinchinWeb_Lakes_
    • Lakes serves as a check to determine if two points are in the samewaterbody. It was written as a replacement for Waterbody Check. Lakesremembers the work it has previously done, which makes subsequent requestsmuch faster.
  • %MinchinWeb.LineWalker ← _MinchinWeb_LW_
    • Line Walker -- walk the map between two points, or start at a givenpoint and walk out at a given slope.
  • %MinchinWeb.Log ← _MinchinWeb_Log_
    • help (dynamically) control the amount of debugging output displayed.
  • %MinchinWeb.Industry ← _MinchinWeb_Industry_
  • %MinchinWeb.Marine ← _MinchinWeb_Marine_
    • Marine and ship related functions.
  • %MinchinWeb.ShipPathfinder ← _MinchinWeb_ShipPathfinder_
    • A geometry based Ship Pathfinder.
  • %MinchinWeb.SpiralWalker ← _MinchinWeb_SW_
    • Spiral Walker -- allows you to define a starting point, and then'walk' all the tiles in a spiral outward. It was originally used to find abuildable spot for my HQ in WmDOT, but is useful for many other things aswell.
  • %MinchinWeb.Station ← _MinchinWeb_Station_
    • some station related functions
  • %MinchinWeb.RoadPathfinder ← _MinchinWeb_RoadPathfinder_
    • Based on NoAI Team's pathfinder. The pathfinder uses the A* search patternand includes functions to find the path, determine its cost, and build it.Can bridge over rivers, canals, and railroad tracks.
  • %MinchinWeb.WaterbodyCheck ← _MinchinWeb_WBC_
    • Note: Waterbody Check has been deprecated in favour of Lakes
    • Waterbody Check - in effect a specialized pathfinder. It serves to checkwhether two points are in the same waterbody (i.e. a ship could travelbetween them). It is optimized to run extremely fast (I hope!). It can becalled separately, but was originally designed as a pre-run check for myShip Pathfinder.

Changelog

Version 9

Released 2015-01-10

  • bug fix to Python build script (specifically, fix NoGo library version)
  • update build script to work with Python 3000

Read the completeChangelog.

Installation {#installation}

The easiest way install MetaLibrary is the use the in-game downloader inOpenTTD.

If you want to manually install it, download the folder and place it in your../OpenTTD/ai/library/ folder.

For you to use the library in your AI's you'll need to import it. Somewhereoutside of any other class or function, add an import statement like:

Import("util.MinchinWeb", "MinchinWeb", 9);

Requirements {#requirements}

If installed from the in-game downloader, the dependencies willautomatically be downloaded and installed. Otherwise, you'll need thefollowing libraries:

OpenTTD is able to read uncompressedtar files without any problem.

FAQ {#faq}

Q: How do I use the sub-libraries directly?

A: Import the main library, and then create global points to thesub-libaries you want to use. Eg:

        Import("util.MinchinWeb", "MinchinWeb", 9);        Arrays <- MinchinWeb.Arrays;

Info: See the sub-library files for the functions available and theirimplementation.

Q: What is the _MinchinWeb_ ... all over the place?

A: I can't answer it better than Zuu when he put together his SuperLib, soI'll quote him.

" Unfortunately due to constraints in OpenTTD and Squirrel, only themain class of a library will be renamed at import. For [MetaLib]that is the [MetaLib] class in this file. Every other class in thisfile or other .nut files that the library is built up by will endup at the global scope at the AI that imports the library. Theglobal scope of the library will get merged with the global scopeof your AI.

" To reduce the risk of causing you conflict problems this libraryprefixes everything that ends up at the global scope of AIs with[ _MinchinWeb_ ]. That is also why the library is not named Utils orsomething with higher risk of you already having at your globalscope.

" You should however never need to use any of the [ _MinchinWeb_ ... ]names as a user of this library. It is not even recommended to doso as it is part of the implementation and could change withoutnotice. "

-- Zuu, SuperLib v.7 documentation

A grand 'Thank You' to Zuu for his SuperLib that provided a very usefulmodel, to all the NoAI team to their work on making the AI system work,and to everyone that has brought us the amazing game of OpenTTD.

License {#license}

Minchinweb's MetaLibrary v.9 [2015-01-10]

Copyright © 2011-15 by W. Minchin.For more info,please visithttps://github.com/MinchinWeb/openttd-metalibrary

Permission is granted to you to use, copy, modify, merge, publish,distribute, sublicense, and/or sell this software, and provide theserights to others, provided:

  • The above copyright notice and this permission notice shall be includedin all copies or substantial portions of the software.
  • Attribution is provided in the normal place for recognition of 3rd partycontributions.
  • You accept that this software is provided to you "as is", without warranty.

\note _MinchinWeb_RoadPathfinder_ is separately licensed underLGPL v.2.1.

Links {#links}

Notes To Me {#notes}

\todo Notes about static classes, what they are, and which classesare 'static'
\todo Consider Fibonacci Heap version in NoCAB
\todo Add picture of in game downloader
\todo Look into theming dOxygen output
\todo Add 'News' tab pointing back to my Blog updates on MetaLibrary


[8]ページ先頭

©2009-2025 Movatter.jp