OpenTTD AI which builds a road network between all towns it can reach.

info.nut 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * This file is part of CountryRoads, an AI for the game OpenTTD.
  3. *
  4. * CountryRoads is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * CountryRoads is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with CountryRoads. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. * Copyright 2015 Sebastian Strzelec
  18. */
  19. class CountryRoads extends AIInfo {
  20. function GetAuthor() { return "Sebastian Strzelec"; }
  21. function GetName() { return "CountryRoads"; }
  22. function GetVersion() { return 1; }
  23. function MinVersionToLoad() { return 1; }
  24. function GetDescription() { return "Country Road builder trying to build realistic roads between towns. Just Eyecandy doesn't compete with players."; }
  25. function GetAPIVersion() { return "1.3"; }
  26. function CreateInstance() { return "CountryRoads"; }
  27. function GetShortName() { return "CORO"; }
  28. function GetDate() { return "2015-01-25"; }
  29. function GetSettings()
  30. {
  31. AddSetting({
  32. name = "buildatall",
  33. description = "Build roads at all",
  34. easy_value = 1,
  35. medium_value = 1,
  36. hard_value = 1,
  37. custom_value = 1,
  38. flags = AICONFIG_BOOLEAN | AICONFIG_INGAME
  39. });
  40. AddSetting({
  41. name = "buildTwisty",
  42. description = "Build more natural roads",
  43. easy_value = 1,
  44. medium_value = 1,
  45. hard_value = 1,
  46. custom_value = 1,
  47. flags = AICONFIG_BOOLEAN | AICONFIG_INGAME
  48. });
  49. AddSetting({
  50. name = "maxBridgeLength",
  51. description = "Maximum bridge length",
  52. min_value = 1,
  53. max_value = 64,
  54. easy_value = 32,
  55. medium_value = 32,
  56. hard_value = 32,
  57. custom_value = 32,
  58. flags = 0
  59. });
  60. AddSetting({
  61. name = "maxTunnelLength",
  62. description = "Maximum tunnel length",
  63. min_value = 1,
  64. max_value = 64,
  65. easy_value = 32,
  66. medium_value = 32,
  67. hard_value = 32,
  68. custom_value = 32,
  69. flags = 0
  70. });
  71. AddSetting({
  72. name = "avoidSlopes",
  73. description = "Avoid hills / slopes",
  74. easy_value = 1,
  75. medium_value = 1,
  76. hard_value = 1,
  77. custom_value = 1,
  78. flags = AICONFIG_BOOLEAN | AICONFIG_INGAME
  79. });
  80. AddSetting({
  81. name = "avoidCoast",
  82. description = "Avoid coast tiles",
  83. easy_value = 1,
  84. medium_value = 1,
  85. hard_value = 1,
  86. custom_value = 1,
  87. flags = AICONFIG_BOOLEAN | AICONFIG_INGAME
  88. });
  89. AddSetting({
  90. name = "avoidBridges",
  91. description = "Less Bridges",
  92. easy_value = 1,
  93. medium_value = 1,
  94. hard_value = 1,
  95. custom_value = 1,
  96. flags = AICONFIG_BOOLEAN | AICONFIG_INGAME
  97. });
  98. AddSetting({
  99. name = "avoidTunnels",
  100. description = "Less Tunnels",
  101. easy_value = 1,
  102. medium_value = 1,
  103. hard_value = 1,
  104. custom_value = 1,
  105. flags = AICONFIG_BOOLEAN | AICONFIG_INGAME
  106. });
  107. AddSetting({
  108. name = "pathfinderIterations",
  109. description = "Pathfinder tiles per script tick (basically CPU usage)",
  110. min_value = 1,
  111. max_value = 128,
  112. easy_value = 128,
  113. medium_value = 128,
  114. hard_value = 128,
  115. custom_value = 128,
  116. flags = AICONFIG_INGAME
  117. });
  118. AddLabels("pathfinderIterations", {
  119. _1 = "Min",
  120. _128 = "Maximum"
  121. });
  122. AddSetting({
  123. name = "currencyMultiplier",
  124. description = "Currency multiplier (in log)",
  125. min_value = 1,
  126. max_value = 512,
  127. easy_value = 2,
  128. medium_value = 2,
  129. hard_value = 2,
  130. custom_value = 2,
  131. flags = AICONFIG_INGAME
  132. });
  133. AddLabels("currencyMultiplier", {
  134. _1 = "1 (£)",
  135. _2 = "2 ($)"
  136. });
  137. AddSetting({
  138. name = "buildcars",
  139. description = "Build Cars",
  140. min_value = 1,
  141. max_value = 3,
  142. easy_value = 3,
  143. medium_value = 3,
  144. hard_value = 3,
  145. custom_value = 3,
  146. flags = 0
  147. });
  148. AddLabels("buildcars", {
  149. _1 = "Never",
  150. _2 = "From start"
  151. _3 = "After roads"
  152. });
  153. AddSetting({
  154. name = "zerorccars",
  155. description = "Use zero cost cars",
  156. min_value = 1,
  157. max_value = 3,
  158. easy_value = 2,
  159. medium_value = 2,
  160. hard_value = 2,
  161. custom_value = 2,
  162. flags = AICONFIG_INGAME
  163. });
  164. AddLabels("zerorccars", {
  165. _1 = "No (Normal Busses only)",
  166. _2 = "Auto (Zero costs preferred)",
  167. _3 = "Only zero costs",
  168. });
  169. }
  170. }
  171. RegisterAI(CountryRoads());