<< Back to Programming Forum   Search

Posts 1 - 5 of 5   
Some one able to help me Warlight AI Challange 2: 2017-05-18 16:19:46


dabo1
Level 57
Report
I modified the code of the C# Starter bot which I found at http://theaigames.com/competitions/warlight-ai-challenge-2/getting-started.
My change was in the attack system. I modiefied it to
var attackTransferMoves = new List<AttackTransferMove>();
var myName = state.MyName;
var armies = 1;
foreach (var superbonus in state.FullMap.SuperRegions){
	var notownedregions = new List<Region> ();
	var ownedregions = new List<Region> ();
	foreach (var subregion in superbonus.SubRegions) {
		if (subregion.OwnedByPlayer(myName)) {
			ownedregions.Add(subregion);
		} else {
			notownedregions.Add(subregion);
		}
	}
	foreach (var fromregion in ownedregions) {
		var possibleToRegions = new List<Region>();
		possibleToRegions.AddRange(fromregion.Neighbors);
		var match = false;
		foreach (var toregion in ownedregions) {
			var matchtwo = false;
			foreach (var notownedregion in notownedregions) {
				if (toregion.Id == notownedregion.Id) {
					matchtwo = true;
				}
			}
			if (matchtwo) {
				match = true;
				attackTransferMoves.Add(new AttackTransferMove(myName, fromregion, toregion, armies));
			}
		}
		if (match == false) {
			foreach (var toregion in ownedregions) {
				attackTransferMoves.Add(new AttackTransferMove(myName, fromregion, toregion, armies));
			}
		}
	}
}

But
if (subregion.OwnedByPlayer(myName)) {
	ownedregions.Add(subregion);
}
is never true. So I hope someone can tell me where my mistake is.
Some one able to help me Warlight AI Challange 2: 2017-05-18 16:43:56


ps 
Level 61
Report
Hard to tell without test environment and full code.

Are you testing it on a local server or the AI games match server? you should really debug it locally before uploading.

I think those calls only get called after the picking stage is done, so maybe you're debugging on first turn and have not realized how the system works?

If the whole system is working, you should be able to debug the state variable and it lists the full map and who controls each region, so first check if that is correct with what you expect from the server.

Is a new AI games challenge coming up? Considering the Warlight AI Challenge from AI Games has ended quite a while ago i would think you'd be more interested in doing AI's for warlight itself, now that it's open source and everything. They are somewhat different from one another.
Some one able to help me Warlight AI Challange 2: 2017-05-18 16:53:57


dabo1
Level 57
Report
I tested it on the ai games server. There is no error message coming so debugging won't help. And yes the challange has ended, but it is still possible to upload new ais. The full code is at https://github.com/dabo123148/Warboti . My only problem is, that the ownerplayer of no territory is my bot (if (subregion.OwnedByPlayer(myName)) {)
Some one able to help me Warlight AI Challange 2: 2017-05-18 18:06:47


Norman 
Level 58
Report
Hello,

there is the engine: https://github.com/theaigames/warlight2-engine

If you want to debug using the game site, then you can write debug output as error message. Something like Console.Error.WriteLine(SubRegion.GetPlayerName());

If you can't find a trivial error, then it might be that you are operating on the wrong data structures or you are pointing to a field from a previous turn. For example I remember that the Java starterbot had two maps, namely "VisibleMap" and "FullMap". FullMap only contained the initial map for the start of the game while visible map only the currently visible map without the fogged territories.

Edited 5/18/2017 18:07:24
Some one able to help me Warlight AI Challange 2: 2017-05-18 18:10:59


dabo1
Level 57
Report
Oh I am so stuppid... Fullmap is the startmap, but I need the currentmap thanks.

Edited 5/18/2017 18:11:27
Posts 1 - 5 of 5