The results were algorithms that can help AI programmers. Four main functions were created: IndustryLandAllocation, CityLandAllocation, IndustryRailroadStationConstruction and RailroadConstruction.
The first two are very similar. Their parameters are:
- Height
- Width
- Validate Land: a function that receives the land position and return a number from 0 to 1 (float) representing the evaluation. If 0 then the land won’t be allocated.
- Maximum cost: the maximum value that can be expended doing terraforming.
- Coverage maximum distance: the maximum distance coverage by the station. It is just used on IndustryLandAllocation.
- Swap Height and Width: indicates that Height and Width can be swapped.
- Allocated land: output the dimensions and location of allocated land.
- Cost priority: a number from 0 to 1 (float) representing the importance of the cost during the process of allocation. If 0 then cost has no importance. The cost is used together with the value returned by Validate Land function.
- Purchase land: say to the function if the land must be purchased.
- Industry / City: the industry or city near where the land must be allocated.
The function IndustryRailroadStationConstruction uses IndustryLandAllocation to allocate the land that will be used to construct the station. The stations are always constructed in pairs because the orientation is very important. The idea here is to choose a orientation that will help railroad track deployment. Its parameters are:
- Source industry
- Destiny industry
- Number of tracks
- Plataform length
- Railroad track type
RailroadConstruction uses A* algorithm to create a two way railroad tracks. Here was used an abstraction based on railroad parts. These parts were created to incase perfectly and form a singed two way railroad compatible with the stations. The most important result is that the algorithm uses terraform to create better tracks (similar to tracks created by human players).
I know that you’re doing a new framework for AI. I developed all this work using C/C++ OpenTTD (0.61) internal functions but the focus of this work was the algorithms that can be implemented using any language. I think these algorithms could be part of the NoAI so that programmers can easily do some common tasks.
So, i want to know if this work can help OpenTTD project.
I can send the source code if it’s necessary. The main problem is that the code is “in Portuguese”.
Currently, I am trying to apply some techniques of Operation Resarch on the game. In the future, I will need some help of the community (if possibly) to evaluate the quality of tracks created by algorithms. Because I used abstract concepts (similarity to expert player’s tracks) I will need human’s evaluation.
PS: I attached some screenshots.
Patch
Thanks.