在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:matthid/s2client-dotnet开源软件地址:https://github.com/matthid/s2client-dotnet开源编程语言:F# 97.0%开源软件介绍:StarCraft II Client API for .NETA .NET (C#, F#, VB.Net) port of https://github.com/Blizzard/s2client-api into .Net "Standard" 2.0.
NuGetWhyTBD. Probably to make something awesome in a sane language ;) UsageCurrent a bot is a simple function The following example will spawn a instance of Starcraft 2 (
So for example to play against a hard bot on static void Main(string[] args)
{
var userSettings = Sc2SettingsFile.settingsFromUserDir();
var instanceSettings = Instance.StartSettings.OfUserSettings(userSettings);
Func<Instance.Sc2Instance> createInstance =
() => Runner.run(Instance.start(instanceSettings));
var participants = new Sc2Game.Participant[] {
Sc2Game.Participant.CreateParticipant(
createInstance(),
Race.Terran,
(state => (IEnumerable<SC2APIProtocol.Action>)new SC2APIProtocol.Action[] {})),
Sc2Game.Participant.CreateComputer(Race.Terran, Difficulty.Hard)
};
var gameSettings =
Sc2Game.GameSettings.OfUserSettings(userSettings)
.WithMap(@"Ladder2017Season1\AbyssalReefLE.SC2Map")
.WithRealtime(true);
// Runs the game to the end with the given bots / map and configuration
Runner.run(Sc2Game.runGame(gameSettings, participants));
} In F# it looks a bit nicer ;) let userSettings = Sc2SettingsFile.settingsFromUserDir()
let instanceSettings = Instance.StartSettings.OfUserSettings userSettings
let instance() = Instance.start(instanceSettings) |> Async.RunSynchronously
let participants =
[ Sc2Game.Participant(instance(), Race.Terran, (fun _ -> []))
Sc2Game.Computer(Race.Terran, Difficulty.Hard) ]
let settings =
{ Sc2Game.GameSettings.OfUserSettings userSettings with
Map = @"Ladder2017Season1\AbyssalReefLE.SC2Map"
Realtime = true }
Sc2Game.runGame settings participants |> Async.RunSynchronously
The empty bot function will ensure you can play manually. Obviously you want to implement that with something useful. Further documentation (regarding the datastructures and custom StarCraft II Builds)
If you use the library don't hesitate to let me know ;) BuildingRequirements:
Now the
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论