<< Back to Warzone Classic Forum   Search

Posts 111 - 130 of 565   <<Prev   1  2  3  4  5  6  7  ...  17  ...  28  29  Next >>   
WarLight AI Challenge: 2014-04-04 17:37:20


ps 
Level 61
Report
finally managed to get my bot not crashing the damn simulator, hope to climb up a few spots during the weekend even though i still haven't implemented all the strategy i was thinking of, i'm still way too passive attacking the enemy. have to clean up a few more bugs. :) wish i had more time for this. :(
WarLight AI Challenge: 2014-04-04 20:47:30


125ch209 
Level 58
Report
@Norman: i learn Java so that i could do this challenge, i never really programmed before exept for some matlab simulations. I'm at version 1044(1052 actually :) ) because every time i change/add one line of code i upload the bot to see if it compile (i don't know how to debug on my computer). And usually for every line there is 2 or 3 errors :D, so 1 line of code represent 2 or 3 version (true story). Until version 960, my bot was crashing a lot and i didn't know why so i was uploading like crazy to try to debug it. But i agree, i'm spending way too much time on this, i was so frustrated that my bot was compiling succesfully yet crashing every 3-4 games without any obvious pattern that i got obsessed. Now that it don't crash anymore (i think it crashed 2 times in 50 games, i can live with that), i'll slowdown ;)
Also i need to thank Odin and Z-Dog, they helped me to get around Java

edit: and if you want a real nooby thread, check this one hahaha
http://stackoverflow.com/questions/22799661/for-loop-inside-else-if-statement

Edited 4/4/2014 22:24:26
WarLight AI Challenge: 2014-04-05 00:28:55

RvW 
Level 54
Report
I strongly suggest you look into figuring out how to do debugging on your own machine. That will allow you to "trace" through the code (let it execute one line at a time, then inspect the values of variables while it's paused, see which branches are actually taken, which loops get executed and how often, etc, etc, etc).
WarLight AI Challenge: 2014-04-05 06:25:09


Norman 
Level 59
Report
I strongly suggest you look into figuring out how to do debugging on your own machine. That will allow you to "trace" through the code (let it execute one line at a time, then inspect the values of variables while it's paused, see which branches are actually taken, which loops get executed and how often, etc, etc, etc).

Would help a lot. However, to make this possible you need your own game engine, that gets your code as input. I'm using the (slightly modified) game engine from github to compare different versions of my bot by letting an old version play a couple hundred games against the new version.

Since the game engine is written in Java it should be possible to modifiy it so that it takes Java code as input instead of runnable files. I took a look into it but since I always used the Java StarterBot and never bothered about the actual communication with the game engine I thought it wasn't worth the effort.
WarLight AI Challenge: 2014-04-05 11:25:25


125ch209 
Level 58
Report
inspecting the value of variables would be really awesome and very very helpful, but i can't figure out how to make the game engine work on my computer, if someone could help me do that, that would be great
WarLight AI Challenge: 2014-04-05 15:43:35

RvW 
Level 54
Report
It just gives you the board updates through standard input and expects you to write orders to standard output? In that case you could automate most of it by simple redirecting stdin from and stdout to files.

Make an input file which contains all the data necessary to initialise (such as board setup). Then run your program with a command line similar to the following (this is assuming you're using Window):

yourprogram.exe < input.txt > output.txt

Afterwards you can open output.txt in your favourite editor to check what moves were generated by your program.

Sure, it will only allow you to debug a single move (since no additional input is generated to tell you the results of your first move), but it should still be much more useful than only running it on the server, where you have no idea what's going on in your program.
WarLight AI Challenge: 2014-04-05 18:37:25


Norman 
Level 59
Report
OK, I found a solution on how to debug the bot locally. The disadvantage is that you don't have the graphical output of the server.


Here are the steps necessary to debug your bot locally using my solution. It shouldn't bother which language you wrote your bot in but if you used a language other than Java you have to adapt the argument for executing your bot.
Step 1: Download the game engine modified by me (game engine was released under the Apache license so me uploading modified stuff should be fine):
http://www.file-upload.net/download-8786734/WarlightBotEngine.zip.html
Step 2: Import my modified game engine as an eclipse project (I created an eclipse project out of the files).
Step 3: Export your Java bot to JAR files. Since two bots are playing together you need two JAR files.
Step 4: RunGame.java contains the two strings bot1Dir and bot2Dir. Currently the paths are pointing to my Desktop. Modify them so that they are pointing to your two JAR files.


How it works:
There are two classes with main methods, namely RunGame.java and NormanMain.java. Running the main method from RunGame let's your bots play a single game against each other. NormanMain contains a loop letting your bots play a couple hundred games against each other.
In RunGame I created the method named printDebugStuff. The only thing that method does is printing the stderr stream to the console after the game has finished. So if you write in your bot something like System.err.println("Hello World"); it will appear on the console. Here is some debug output that is comming from my bot:

=============== Round Nr: 5 ===============
Possible super regions last turn: North America, South America, Europe,
Opponent deployed visible: 7
Guessed opponent income: 7
Guessed opponent SuperRegions: South America,
Guessed opponent Regions: Peru, Egypt, Argentinia, Venezuela, Brazil,
Guessed game state: armiesAdvantage
Guessed opponent deployment: 7 armies to Egypt
WarLight AI Challenge: 2014-04-05 23:15:31


125ch209 
Level 58
Report
wow thank you very much. I tried to do what you said, but i think your bot is smarter than me, because i can't get it to work. When i modify the direction to the jar files, i get this:
java -jar C:/Users/Hugo/Desktop/gadz.jar
java -jar C:/Users/Hugo/Desktop/gadz2.jar
Error: Invalid or corrupt jarfile C:/Users/Hugo/Desktop/gadz2.jar

it is weird because the real path would be C:\Users\Hugo\Desktop\gadz.jar , but it doesn't compile when i use "\" instead of "/"
also when i export the bor to JAR file, it says "exported with compile warnings"...any thoughts?
WarLight AI Challenge: 2014-04-06 08:16:08


Norman 
Level 59
Report
'/' as separator should be fine. Works on Windows. Your compiler warnings point out probable problems in your code but should be irrelevant for the task of generating the JAR. Those yellow markers in eclipse represent the compiler warnings.

I guess your JAR file isn't executable. This is how I export my JARs using eclipse:
1. Export runnable JAR file.
2. In the launch configuration I specify my main file (= BotStarter).
WarLight AI Challenge: 2014-04-06 13:04:54


Hitchslap
Level 56
Report
...

Edited 4/6/2014 13:05:16
WarLight AI Challenge: 2014-04-06 15:41:05


125ch209 
Level 58
Report
Thanks it worked (i wasn't exporting as runnable JAR...)! but can't we see the output for each round like there is on theaigame website?
WarLight AI Challenge: 2014-04-06 15:49:18


ps 
Level 61
Report
to debug where my bot was crashing the sim i also had to get the conquest engine working (i call it the sim).

My code is online at:
https://github.com/psenough/warlight_ai_challenge

I made the /sim/main/RunGame.java saveGame() function output the error and message dump of bot1 to the command line

System.out.println("bot1 stdErr...");
System.out.println(bot1.getStderr());

System.out.println("bot1 dump...");
System.out.println(bot1.getDump());


And then when i call the sim i just pipe the result to a log file (you have to use a > on the command line), like so:

"C:\Program Files\java\jre8\bin\java.exe" main.RunGame 0 1 2 "..\..\temp\mybot.exe" "..\..\temp\mybot.exe" >"..\..\temp\log.txt"

Also made a few batch files to compile and run available on /scripts/

Don't know if it helps you or not but they're online on my repo if you want to check them.
WarLight AI Challenge: 2014-04-06 23:43:17


ps 
Level 61
Report
couple more bugs fixed, starting to climb through the ranks :) Hope to reach you guys within a couple of days. Won't have much time to implement anything new during this week though, but hopefully will have some time again during next week to debug a few more issues and implement some more advanced tactics :) Not that i ever got any mail back from dead piggy, that useless scoundrel, but i still have quite a few ideas of my own left to implement and hedja's tips to go over.
WarLight AI Challenge: 2014-04-06 23:45:24


ps 
Level 61
Report
Weird that it's mostly warlight folks on top positions, was expecting a little more from random computer science university students, but seems they all suck or didn't bother taking it seriously.
WarLight AI Challenge: 2014-04-07 00:15:29

RvW 
Level 54
Report
125ch209 wrote:
it says "exported with compile warnings"

That means "the code you wrote is technically valid, but are you sure it's correct, it looks rather suspicious". This could be if statements which are never executed ( "if 0 == 1" for instance; in a real case, it will probably not be so obvious the condition is always false (or always true!)), loops which never get executed ( "while 1 < 0" for instance; also in this case the example is intended to be obvious, in practice the concept will be the same, but the actual code more complex), functions which never get called, and a gazillion other things.

Note that not all warnings are in fact errors! Especially (utility) functions you used in a previous version, don't use in the current version, but want to keep around for future versions can trigger a warning. Likewise, some debugging techniques can lead to code which the compiler will give warnings over, but which you should not fix. However, in general it is a good idea to either fix warnings, or explain to yourself why a particular warning is okay.

(Apologies for the less-than-detailed examples; I'm not a Java programmer myself.)
WarLight AI Challenge: 2014-04-07 16:26:33

{rp} pedrito 
Level 48
Report
Just wondering...How many hours have you guys put into your bots on average?

Me probably some 50 or more, but it's my first time writing PHP so it's a bit of a learning experience. Enjoying every bit of it too.
WarLight AI Challenge: 2014-04-07 22:25:14


125ch209 
Level 58
Report
i've probably spend more than 50h too, and i spent at least 20hours reading about Java before i even started programming the bot. I found out yesterday that if i was writing my bot as a project, oracles would points out automatically my syntax errors...lol (so i found out about the compile warnings, wich were some imported packages that were never used)

I have a question for you guys, how do you print out the values of an arraylist?

for example, i have an arraylist of regions, and i want to print their id. i tried:

for (Region region : arrayListOfRegions){
System.out.println(region.getId());
}

but it doesn't work. any thought?

Edited 4/7/2014 22:28:12
WarLight AI Challenge: 2014-04-08 06:42:14


Norman 
Level 59
Report
@125ch209:
Change
System.out.println(region.getId());
to
System.err.println(region.getId());

System.out will break your code since then the result is written to the same stream to which your bot sends his moves.

@predito:
50 hours would mean about 3.5 hours per day for me. Don't think it took me that long.

During the first weak of coding I wrote some dirty code making my bot perform his moves.

Since then I didn't make my bot (visibly) act much smarter but I added quite complex functionality to make my bot understand what is going on on the board (what SuperRegions does opponent have?, is game in stalemate, won, lost, ,...?, where will opponent deploy?).

Next step is to rewrite the dirty code making my bot move so that he uses his model of what is going on on the board to perform some smart moves.
WarLight AI Challenge: 2014-04-08 11:10:58


ps 
Level 61
Report
i think i invested around 20 hours so far.
WarLight AI Challenge: 2014-04-08 16:25:20


125ch209 
Level 58
Report
Awesome, thanks Norman!
Posts 111 - 130 of 565   <<Prev   1  2  3  4  5  6  7  ...  17  ...  28  29  Next >>