SimArena is a powerful toolkit for creating, configuring, and running simulations with multiple agents in various scenarios. It provides a robust foundation for AI research and development, with support for custom objectives, brains, weapons, and maps.
This guide covers how to create custom maps and map templates for SimArena.
Map templates are the recommended way to create reusable map configurations. They’re stored as JSON files in the templates/maps/
directory.
{
"TemplateId": "my_custom_map",
"Name": "My Custom Map",
"Description": "A custom map for specific scenarios",
"Version": "1.0",
"Tags": ["custom", "scenario"],
"MapConfiguration": {
// Map configuration goes here
}
}
Perfect for open combat scenarios:
{
"MapConfiguration":
{
"Type": "Simple",
"Width": 40,
"Height": 40
}
}
For dynamic, room-based combat:
{
"MapConfiguration":
{
"Type": "ProcGen",
"StrategyType": "RandomRooms",
"Width": 50,
"Height": 30,
"MaxRooms": 20,
"RoomMaxWidth": 6,
"RoomMaxHeight": 4
}
}
The available strategy types are:
More can be implemented by implementing the IMapCreationStrategy<Map>
interface and registering it with the
polymorphic JSON serialization system.
For completely custom layouts:
{
"MapConfiguration":
{
"Type": "File",
"FilePath": "maps/my_custom_map.txt",
"Width": 25,
"Height": 25
}
}
File-based maps use text files to define custom layouts. They use structured directives in plain text
files to define walls, doors, spacing, and offsets. These maps will then be parsed and translated into playable
maps through an instance of FileBasedMapCreationStrategy<TMap>
.
Each line in the map file must begin with a #
followed by a keyword. Empty lines and comments (//
) are ignored.
#width [int]
#height [int]
#wall ([x1],[y1])
#wall ([x1],[y1]) ([x2],[y2])
#wallrect ([x1],[y1]) ([x2],[y2])
#door ([x],[y])
#window ([x],[y])
#wallrect (0,0) (35,4)
#door (35,3)
#wallrect (34,0) (39,6)
#door (34,3)
#width
and #height
are omitted, they are inferred based on the furthest #wallrect
, #wall
, or #door
coordinates.#wallrect
draws the four outer edges of a rectangle.Reference your custom map template:
{
"Name": "Custom Battle",
"MapTemplate": {
"TemplatePath": "my_custom_map"
},
"RealtimeMode": false,
"Objective": {
"Type": "DeathmatchObjective",
"ObjectiveType": "TeamDeathmatch",
"TeamCount": 2,
"KillsToWin": 5
}
}
Customize template properties:
{
"Name": "Large Custom Battle",
"MapTemplate": {
"TemplatePath": "office_building",
"Overrides": {
"Width": 80,
"Height": 60,
"MaxRooms": 40,
"RoomMaxWidth": 10,
"RoomMaxHeight": 8
}
}
}
For RandomRooms maps:
Use tags to select appropriate maps:
var urbanMaps = templateManager.GetMapTemplatesByTag("urban");
var selectedMap = urbanMaps.First();
Modify maps at runtime:
var map = mapConfiguration.CreateMap();
// Add dynamic obstacles
map.SetCellProperties(x, y, false, false); // Make cell impassable
Implement IMapCreationStrategy<Map>
for custom generation algorithms:
public class CustomMapStrategy : IMapCreationStrategy<Map>
{
public Map CreateMap()
{
// Custom map generation logic
return new Map(width, height);
}
}