As a French person I feel like it's my duty to explain strikes to you. - AdrienIer

Create an account  

 
Civ6 with Custom World Builder Map

Excellent work Trasson! I did some more testing, here is what I've found to add:

• Importing the Players and PlayerAttributes tables was sufficient to load City States properly. I don't think editing of the StartPosition in your #5 is necessary.
• The actual values in the Players and PlayerAttributes tables don't seem to have much (if any) effect. So much so that I created a script to auto-create and import the tables with identical parameters for each player/CS (except for the player ID). I will put the script details in the next post.
• The number of city states is not hard-coded to 9, as suggested when starting a 6 Arm Snowflake map. I successfully started a game with 18 city states generated. The only difference was that I imported Players and PlayerAttributes tables with 18 city states.
• I did confirm that specific players can be assigned to specific starting locations. This can be done by selecting "Leader" for the starting player location, and selecting the appropriate leader from the secondary dropdown. This worked independent of the civs that were selected while rolling the map, as long as all start locations were set to "Leader" and those leaders were actually selected during game setup.
• I also tried but was unable to get specific city states assigned to specific locations.

Regarding the World Builder editor itself:
• One-tile-at-a-time editing is t-e-d-i-o-u-s. However minor edits to a rolled map such as balancing starting positions, adding some fresh water for 2nd city locations, locating city states somewhat equally, adding a couple more land tiles to connect continents/island via coast, etc. are doable since they would be done one tile at a time anyway.
• The natural wonders in the editor are buggy (at least the 2+ tile ones). The 2+ tile wonders cannot be placed on the map, and when deleting them they are still recognized as present on at least one of the tiles, even though not shown in the editor.
• The tile visibility tool is buggy. Once selected all tiles turn dim fog-of-war, as though they have been previously explored but currently out of line of sight. I wasn't able to actually change visibility for civs and the display was stuck dim even when switching back to other tools. (as an aside, the fogged-tile graphics are one of my least favorite GUI "features" since I find fogged-tiles incredibly difficult to differentiate without mousing over).
Reply

As mentioned in my previous post I created a script to initialize a World-Builder-Created Civ6Map by auto-creating and importing the Players and PlayerAttributes tables. I do not know anything about SQLite, so I used AutoHotkey to make the necessary edits using the DB Browser program, including copy/paste of the map file to BalancedMaps folder. I am a recreational coder at best so this could surely be done in a more efficient manner and more generalized. There is currently no user interface, all user inputs are currently located at the top of the script and changed via text editor, and has a couple limitations/quirks (see below). In any case, the below works for me:

Requirements:
• Program: AutoHotkey
• Program: DB Browser
• Copy-paste script from spoiler below, save-as InitializeCiv6Map.ahk using a text editor (I wasn't sure if it was kosher to upload an actual script file)
• Update the User Inputs section towards the top of the scrip to the proper values including the map folders and DB Browser program target.

The script does the following actions:
*) Hotkey for initializing Civ6Map: CTRL+ALT+a
1) Copy the specified map [user input: map name] from the WorldBuilder, changing the name to Balanced6.Civ6Map and overwriting the current file of that name
2) Delete any current Players.csv and PlayerAttributes.csv files in folder from which the script is run.
3) Create the Players.csv and PlayerAttributes.csv files, which will be imported into the map file [user inputs: number of players, number of city states]
4) Open DB Browser ... NOTE! An open instance of DB Browser with an open-and-edited-but-unsaved file will cause the script to wack-out with the popup prompting to save the changes. The script will roll right along, I believe accepting the changes, not ending up with a properly-edited Civ6Map file, and possibly damange the file that was already open. YOU HAVE BEEN WARNED!
5) Clear all existing entries from the Players and PlayerAttributes tables. I had to use MouseClick commands for a couple of the buttons that I couldn't find DB Browser keyboard commands, might require user-specific tweaking for resolution differences. I think it properly accounts for changing the window size, but no guarantees.
6) Import Players.csv and PlayerAttributes.csv files created above ... NOTE! you first need to do a manual import and make sure the "Column names in first line" checkbox on the import popup is unchecked. The only way I could find to test if this box was check was using an image search command which I didn't even test since this is the only thing I use DB Browser for and the checkbox remembers last-used state.
7) Save, close DB Browser, delete the temporarily-used Player.csv and PlayerAttributes.csv files by moving to the recycle bin
*) The script also includes a hotkey for reloading the script (i.e. after editing): CTRL+ALT+z
*) The script also includes a hotkey for testing smaller subsets of code: CTRL+ALT+x. I used this to emperically create the script in a step-by-step manner, testing each successive step before incorporating into the working script.


Script text in spoiler:
Code:
;Scrip to initialize a World-Builder-Created Civ6Map by auto-creating and importing the Players and PlayerAttributes tables.
;Requires the program DB Browser for SQLite to be installed

#SingleInstance force


^!a:: ; CTRL+ALT+a
;User Inputs
NumPlayers := 6
NumCityStates := 9
MapName := "Test_Map_04.Civ6Map"
MapFolder := "C:\Users\USER\Documents\My Games\Sid Meier's Civilization VI\Saves\WorldBuilder\" ;IMPORTANT! Make sure to include trailing backslash \
BalancedMapFolder := "C:\Program Files (x86)\Steam\SteamApps\common\Sid Meier's Civilization VI\Base\Assets\Maps\BalanceMaps\" ;IMPORTANT! Make sure to include trailing backslash \
DBBrowserTarget := "C:\Program Files\DB Browser for SQLite\DB Browser for SQLite.exe"


;Define position references relative to the Client
CoordMode, Pixel, Client
CoordMode, Mouse, Client

;Start by copying the specified map to the Balanced Maps folder and rename to Balanced6.Civ6Map,overwriting any existing Balanced6.Civ6Map file
MapLocation := MapFolder . MapName
DestinationFile := BalancedMapFolder . "Balanced6.Civ6Map"
FileCopy, %MapLocation%,%DestinationFile%,1

;Create Player.csv and PlayerAttributes.csv, first checking if these files exist and deleting them if they do already exist
IfExist, Players.csv
{
    FileRecycle, Players.csv
}
IfExist, PlayerAttributes.csv
{
    FileRecycle, PlayerAttributes.csv
}
CivString = ,UNDEFINED,UNDEFINED,CIVILIZATION_LEVEL_FULL_CIV,,Human,DIFFICULTY_PRINCE,INVALID,PLAYERCOLOR_LIGHT_ORANGE,0`n
CityStateString = ,RANDOM,RANDOM,CIVILIZATION_LEVEL_CITY_STATE,,AI,DIFFICULTY_PRINCE,INVALID,CIVILIZATION_KUMASI,1`n
AttributesString = ,Era,ERA_ANCIENT,0`n
BarbarianString = 63,CIVILIZATION_BARBARIAN,UNDEFINED,CIVILIZATION_LEVEL_TRIBE,,AI,DIFFICULTY_PRINCE,INVALID,CIVILIZATION_BARBARIAN,1
PlayerString =
PlayerAttributesString =
x := 0
LoopDuration := NumPlayers + NumCityStates
Loop, %LoopDuration%
{
    If (x < NumPlayers)
    {
        PlayerString := PlayerString . x . CivString    
    }
    Else
    {
        PlayerString := PlayerString . x . CityStateString
        PlayerAttributesString := PlayerAttributesString . x . AttributesString
    }
    x := x + 1
}
PlayerString := PlayerString . BarbarianString ;Add Barbarian line at the end
PlayerAttributesString := PlayerAttributesString . 63 . AttributesString ;Add Barbarian line at the end
FileAppend, %PlayerString%, Players.csv
FileAppend, %PlayerAttributesString%, PlayerAttributes.csv


;Import the newly-created Players.csv and PlayerAttributes.csv into the Civ6Map using DB Browser
;First check if DB Browser is open, either activate or open as needed
IfWinExist ahk_exe DB Browser for SQLite.exe
    winactivate ahk_exe DB Browser for SQLite.exe
else
    run, %DBBrowserTarget%
WinWait ahk_exe DB Browser for SQLite.exe
WinActivate ahk_exe DB Browser for SQLite.exe
WinWaitActive ahk_exe DB Browser for SQLite.exe
WinGetPos,,,WinWidth
DeleteX := WinWidth - 435 ;Find horizonal position of the Delete button, used below to delete entries from Players and PlayerAttributes tables. The button's position is located relative to the right of the window (moves as the window is resized), while the MouseClick command used position relative to the left.

;Open Map file, use the clipboard to type long text sequence faster. Original Clipboard contents are temporarily stored to a variable and then restored to the Clipboard at the end of the script
ClipSaved := ClipboardAll
Clipboard := DestinationFile
Send,{Ctrl down}o{Ctrl up}
WinWaitActive Choose a database file
Send,{Ctrl down}v{Ctrl up}{Enter}

;Clear all entries from Players and PlayerAttributes tables
WinWaitActive DB Browser
MouseClick, left, 166, 75
MouseClick, left, 131, 108
Send,p
Sleep 300
Send,{Enter}{Tab}{Tab}{Tab}{Tab}{Tab}{Tab}{Ctrl down}a{Ctrl up}
MouseClick, left, DeleteX, 108
MouseClick, left, 131, 108
Send,p
Sleep 300
Send,{Enter}{Tab}{Tab}{Tab}{Tab}{Tab}{Tab}{Ctrl down}a{Ctrl up}
MouseClick, left, DeleteX, 108

;Import Players.csv and PlayerAttributes.csv
Clipboard := A_ScriptDir . "\Players.csv"
Send,{Alt down}f{Alt up}it
WinWaitActive Choose a text file
Send,{Ctrl down}v{Ctrl up}{Enter}
WinWaitActive Import CSV file
Send,{Enter}
WinWaitActive,DB Browser
Send,{Enter}
WinWaitActive,DB Browser
Send,{Enter}
WinWaitActive,DB Browser
Clipboard := A_ScriptDir . "\PlayerAttributes.csv"
Send,{Alt down}f{Alt up}it
WinWaitActive Choose a text file
Send,{Ctrl down}v{Ctrl up}{Enter}
WinWaitActive Import CSV file
Send,{Enter}
WinWaitActive,DB Browser
Send,{Enter}
WinWaitActive,DB Browser
Send,{Enter}
WinWaitActive,DB Browser

;Write Changes (i.e. save) and close DB Browser
Send,{Ctrl down}s{Ctrl up}
WinClose

;Delete Player.csv and PlayerAttributes.csv files that were created above
FileRecycle, Players.csv
FileRecycle, PlayerAttributes.csv

;Restore original Clipboard contents that were temporarily saved to a variable, then clearing the temporary variable.
Clipboard := ClipSaved
ClipSaved =

Return

;The following HotKey is for reloading the current script after editing the script
^!z:: ; CTRL+ALT+z
run InitializeCiv6Map.ahk /restart
Return

;The following HotKey is for testing smaller subsets of code before integrating into the above
^!x::


Return
Reply

So the big question: are these tools usable to create the map for the PBEM4 game? I'd much rather make use of these tools than roll dozens of maps hoping to get lucky, although the programming in these posts is likely beyond my abilities.
Follow Sullla: Website | YouTube | Livestream | Twitter | Discord
Reply

(July 5th, 2017, 21:32)Sullla Wrote: So the big question: are these tools usable to create the map for the PBEM4 game? I'd much rather make use of these tools than roll dozens of maps hoping to get lucky, although the programming in these posts is likely beyond my abilities.

Absolutely. The biggest roadblock is that editing with the ingame Civ6 worldbuilder is fairly slow an obnoxious. That said, it's slow and obnoxious in a usable way. If you can bear with that, everything we've come up with is just making it so your edited map can have city states and have them spawn in the locations of your choosing. That part doesn't require any special technical skill beyond knowing how to use an OS: while it's intuitive if your job happens to involve databases, you really can follow what's going on without knowing what it's doing as long as it gets the result.

That being said, while you can design the whole map in Worldbuilder, I'd, as mentioned, suggest taking a few randomly generated maps and picking from them to edit as you'll get 95% of what you want with 10% of the work. It should still definitely be better than picking the best randomly rolled map you get since you're not going to run into "Oh wow this would be perfect if I could change these five tiles but I can't so let's burn another hour!".
Reply

The post about the script is not essential, just a tool that would save time if you were doing many maps. If you make the map edits, we can upload the Players.csv and PlayerAttributes.csv files with the proper number of players/city states for you to import (How many city states were decided?). Once you get DB Browser installed it is really just a couple clicks make the necessary edits, then copy and re-name to the BalancedMaps folder to start the game.

DB Browser for SQLite can downloaded from here: http://sqlitebrowser.org/

STEP BY STEP
1. As always, make a backup copy of your map just in case smile
2. Open the map in DB Browser (need to select All Files to see .Civ6Map files)
   
3. Click Browse Data tab -> Select PlayerAttributes
4. Click any of the cells in the table, then type CTRL+a to select all, then click "Delete Record" to clear the table
   
5. Go to File -> Import -> Table from CSV File
   
6. Navigate to the PlayerAttributes.csv file that you want to import, click Open
7. Confirm the "Column names in first line" checkbox in NOT checked, click OK. There will be another popup telling you "There is already a table of that name ...", click "Yes".
   
8. Repeat steps 3-7, this time clearing the Players table and importing Players.csv
9. Type CTRL+s to save the changes
Reply

You guys are awesome!

Sullla, do you feel like you will be able to use the worldbuilder on the PBEM4 map, or would you prefer to go ahead with what we already had in mind?
Reply

As a final precaution, I made a hotseat game with a custom map and tried a couple more things (tiny map, 4 players, 10 city states). Please someone download the test game from the following link and make sure that this plays on other computers: https://www.dropbox.com/s/9q1evbce29kunp...6Save?dl=1 There's still a small chance that games might only work on the creator's computer (I don't expect that, but better to find out now than before Sulla spends time fine tuning a map)

A couple more things that I tested
• Adding additional land to what was previously coast. Worked without issue, maintained same continent designation as adjacent land. Resulted in some wonky out-of-place cliff graphics in the middle of the newly drawn plain that I wasn't able to delete in World Builder, however when I loaded up the map in the actual game the out-of-place cliffs were gone. The adjacent ocean tiles did not automatically become coast so be careful to double check for land-adjacent ocean if you add land anywhere.
• Adding river (first time I've tried this) did work with assigning the correct fresh water designation to the adjacent tile.

In the game save linked above, the tiles to the NE of player 1 including the two floodplains and all surrounding tiles were were previously coastal/ocean. I drew the river adjacent to the player 1 starting position.
Reply

I'm going to try to find a natural map that looks like a good starting point, then try to get this setup to work for the finetuning. If I can't figure it out, I'll post in the PBEM4 spoiler thread and see if Cornflakes or Trasson or someone else can get everything to work as expected. smile
Follow Sullla: Website | YouTube | Livestream | Twitter | Discord
Reply

Fantastic work and efforts here. This is really appreciated. Island Plate maps can be truly screwed. I am sure some editing might be needed.
Reply

The consensus in PBEM4 appears to be 10 city states. I have attached the Players.csv and PlayerAttributes.cvs files that will work for a game with 6 players and 10 city states.


Attached Files
.zip   6_Player_10_CS.zip (Size: 484 bytes / Downloads: 6)
Reply



Forum Jump: