• Post Reply Bookmark Topic Watch Topic
  • New Topic

I don't know how to describe this with only a few words  RSS feed

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Robocode, which is a robotics battle simulator, the user can program a robot using java, and then use it in a battle. The robot must extends Robot class, and the user can select to use it for a battle in the robocode program.

How do they do this? because in order to use the robot, the code would have to reference it in it's own code. But the Robocode program is already compiled, it can't change the source code of itself... and yet if you write a class that extends robot you can use it in the program as if the Robocode program has a reference to it in itself... I don't know how to describe this in one or two words... but hopefully you know what I mean.

I want to do something similar with my program, where the user can program something and use it in my program.
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's basically a plugin API.
Conveniently, a JavaRanch journal entry that covers this topic was posted a few years ago: http://www.javaranch.com/journal/200607/Plugins.html
 
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I loved Robocode :)
 
Daniel Gen Li
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much. I'll look through it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!