Jump to content
  • Advertisement
Sign in to follow this  
TheNess

Web game to code AI and fight against the house AI

This topic is 798 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So this one needs some background...

 

Basically I needed a way to execute untrusted (user-generated) code on Node.js / browsers, and I ended up writing a Python-like language on top of JavaScript, designed to execute unsafe code in a safe way (http://adderscript.com/).

 

The game I'm posting here is a demonstration game for the language; its a web game (no canvas nor WebGL, only HTML elements :P) where you need to write an AI to defeat the house AI. You can play it here:

 

http://adderscript.com/examples/BotWars/BotWars.html

 

Feedback will be appreciated

Cheers!  :D

 

 

Share this post


Link to post
Share on other sites
Advertisement

Cool! Is there a way to access enemy states ?

And how to create global variables to reuse the next steps ?

Edited by skarab

Share this post


Link to post
Share on other sites

Cool! Is there a way to access enemy states ?

And how to create global variables to reuse the next steps ?

 

Thanks! :)

 

To access enemy states you can use the 'Enemy' module, it has the same API as 'Self' (more details in API, click on the "Show API" button. you can also see it used by the enemy code in "Show enemy code").

 

As for a way to store global vars, by default all vars are global and remain between executions. you can do something like this:

 

# for first-time execution - create the var
if not exist("global_var"): global_var = 0

# every round the var will increase by 1 and we'll print it
global_var += 1
print(global_var)

The code above will print incrementing numbers every round.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!