As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/

Google AI Challenge

24

Posts

  • The AnonymousThe Anonymous Uh, uh, uhhhhhh... Uh, uh.Registered User regular
    edited September 2010
    Well, fuck it. Does someone care to explain why this shit always crashes for reasons no engine cares to explain?
    foreach (Planet p2 in notMyPlanets)
    {
        if (neutralPlanetsUnderAttack.TryGetValue(p2, out value) == true && neutralPlanetsUnderAttack[p2] < 0 && p.NumShips() > p2.NumShips() + p2.GrowthRate() - neutralPlanetsUnderAttack[p2])
        {
            ships = -neutralPlanetsUnderAttack[p2] + p2.NumShips() + p2.GrowthRate() + 1;
            orders.Add(new Order(p, p2, ships));
            p.RemoveShips(ships);
            neutralPlanetsUnderAttack[p2] = 1;
        }
        else if (enemyPlanetsUnderAttack.TryGetValue(p2, out value) == true && enemyPlanetsUnderAttack[p2] < 0 && p.NumShips() > p2.NumShips() - enemyPlanetsUnderAttack[p2])
        {
            ships = -enemyPlanetsUnderAttack[p2] + p2.NumShips() + p2.GrowthRate() + 1;
            orders.Add(new Order(p, p2, ships));
            p.RemoveShips(ships);
            enemyPlanetsUnderAttack[p2] = 1;
        }
        /*else if (p.NumShips() >= p2.NumShips() + p2.GrowthRate() + 1)
           {
               ships = p2.NumShips() + p2.GrowthRate() + 1;
               orders.Add(new Order(p, p2, ships));
               p.RemoveShips(ships);
               switch (p2.Owner())
               {
                   case 0: //neutral
                       neutralPlanetsUnderAttack.Add(p2, p2.NumShips() + 1);
                       break;
                   case 2: //enemy
                       enemyPlanetsUnderAttack.Add(p2, p2.NumShips() + 1);
                       break;
               }
        }*/
    }
    
    Specifically, it's the commented out code block that causes the crash.

    The Anonymous on
  • khainkhain Registered User regular
    edited September 2010
    I don't think this is causing the problem, but shouldn't the two lines in the switch statement use the variable ships instead of p2.NumShips() + 1 since that's the number of ships you're sending?

    khain on
  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    edited September 2010
    What do you mean by "crash?" Is this on the official server and your games just stop? You can always run locally against the examples/yourself/use the TCP server if it's an actual fault.

    But, by itself, I can't see that code crashing

    Phyphor on
  • AlegisAlegis Impeckable Registered User regular
    edited September 2010
    This looks like some cool beans. Stay in my safe java comfort zone, venture into using C++ or C# for once or have fun with Haskell?

    Decisions decisions.

    Alegis on
  • The AnonymousThe Anonymous Uh, uh, uhhhhhh... Uh, uh.Registered User regular
    edited September 2010
    Phyphor wrote: »
    What do you mean by "crash?" Is this on the official server and your games just stop? You can always run locally against the examples/yourself/use the TCP server if it's an actual fault.

    But, by itself, I can't see that code crashing
    I'm using the Galcon Bot Testing Arena (courtesy of the AI Challenge forums) to test my code. And the test match ends when my bot crashes. Which I don't get either.

    The Anonymous on
  • The AnonymousThe Anonymous Uh, uh, uhhhhhh... Uh, uh.Registered User regular
    edited September 2010
    Alegis wrote: »
    This looks like some cool beans. Stay in my safe java comfort zone, venture into using C++ or C# for once or have fun with Haskell?

    Decisions decisions.
    Make a starter package for lolcode. You know you want to.

    The Anonymous on
  • Lux782Lux782 Registered User regular
    edited September 2010
    I am writing up a better package for C#. The one given is ugly.

    I am also going to write up a game engine so I can debug if needed.

    Lux782 on
  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    edited September 2010
    They have a jave version included

    Phyphor on
  • seabassseabass Doctor MassachusettsRegistered User regular
    edited September 2010
    Alegis wrote: »
    This looks like some cool beans. Stay in my safe java comfort zone, venture into using C++ or C# for once or have fun with Haskell?

    Decisions decisions.

    You could try F# or OCaml? They're nice functional language, but impure (meaning you can do some awesome imperative things).

    seabass on
    Run you pigeons, it's Robert Frost!
  • Michael HMichael H Registered User regular
    edited September 2010
    This looks pretty awesome, I may have to put my pet projects on hold to get in on this..

    Michael H on
  • Michael HMichael H Registered User regular
    edited September 2010
    On Windows 7 it took me a couple of minutes to figure out why I couldn't run the visualizer tool... it helps to add the java bin directory to the system path variable.

    Also, Notepad++ -> TextFX -> Reindent C++ code is pretty nice.

    edit: So I got the visualizer to play against itself... it comes with java files for the bots. Is there a way to get the offline visualizer play my cpp bot? I don't understand.

    Michael H on
  • ecco the dolphinecco the dolphin Registered User regular
    edited September 2010
    Michael H wrote: »
    On Windows 7 it took me a couple of minutes to figure out why I couldn't run the visualizer tool... it helps to add the java bin directory to the system path variable.

    Also, Notepad++ -> TextFX -> Reindent C++ code is pretty nice.

    edit: So I got the visualizer to play against itself... it comes with java files for the bots. Is there a way to get the offline visualizer play my cpp bot? I don't understand.

    You should be able to replace the bolded parts with your compiled bots:

    e.g. the example from the tutorial:
    java -jar tools/PlayGame.jar maps/map43.txt 1000 1000 log.txt "[B]java -jar example_bots/RageBot.jar[/B]" "[B]java -jar example_bots/ProspectorBot.jar[/B]" | java -jar tools/ShowGame.jar
    

    becomes
    java -jar tools/PlayGame.jar maps/map43.txt 1000 1000 log.txt "YourAwesomeBot.exe" "AWorthyOpponent.exe" | java -jar tools/ShowGame.jar
    

    ecco the dolphin on
    Penny Arcade Developers at PADev.net.
  • Michael HMichael H Registered User regular
    edited September 2010
    Cool, thanks. I'll give that a try tonight.

    Michael H on
  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    edited September 2010
    Just make sure you use "java -jar tools/PlayGame.jar maps/map43.txt 1000 200 log.txt "YourAwesomeBot.exe" "AWorthyOpponent.exe" | java -jar tools/ShowGame.jar" instead, since games only last 200 turns right now


    edit: Also, from my experience, only dualbot and ragebot are worth playing against

    Phyphor on
  • jogernautjogernaut BisonopolisRegistered User regular
    edited September 2010
    I've just started playing around with the starter package and DualBot is kicking my ass.

    jogernaut on
    steam_sig.png
  • Lux782Lux782 Registered User regular
    edited October 2010
    So I have remade the C# package (it doesn't compile when I submit it due to an error on the server but they appear to be fixing it.)

    Comments would be nice. Use it if you like it.

    http://www.0x5eeded.com/PlanetWars.zip

    Lux782 on
  • CmdPromptCmdPrompt Registered User regular
    edited October 2010
    Lux782 wrote: »
    So I have remade the C# package (it doesn't compile when I submit it due to an error on the server but they appear to be fixing it.)

    Comments would be nice. Use it if you like it.

    http://www.0x5eeded.com/PlanetWars.zip
    You have two different versions of IBot.cs, one in the root folder and one in /Bot/.

    I'm guessing Engine.cs is incomplete? It doesn't have any code for planets fighting, nor does it seem to be called from anywhere in your code. If you do get that working, it'd be useful to pipe the output of the game into http://github.com/DanielVF/Planet-Wars-Canvas-Visualizer.

    I just pulled up the actual VS project and noticed those files weren't in the project. You might want to clean that up, otherwise looks fine, great work.

    CmdPrompt on
    GxewS.png
  • Lux782Lux782 Registered User regular
    edited October 2010
    CmdPrompt wrote: »
    Lux782 wrote: »
    So I have remade the C# package (it doesn't compile when I submit it due to an error on the server but they appear to be fixing it.)

    Comments would be nice. Use it if you like it.

    http://www.0x5eeded.com/PlanetWars.zip
    You have two different versions of IBot.cs, one in the root folder and one in /Bot/.

    I'm guessing Engine.cs is incomplete? It doesn't have any code for planets fighting, nor does it seem to be called from anywhere in your code. If you do get that working, it'd be useful to pipe the output of the game into http://github.com/DanielVF/Planet-Wars-Canvas-Visualizer.

    I just pulled up the actual VS project and noticed those files weren't in the project. You might want to clean that up, otherwise looks fine, great work.

    I have been further refactoring the gamestate stuff to make it easier to pick what fleets or planets you want. Linq makes it very easy to read and select. I am still working on the Engine.cs so that it works completely and allows for threading. This way I can run my bot on multiple threads and have multiple battles going on at the same time. Ofcourse I cant use threading for submissions but I can for my internal testing.

    Lux782 on
  • Lux782Lux782 Registered User regular
    edited October 2010
    So apparently, and I did not know this, they use mono to compile c# code. So there goes my .NET 4.0 work. Fucking hate Mono.

    Lux782 on
  • MonoxideMonoxide Registered User, ClubPA regular
    edited October 2010
    Lux782 wrote: »
    So apparently, and I did not know this, they use mono to compile c# code. So there goes my .NET 4.0 work. Fucking hate Mono.

    :cry:

    Monoxide on
  • HalibutHalibut Passion Fish Swimming in obscurity.Registered User regular
    edited October 2010
    Okay, the way they are compiling java projects is dumb. All of the source files have to be in the root directory, meaning there is no way to organize code. I had to manually go through about 25 files to fix package and import declarations.

    The good news is that my first bot with no offense made it up to about 800 yesterday.

    Halibut on
  • Lux782Lux782 Registered User regular
    edited October 2010
    Monoxide wrote: »
    Lux782 wrote: »
    So apparently, and I did not know this, they use mono to compile c# code. So there goes my .NET 4.0 work. Fucking hate Mono.

    :cry:

    Don't worry, I didn't mean all forms of Mono. Just the partially implemented open source kinds.

    Lux782 on
  • HalibutHalibut Passion Fish Swimming in obscurity.Registered User regular
    edited October 2010
    Made a slight change and moved up to around 600.

    Does anyone know if sharing each others bot (source or binary) is against the rules?

    I started dominating the starter kit bots, and it's difficult to determine what changes work well and which ones don't. Does anyone have a decent bot that they want to share so that we all have something more competitive to test against?

    I understand that for languages that decompile easily (or don't even compile) that most people probably don't want to give away any kind of competitive advantage, but maybe you've got an older version? Once I make a few improvements to my current bot, I don't mind sharing the current version.

    Halibut on
  • CmdPromptCmdPrompt Registered User regular
    edited October 2010
    If you want to test against better bots, use the TCP server: http://www.benzedrine.cx/planetwars/

    CmdPrompt on
    GxewS.png
  • Lux782Lux782 Registered User regular
    edited October 2010
    I cant get the TCP server to work. I reprogrammed my bot in Java and when I run from netbeans I have no issues but once I try to use the TCP server it says it cant find the class named MyBot. I have checked and there is a class named MyBot in the Jar file. It isn't in a package. WTF is wrong?

    Lux782 on
  • CmdPromptCmdPrompt Registered User regular
    edited October 2010
    If you're running from a jar file it should look like this:
    tcp.exe 72.44.46.68 995 username -p password java -jar MyBot.jar

    CmdPrompt on
    GxewS.png
  • HalibutHalibut Passion Fish Swimming in obscurity.Registered User regular
    edited October 2010
    The TCP server is awesome. I'm getting my ass kicked.

    I finally won though. Battle of the pacifists.

    Halibut on
  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    edited October 2010
    The TCP server is nice.

    Battle of the pacifists, take two. I'm not sure why neither of us colonized the 20 & 32, or the 7

    Phyphor on
  • HalibutHalibut Passion Fish Swimming in obscurity.Registered User regular
    edited October 2010
    Haha, that is a ridiculous match.

    My bot started getting way too complicated, and is currently hovering around 600th on the leaderboards.

    I'm going back to the drawing board to implement something like Kanban which should be a lot easier to maintain and tweak.

    Halibut on
  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    edited October 2010
    Well that map is interesting because if you overextend at all you instantly lose. Normally, when I'm close to an enemy I don't do colonization at all, unless I have enough numbers to do it safely, in that case it looks like we had similar logic going on. Although it would have been safe to send 25-30 ships out for colonization in that case.

    So far, I've been splitting all my functionality, I've got pieces of code that handle colonization, interception, reinforcement and attack, all separate, which has kept things pretty simple

    Phyphor on
  • Lux782Lux782 Registered User regular
    edited October 2010
    So after trying to code in Java and in C++ I have given up and will try mono again. I just like C# too much to program in anything else when given the choice.

    Lux782 on
  • HalibutHalibut Passion Fish Swimming in obscurity.Registered User regular
    edited October 2010
    Lux782 wrote: »
    So after trying to code in Java and in C++ I have given up and will try mono again. I just like C# too much to program in anything else when given the choice.

    I totally get that. If they had a Scala starter kit, I'd be dumping Java in a heartbeat.

    Halibut on
  • SirUltimosSirUltimos Don't talk, Rusty. Just paint. Registered User regular
    edited October 2010
    Alright, so I'm entering this. I only have the sample uploaded. I'm gonna try and tweak it over the next few days.

    SirUltimos on
  • HalibutHalibut Passion Fish Swimming in obscurity.Registered User regular
    edited October 2010
    Phyphor wrote: »
    Well that map is interesting because if you overextend at all you instantly lose. Normally, when I'm close to an enemy I don't do colonization at all, unless I have enough numbers to do it safely, in that case it looks like we had similar logic going on. Although it would have been safe to send 25-30 ships out for colonization in that case.

    So far, I've been splitting all my functionality, I've got pieces of code that handle colonization, interception, reinforcement and attack, all separate, which has kept things pretty simple

    Hmm... the close-starting-planets scenario is something I never considered before. So, I guess in that situation you would be better off sending out some ships to a far-away low-cost planet on your side of the map. Then you would slowly amass enough ships to colonize other planets and you would quickly have the upper hand.

    It seems like getting your initial planet colonization right is the key. Pretty much as soon as one player gets an advantage in ship count (or ship growth rate) it's all over.

    Also as far as separating attack, defend, etc... I was doing that. The problem is that I further separated it into smaller sub-contexts. For instance, I made a distinction between attacking neutral planets that the opponent is sending ships to, and attacking a neutral planet that was previously not under attack.

    My new strategy is going to simplify all of this though.

    Halibut on
  • CmdPromptCmdPrompt Registered User regular
    edited October 2010
    Halibut wrote: »
    Lux782 wrote: »
    So after trying to code in Java and in C++ I have given up and will try mono again. I just like C# too much to program in anything else when given the choice.

    I totally get that. If they had a Scala starter kit, I'd be dumping Java in a heartbeat.
    I'm sure you could get it supported if you posted in the forums.

    CmdPrompt on
    GxewS.png
  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    edited October 2010
    Halibut wrote: »
    Phyphor wrote: »
    Well that map is interesting because if you overextend at all you instantly lose. Normally, when I'm close to an enemy I don't do colonization at all, unless I have enough numbers to do it safely, in that case it looks like we had similar logic going on. Although it would have been safe to send 25-30 ships out for colonization in that case.

    So far, I've been splitting all my functionality, I've got pieces of code that handle colonization, interception, reinforcement and attack, all separate, which has kept things pretty simple

    Hmm... the close-starting-planets scenario is something I never considered before. So, I guess in that situation you would be better off sending out some ships to a far-away low-cost planet on your side of the map. Then you would slowly amass enough ships to colonize other planets and you would quickly have the upper hand.

    It seems like getting your initial planet colonization right is the key. Pretty much as soon as one player gets an advantage in ship count (or ship growth rate) it's all over.

    Also as far as separating attack, defend, etc... I was doing that. The problem is that I further separated it into smaller sub-contexts. For instance, I made a distinction between attacking neutral planets that the opponent is sending ships to, and attacking a neutral planet that was previously not under attack.

    My new strategy is going to simplify all of this though.

    Yeah, close starting positions lead to very interesting games.

    An extreme example would be this: p1 & p2 start off as usual, but only 6 distance apart. There is a growth 5 planet with 40 neutral ships on it 10 distance away from p2 (and 16 from p1). Obviously p1 won't try to colonize it, but p2 loses the game every time if he tries to colonize it.

    The hard maximum you can safely send out to colonize in that case is your ships - enemy ships + growth rate * distance



    I have similar separations in my code, but the actual chunk that does the AI is only about 200 lines. One thing I did was add a lot of functionality to the engine. You're going to want to be able to do a full simulation of the game state to arbitrary turns; it makes answering the question of "how many reinforcements do i need and when do they have to arrive" trivial - simulate until the planet flips.

    Phyphor on
  • jogernautjogernaut BisonopolisRegistered User regular
    edited October 2010
    Hahaha. I'm in the top 200 only because the first game of my new bot was a fluke win over a guy rated at ~200. I don't expect to stay here for long though.

    jogernaut on
    steam_sig.png
  • SirUltimosSirUltimos Don't talk, Rusty. Just paint. Registered User regular
    edited October 2010
    So now my bot won't compile and they're not even sending me an email explaining why. I think it's still a problem with Mono and not my code, which makes it even more frustrating. It a couple of submissions last night before it would even compile the starter package.

    SirUltimos on
  • EndEnd Registered User regular
    edited October 2010
    Isn't it possible to install mono along side .NET? I'd try that maybe.

    End on
    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpg
  • Lux782Lux782 Registered User regular
    edited October 2010
    SirUltimos wrote: »
    So now my bot won't compile and they're not even sending me an email explaining why. I think it's still a problem with Mono and not my code, which makes it even more frustrating. It a couple of submissions last night before it would even compile the starter package.

    This was my frustration. I ended up trying some C++ and then some Java and gave up on those and I am now using Mono to test compile. I use 1.2.6 and made a simple batch file I run every now and then to make sure things work. Just tried submitting a base project that does nothing (no bot logic) but does parse the game state. Going to hope that works.

    Edit: I have .NET along with mono. No problems thus far.

    Edit 2:
    Well there goes that idea.
    Oct 5th 16:49:07 	error while compiling submission 	C#
    

    Ain't that just fine and dandy... I had 0 issues compiling on my end with Mono. I even compiled with the SAME SETTINGS they used on my 1 sucessful submission which was this:
    gmcs -warn:0 -out:MyBot.exe Fleet.cs MyBot.cs Planet.cs PlanetWars.cs
    

    Ofcourse I added a few more files that need to be compiled but all of them are in the same directory. I am going to try removing namespaces.

    edit 3:
    removing namespaces did nothing.

    edit 4:
    removing useless using statements did nothing.

    edit 5:
    used the c# starter package, that failed as well.

    Lux782 on
Sign In or Register to comment.