Created
February 11, 2012 20:50
-
-
Save michelsalib/1804150 to your computer and use it in GitHub Desktop.
Green Planet client basic example
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
package greenplanettestclient; | |
import greenplanetclient.*; | |
import java.io.IOException; | |
import java.util.ArrayList; | |
import javax.xml.bind.JAXBException; | |
/** | |
* @author michel | |
*/ | |
public class GreenPlanetTestClient { | |
/** | |
* @param args the command line arguments | |
*/ | |
public static void main(String[] args) throws IOException, JAXBException, InterruptedException { | |
// create client | |
ClientInterface client = new OfflineClient("Michel"); // offline client | |
//ClientInterface client = new Client(3, "Michel"); // online client | |
try { | |
// wait for game to start | |
Game game = client.waitForStart(); | |
// while game is running | |
while (game.getState() == GameStateEnum.RUNNING) { | |
// display some stufs | |
System.out.println("Play turn #" + game.getTurn().getNumber()); | |
// compute order (AI job) | |
Order order = new Order(10, new ArrayList<String>()); | |
// give order, wait for next turn | |
game = client.giveOrder(order); | |
} | |
} catch (ClientException ex) { | |
System.out.println(ex); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment