Last active
August 29, 2015 14:04
-
-
Save DeinFreund/5596a18cd4ceea5763eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package zkai; | |
import com.springrts.ai.oo.clb.OOAICallback; | |
import com.springrts.ai.oo.clb.Resource; | |
import com.springrts.ai.oo.clb.Unit; | |
import java.util.ArrayList; | |
import java.util.List; | |
/** | |
* | |
* @author User | |
*/ | |
public class zkai extends com.springrts.ai.oo.AbstractOOAI { | |
int team = -1; | |
OOAICallback callback; | |
@Override | |
public int init(int teamId, OOAICallback callback) { | |
this.callback = callback; | |
int first = -1; | |
//callback.getGame().sendTextMessage("yolo, there are " + callback.getGame().getTeams() + " teams", team); | |
for (int i = 0; i < callback.getGame().getTeams(); i++) { | |
//callback.getGame().sendTextMessage("yolo, trying " + i, team); | |
if (callback.getGame().getTeamAllyTeam(i)==callback.getGame().getMyAllyTeam() && first < 0) { | |
first = i; | |
} | |
if (callback.getGame().getTeamAllyTeam(i)==callback.getGame().getMyAllyTeam() && i > callback.getGame().getMyTeam()) { | |
team = i; | |
break; | |
} | |
} | |
if (team < 0) { | |
team = first; | |
} | |
callback.getGame().sendTextMessage("yolo, sending stuff to " + team, team); | |
return 0; | |
} | |
@Override | |
public int unitGiven(Unit unit, int oldTeamId, int newTeamId) { | |
unitFinished(unit); | |
return 0; | |
} | |
@Override | |
public int unitFinished(Unit u) { | |
List<Unit> l = new ArrayList(); | |
l.add(u); | |
callback.getEconomy().sendUnits(l, team); | |
return 0; | |
} | |
@Override | |
public int update(int frame) { | |
if (frame % 5 == 0) { | |
Resource metal = callback.getResources().get(0); | |
Resource energy = callback.getResources().get(1); | |
callback.getEconomy().sendResource(metal, Math.min(callback.getEconomy().getCurrent(metal),callback.getGame().getTeamResourceStorage(team, 0) - callback.getGame().getTeamResourceCurrent(team, 0)), team); | |
callback.getEconomy().sendResource(energy,Math.min( callback.getEconomy().getCurrent(energy),callback.getGame().getTeamResourceStorage(team, 1) - callback.getGame().getTeamResourceCurrent(team, 1)), team); | |
} | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment