Author Topic: outdated terrain generation proposal  (Read 18328 times)

Offline davide

  • Commander
  • *****
  • Posts: 565
    • View Profile
outdated terrain generation proposal
« on: September 11, 2014, 10:55:35 am »

Hi,

I would like to offer my contribute to  extend the engine algorithm to support generation terrain map for OpenTFTD
and expose the new features by ruleset to allows modders to use it.

I wish that my contribute will be merged into main source code branch therefore
all thing that I will make will be undergo to developer Boss review


The TFTD vanilla needs that I recognize:

  • Islands has a constraint on left maps:a group of maps has sea waves
  • Port has a constraint on bottom maps: a group of maps has docks
  • "Alien base landing (level 1)" has positional constraint on all maps
  • "Crashed Plane"  has constraints on central maps on a cross line for connect segmented part of airplane
  • Cruiser/Cargo Ship  terrain have  two huge rectangle maps
  • Cruiser/Cargo Ship  do not have a specific  landing clear and flat map, but XCom Craft has to land on specific position of a very complex map

I  can follow any additional requirements/needs too.

I suppose that skilled modders will be interested to use these new features with current OpenXCom too.

As example for recover UFO2000 terrains named Siberia, Sand Storm and Normandy.





« Last Edit: December 06, 2014, 07:49:54 pm by davide »

Offline davide

  • Commander
  • *****
  • Posts: 565
    • View Profile
A case study with Ufo2000 terrain Normandy
« Reply #1 on: September 11, 2014, 11:01:37 am »
It has a lot of requirements such as TFTD terrain.

  • It has positional constraint on five group of maps: from left (the beach) to right (the bunker)
  • It is based on rectangular maps
  • It has a requirements on  landing position.

An image could be more clear that my little english


The  ruleset fragment:
Code: [Select]
terrains:
  - name: NORMANDY
    mapDataSets:
      - BLANKS
      - BON1
      - BON2
      - BON3
    largeBlockLimit: 20
    width: [60. 40, 80]
    length: [60, 60, 60]
    craftPositions:
      - [0, 40, 60, 20]
    mapBlocks:
     - name: BON_1
       width: 10
       length: 20
       type: 1
       subType: 0
     - name: BON_3
       width: 10
       length: 10
       type: 1
       subType: 0
     - name: BON_4
       width: 10
       length: 10
       type: 1
       subType: 0
       onY: [40]
     - name: bon_5
       width: 20
       length: 10
       type: 1
       subType: 0
     - name: bon_2
       width: 10
       length: 10
       onY: [50]
     - name: bon_51
       width: 20
       length: 10
       onY: [50]
     - name: bon_52
       width: 20
       length: 10
       onY: [50]
     - name: bon_53
       width: 20
       length: 10
       onY: [50]
     - name: bon_54
       width: 20
       length: 10
       onY: [50]
     - name: bon_61
       width: 10
       length: 10
       onY: [40]
     - name: bon_62
       width: 10
       length: 10
       onY: [40]
     - name: bon_63
       width: 10
       length: 10
       onY: [40]
     - name: bon_64
       width: 10
       length: 10
       onY: [40]
     - name: bon_65
       width: 10
       length: 10
       onY: [40]
     - name: bon_66
       width: 10
       length: 10
       onY: [40]
     - name: bon_71
       width: 20
       length: 10
       maxCount: 1
       onlyEvenX: true
       onY: [30]
     - name: bon_72
       width: 20
       length: 10
       maxCount: 1
       onlyEvenX: true
       onY: [30]
     - name: bon_73
       width: 20
       length: 10
       maxCount: 1
       onlyEvenX: true
       onY: [30]
     - name: bon_74
       width: 20
       length: 10
       maxCount: 1
       onlyEvenX: true
       onY: [30]
     - name: bon_81
       width: 20
       length: 20
       maxCount: 1
       onlyEvenX: true
       onY: [10]
     - name: bon_82
       width: 20
       length: 20
       maxCount: 1
       onlyEvenX: true
       onY: [10]
     - name: bon_83
       width: 20
       length: 20
       maxCount: 1
       onlyEvenX: true
       onY: [10]
     - name: bon_84
       width: 20
       length: 20
       maxCount: 1
       onlyEvenX: true
       onY: [10]
     - name: bon_91
       width: 20
       length: 10
       maxCount: 1
       onlyEvenX: true
       onY: [0]
     - name: bon_92
       width: 20
       length: 10
       maxCount: 1
       onlyEvenX: true
       onY: [0]
     - name: bon_93
       width: 20
       length: 10
       maxCount: 1
       onlyEvenX: true
       onY: [0]
     - name: bon_94
       width: 20
       length: 10
       maxCount: 1
       onlyEvenX: true
       onY: [0]
« Last Edit: November 05, 2014, 12:28:50 am by davide »

Offline davide

  • Commander
  • *****
  • Posts: 565
    • View Profile
Re: [PLEASE do not reply to this post because I need some time to complete it]
« Reply #2 on: September 11, 2014, 11:23:30 am »
I am sorry :-[

I come back later to enum the

-New terrain attribute
-New maps attribute
-some general note about the algorithm

Offline davide

  • Commander
  • *****
  • Posts: 565
    • View Profile
MapBlock entity
« Reply #3 on: September 11, 2014, 12:54:26 pm »
MapBlock entity has new optional attributes exposed to ruleset:

  • odds to reduce probability to choose a maps
    (it is the opposite of frequency)
  • mandatory to force the selection of this map, it could be use for access lift
    (probably it as to be used in conjunction with maxCount = 1)
  • onX is a vector with the allowed X position
    (such as sea front of TFTD Island Terrain)
  • onY is a vector with the allowed Y position
    (such as line of docks of TFTD Port Terrain)
  • craftOffsetX is a int value offset used to move the origin of this current landing map when craft map is merged on it
    (It is born to support Cargo/Cruise ship terrain generation)
  • craftOffsetY is the dual of previous

One value is randomly selected from onX and one from onY vectors when the vector size is greater than one
« Last Edit: September 14, 2014, 11:22:32 pm by davide »

Offline davide

  • Commander
  • *****
  • Posts: 565
    • View Profile
RuleTerrain entity
« Reply #4 on: September 11, 2014, 01:20:12 pm »
The original attribute largeBlockLimit in the previous algorithm was the max number of maps of size 20x20
in mine proposal it drive maps of size 20x10 and 10x20 too.
"Vanilla" terrains are not affected because the rectangular maps were not supported.

I add new optional attributes

  • largeBlockLimit30to40 to set the max number of rectangular maps that have at least one dimension equal to 30 or 40
    (10x30, 30x30, 40x10, 40x20, and so on)
  • largeBlockLimit50orMore to set the max number of rectangular maps that have at least one dimension greater or equal to 50
    (50x20, 60x60, 30x50 such as TFTD ships, 30x70, and so on)
  • width is a vector with the allowed X dimension of terrain (it override the default mission dimension)
  • lenght is a vector with the allowed Y dimension of terrain (it override the default mission dimension)
  • height is a single value with the Z dimension of terrain (it override the default mission dimension)
  • craftX is a vector with the allowed X coordinate of XCom craft landing map[/color]
  • craftY is a vector with the allowed Y coordinate of XCom craft landing map[/s]

One value is randomly selected from width and from lenght vectors when the vector size is greater than zero.
When both vectors are defined, only one index will be randomize (in range 0 to minSize) and used to select a couple of w and l

In the first prototipe,craftX and craftY are single value: them could will be vectors.
I adopted same rule to select craftX and craftY.

The syntax of vector attributes craftX and craftY were refactored/merged to the new matrix attribute craftPositions

I adopted the optional attribute ufoPositions too

and added the new roadPositions and for a second set of road, roadPositions2

« Last Edit: November 05, 2014, 12:38:29 am by davide »

Offline davide

  • Commander
  • *****
  • Posts: 565
    • View Profile
Re: [PLEASE do not reply to this post because I need some time to complete it]
« Reply #5 on: September 11, 2014, 04:30:45 pm »
Please do not add other comment for the moment because I am preparing a proposal for Warboy

The problem is very difficult and I have to explain him what I already made

I seek a compromise between the features needed by TFTD and new opportunity of modding.
I seek to remain near to the structure of the original algorithm to render more simple a review to a Boss and minimize the risk to introduce regressions
I seek to cover already existing terrain types before plan to add new features that was not request by map makers

If Warboy will be interested about my work is it possible that the discussion will be open to all

Do you write c++ code runnable that implement the map generation algorithm with your ruleset
or you only project the syntax of the new ruleset ?
« Last Edit: September 11, 2014, 04:41:32 pm by davide »

Offline davide

  • Commander
  • *****
  • Posts: 565
    • View Profile
A case study with Ufo2000/TFTD terrain Plane Crash site
« Reply #6 on: September 12, 2014, 07:36:36 pm »
I lose a wing ... for now  ;)(I fixed the ruleset)

Probably the map composition is not vanilla ... :-[

Lightinight craft map dimension block a lot of positions

The  ruleset fragment:

Code: [Select]
  - name: PLANECRASH
    mapDataSets:
      - BLANKS
      - PC_SANDS
      - PC_BIRD
      - PC_DUMMY
    largeBlockLimit: 2
    width: [60]
    length: [60]
    craftX: [0,10,40,50,40]
    craftY: [0,0,0,0,40]
    mapBlocks:
     - name: PLANE00
       width: 10
       length: 10
       type: 1
       subType: 0
     - name: PLANE01
       width: 10
       length: 10
     - name: PLANE02
       width: 10
       length: 10
     - name: PLANE03
       width: 10
       length: 10
     - name: PC_PLANE04
       width: 10
       length: 10
       maxCount: 1
       onX: [50]
       onY: [30]
     - name: PC_PLANE05
       width: 10
       length: 10
       maxCount: 1
       onX: [50]
       onY: [30]
     - name: PC_PLANE06
       width: 10
       length: 10
       maxCount: 1
       onX: [30]
       onY: [30]
     - name: PC_PLANE07
       width: 10
       length: 10
       maxCount: 1
       onX: [10]
       onY: [30]
     - name: PC_PLANE08
       width: 10
       length: 10
       maxCount: 1
       onX: [40]
       onY: [30]
     - name: PC_PLANE09
       width: 10
       length: 10
       maxCount: 1
       onX: [40]
       onY: [30]
     - name: PC_PLANE10
       width: 10
       length: 10
       maxCount: 1
       onX: [20]
       onY: [30]
     - name: PC_PLANE11
       width: 10
       length: 10
       maxCount: 1
       onX: [20]
       onY: [30]
     - name: PLANE12
       width: 10
       length: 10
       maxCount: 1
       onX: [0]
       onY: [30]
     - name: PLANE13
       width: 20
       length: 20
       maxCount: 1
       onX: [20]
       onY: [10]
     - name: PLANE14
       width: 20
       length: 20
       maxCount: 1
       onX: [20]
       onY: [10]
     - name: PLANE15
       width: 20
       length: 20
       maxCount: 1
       onX: [20]
       onY: [40]
     - name: PLANE16
       width: 20
       length: 20
       maxCount: 1
       onX: [20]
       onY: [40]
     - name: PLANE17
       width: 10
       length: 10
       maxCount: 1
       onX: [10]
       onY: [20]
     - name: PLANE18
       width: 10
       length: 10
       maxCount: 1
       onX: [10]
       onY: [20]
     - name: PLANE19
       width: 10
       length: 10
       maxCount: 1
       onX: [10]
       onY: [40]
     - name: PLANE20
       width: 10
       length: 10
       maxCount: 1
       onX: [10]
       onY: [40]
« Last Edit: October 14, 2014, 04:46:45 pm by davide »

Offline davide

  • Commander
  • *****
  • Posts: 565
    • View Profile
Cargo Ship
« Reply #7 on: September 13, 2014, 01:04:06 pm »
Some troble with routes

There is a unique map and  try to use it as landing maps

The  pilot of my cfraft needs some lessons of driving school ...
He throw down the bulwark of ship



I have to load its route file but I found a bug into TileEngine::voxelCheck:
I add a check for valid index:

   https:// first we check terrain voxel data, not to allow 2x2 units stick through walls
   for (int i=0; i< 4; ++i)
   {
      MapData *mp = tile->getMapData(i);
      if (tile->isUfoDoorOpen(i))
         continue;
      if (mp != 0)
      {
         int x = 15 - voxel.x%16;
         int y = voxel.y%16;
         int idx = (mp->getLoftID((voxel.z%24)/2)*16) + y;
         if (idx < _voxelData->size() && (_voxelData->at(idx) & (1 << x)))
         {
            return i;
         }
      }
   }


 but there are some old post in the forum about route problem ...

Code: [Select]
terrains:
  - name: CARGOSHIP1
    mapDataSets:
      - BLANKS
      - SEA
      - CARGO1
      - CARGO2
      - XBITS
      - CARGO3
    width: [30]
    length: [70]
    craftY: [0]
    craftX: [0]
    mapBlocks:
     - name: CARGO00
       width: 30
       length: 70
       type: 1
       subType: 0
« Last Edit: September 14, 2014, 11:02:35 pm by davide »

Offline davide

  • Commander
  • *****
  • Posts: 565
    • View Profile
Cruise Ship
« Reply #8 on: September 14, 2014, 10:40:51 am »
big parking problem !

I can move to an other starting block
but remains unit offset depends on specific craft
 (fortunately TFTD crafts are well alligned to craft map rear but those of UFO are not ....)
Avenger for example, look its map ...I have to crop some tiles to minimize collisions to ship structure
I have to reserve 2 tile in the rear to allows robots to move
I think that I can try to do it by code ...
after that I think that there is already same code that remove some tiles overlapped to craft ...

Code: [Select]
  - name: CRUISESHIP1
    mapDataSets:
      - BLANKS
      - DECKC
      - LINERA
      - LINERB
      - LINERC
      - LINERD
    width: [30]
    length: [70]
    craftPositions:
      - [0, 0, 10, 20]
    mapBlocks:
     - name: LINERT01
       width: 30
       length: 50
       type: 1
       subType: 0
       craftOffsetX: 10
     - name: LINERT00
       width: 30
       length: 20
       onX: [0]
       onY: [50]
« Last Edit: November 05, 2014, 12:45:55 am by davide »

Offline davide

  • Commander
  • *****
  • Posts: 565
    • View Profile
Cargo Ship well parked
« Reply #9 on: October 14, 2014, 04:23:14 pm »
Code: [Select]
  - name: CARGOSHIP1
    mapDataSets:
      - BLANKS
      - SEA
      - CARGO1
      - CARGO2
      - XBITS
      - CARGO3
    width: [30]
    length: [70]
    craftPositions:
      - [0, 0, 10, 20]
    mapBlocks:
     - name: CARGO00
       width: 30
       length: 70
       type: 1
       subType: 0
       craftOffsetX: 5
       craftOffsetY: 1
« Last Edit: November 05, 2014, 01:44:47 am by davide »

Offline davide

  • Commander
  • *****
  • Posts: 565
    • View Profile
Island
« Reply #10 on: October 14, 2014, 04:24:43 pm »
Code: [Select]
  - name: ISLAND
    mapDataSets:
      - BLANKS
      - SEA
      - ISLAND1
      - ISLAND2
      - ISLAND3
    width: [50]
    length: [50]
    largeBlockLimit: 3
    craftPositions:
      - [0, 0, 50, 20]
    mapBlocks:
     - name: ISLAND00
       width: 10
       length: 10
       type: 1
       subType: 0
     - name: ISLAND01
       width: 10
       length: 10
       type: 1
       subType: 0
     - name: ISLAND02
       width: 20
       length: 20
       maxcount: 1
     - name: ISLAND03
       width: 20
       length: 20
       maxcount: 1
     - name: ISLAND04
       width: 20
       length: 20
       onY: [30]
       maxcount: 1
     - name: ISLAND05
       width: 20
       length: 20
       onY: [30]
       maxcount: 1
     - name: ISLAND06
       width: 20
       length: 20
     - name: ISLAND07
       width: 10
       length: 10
       onY: [40]
       even: true
     - name: ISLAND08
       width: 10
       length: 10
     - name: ISLAND09
       width: 10
       length: 10
     - name: ISLAND10
       width: 10
       length: 10
     - name: ISLAND11
       width: 10
       length: 10
     - name: ISLAND12
       width: 10
       length: 10
     - name: ISLAND13
       width: 10
       length: 10
     - name: ISLAND14
       width: 10
       length: 10
« Last Edit: November 05, 2014, 12:55:40 am by davide »

Offline davide

  • Commander
  • *****
  • Posts: 565
    • View Profile
Port
« Reply #11 on: October 14, 2014, 04:25:24 pm »
Code: [Select]
  - name: PORT
    mapDataSets:
      - BLANKS
      - SEA
      - PORT01
      - PORT02
    width: [50]
    length: [50]
    mapBlocks:
     - name: PORT00
       width: 10
       length: 10
       type: 1
       subType: 0
     - name: PORT01
       width: 10
       length: 10
       type: 1
       subType: 0
     - name: PORT02
       width: 10
       length: 10
       onX: [40]
     - name: PORT03
       width: 10
       length: 10
       onX: [40]
     - name: PORT04
       width: 10
       length: 10
       onX: [40]
     - name: PORT05
       width: 10
       length: 10
       onX: [40]
     - name: PORT06
       width: 10
       length: 10
       onX: [40]
     - name: PORT07
       width: 10
       length: 10
       onX: [40]
     - name: PORT08
       width: 10
       length: 10
       onX: [40]
     - name: PORT09
       width: 10
       length: 10
       onX: [40]
     - name: PORT10
       width: 10
       length: 10
     - name: PORT11
       width: 10
       length: 10
     - name: PORT12
       width: 10
       length: 10
     - name: PORT13
       width: 10
       length: 10
     - name: PORT14
       width: 10
       length: 10
     - name: PORT15
       width: 10
       length: 10
     - name: PORT16
       width: 10
       length: 10
     - name: PORT17
       width: 20
       length: 20
     - name: PORT18
       width: 20
       length: 20
     - name: PORT19
       width: 20
       length: 20
     - name: PORT20
       width: 20
       length: 20
       onX: [0,10,20]
       onY: [0]
« Last Edit: October 14, 2014, 04:43:35 pm by davide »

Offline davide

  • Commander
  • *****
  • Posts: 565
    • View Profile
Landing on Alien Base
« Reply #12 on: October 14, 2014, 04:26:40 pm »
Code: [Select]
  - name: ALIENBASE1
    mapDataSets:
      - BLANKS
      - SAND
      - UEXT2
      - UEXT3
      - ORGANIC1
      - ENTRY
    width: [60]
    length: [60]
    largeBlockLimit: 9
    craftPositions:
      - [0, 0, 10, 20]
      - [0, 40, 10, 20]
      - [40, 0, 10, 20]
      - [40, 40, 10, 20]
    mapBlocks:
     - name: ENTRY00
       width: 20
       length: 20
       type: 1
       subType: 0
       craftOffsetX: 10
       onY: [0]
       onX: [0]
     - name: ENTRY01
       width: 20
       length: 20
       onY: [0]
       onX: [20]
     - name: ENTRY02
       width: 20
       length: 20
       type: 1
       subType: 0
       onY: [0]
       onX: [40]
     - name: ENTRY03
       width: 20
       length: 20
       onY: [20]
       onX: [0]
     - name: ENTRY04
       width: 20
       length: 20
       onY: [20]
       onX: [20]
     - name: ENTRY05
       width: 20
       length: 20
       onY: [20]
       onX: [40]
     - name: ENTRY06
       width: 20
       length: 20
       type: 1
       subType: 0
       craftOffsetX: 10
       onY: [40]
       onX: [0]
     - name: ENTRY07
       width: 20
       length: 20
       onY: [40]
       onX: [20]
     - name: ENTRY08
       width: 20
       length: 20
       onY: [40]
       onX: [40]
       type: 1
       subType: 0
« Last Edit: November 05, 2014, 12:50:34 am by davide »

Offline davide

  • Commander
  • *****
  • Posts: 565
    • View Profile
Alien Base step2
« Reply #13 on: November 05, 2014, 01:39:42 am »
 :o
How to connect the maps ?
 :-\

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: [PLEASE do not reply to this post because I need some time to complete it]
« Reply #14 on: November 05, 2014, 06:03:15 am »
remove the dirt portion in the map where the normally "door creation-magic" happens ?