Developing a Robocode type game with .Net, for a School Assignment

走远了吗. 提交于 2019-12-17 09:53:31

问题


I am currently in my final year at school, studying for a Higher National Diploma in Computer Studies, and basically in this final semester, we need to develop a Software Project, that basically incorporates a whole system.

Now, what I'm thinking of doing is something along the lines of Robocode, but instead of Java, I will be doing this with the .Net Framework.


What is Robocode ?

For those of you don't know what Robocode is, it's basically a sort of programming game in where people develop their own robots using methods from the class interfaces and downloadable classes that exist, and then they fight each other in an autonomous battle in an arena...like such:

alt text http://articles.techrepublic.com.com/i/tr/cms/contentPics/robocode.gif


So basically, as I said, I want to recreate this sort of scenario using the .Net Framework..and I am posting this question here on StackOverflow in hope that more experienced developers will be able to guide me in the right direction for this project.

What I have in mind up till now is basically to create:

  • An Offline application that will serve as the battle arena and the user-interface to create new battles with existing robots and such.
  • An Online interface that players will able to use to register new robots, view past tournament scores etc...
  • And obviously the Class Interfaces that players will need to use to create their robots.

Animation and Graphics (for the actual battles)

Now, of course there will be some sort of animation and movement when the battle occurs, and I haven't decided what yet to use as a medium for this.

The options I currently have in mind are:

  • Developing, as I said in the first above bullet points, an offline application that will serve as a battle grounds, and all animations will be done using mainly C# code
  • Or develop a Silverlight Application that will handle the animations (thus, changing the scenario from an offline applcation to now an online one
  • Or, maybe the least feasable of them, create the battle animations using JavaScript, with something like the Canvas

What do you think could be more suitable for this particular scenario ?


Developing Classes and Interfaces

For the players to develop the robots, I will provide certain Class Interfaces that they will be able to use like in Robocode.

Examples of such events and methods may include:

public void run () {}
public void onScannedRobot(ScannedRobotEvent e) {}

walk(/* ammount in pixels or w/e to walk to */);
turnRight(/* value in degrees for an angular turn */);
//etc...

Here is a snippet from code in Robocode (Java) :

public class MyFirstRobot extends Robot {
    public void run() {
        while (true) {
             ahead(100);
             turnGunRight(360);
             back(100);
             turnGunRight(360);
         }
    }
}

For then to actually make the battles happen, I am thinking of using Reflection to actually read what methods the user is actually making use of and implementing them to run and be invoked at particular moments of the battle and such.


Now, what I kindly and humbly ask of you experienced developers, is to guide me a bit through this project of mine and advise me on what needs to be done...for starters, is this project feasible at all ? And if it actually is, from where do I need to actually start with my project?


As regards technologies and software I intend to be using are :

  • .NET Framework 3.5, with C# 3.0
  • LINQ (Language Integrated Query)
  • SQL Server 2008
  • Microsoft Visual Studio 2008
  • jQuery Framework
  • Possibly Silverlight

I thank you all, even for managing to read up to this point in my question and I will need and appreciate greatly all the help I can get to finish this project.

Thank you for your time and effort.


Btw, up till now, apart from Robocode, I have found these games that are similar to what I am trying to create:

  • NRobot
  • Virii (thanks Marc)

回答1:


When I began working with WPF (which is much the same as Silverlight) I ended up spending a lot of time figuring out how to do things. It is a very different way of making a GUI than what else I've tried and there seems to be a billion different ways to do things. My point is, that if you have no experience with WPF/Silverlight I suspect it is going to take a lot of time for you to wrap your mind around. I guess it depends on what you already know.

Apart from than, I wholeheartedly support ChrisW's suggstion about incremental development. I'll give you an idea of how you can approach the design of the game. Start out with a very simple API for the bots, say two functions with no events, input or knowledge of the world. Just start by getting the bots to move. The point is to get a fully functioning program with the simple functionality, including all parts from loading the client code to showing the resulting 'battle'.

Each bot should implement an interface with a single method run() and be in their own dll file. When the battle starts, each dll with the interface implemented is loaded (using reflection) from a certain location and instantiated. Then start a battle with a loop until 1 minute has passed (or whatever, just to see that something is going on):

while (time is not up)
   generate random sequence for bots
   call run() on each bot
   draw(world)

When the time is up, the battle is over. Now you have a skeleton application which you can begin to flesh out and which will let you have a working program, even if you won't have time to make all the functionality you would like. In the run method, the bots can call the couple of move actions you have defined in the API. Calling these will change the state of the world - probably just a grid of tiles, and the location of each bot.

The next step could be to add a view of the world to the bots' run method, changing the loop to this:

while (time is not up)
   generate random sequence for bots
   call run(WorldView) on each bot
   draw(world)

Let's say that the bots can still only perform a couple of move actions in their run method. Now they have the option of getting a view of the world (or their part of it) which allows them to move towards or away from enemies and avoid walls.

In the next iteration you could then create a single API function to shoot you cannon (or whatever is appropriate your game). Implement how this changes the world state, how the bullets are tracked and how the animation is represented, etc. The loop could look something like this:

while (time is not up and there are more than 1 bot alive)
   advance projectiles
   calculate projectile-bot collisions and damage
   generate random sequence for bots
   call run(WorldView) on each bot
   draw(world)

I hope this gives you an idea of how you can iteratively flesh out the program, all the while having a working program that reflects all the areas of the game. I don't have much experience with implementing games, so you should look at my advice with a critical eye but this is how I would attack the problem.




回答2:


is this project feasible at all ?

It sounds big. I don't know how much time you have. Here's a rule of thumb:

  • When the drop-dead due-date happens, if 90% of the system delivering 90% of the functionality is 100% complete, then you might say that the project is at least 90% successful.

  • OTOH if 100% of the software delivering 100% of the functionality is only 90% finished (i.e., is not finished) then nothing is finished and the project is a failure.

A key to success, then, is "incremental development" and "continual delivery". Your project specification says:

We need to develop a Software Project, that basically incorporates a whole system.

To do this, I suggest:

  1. Create (i.e., design, develop, and test) a small whole system
  2. Repeat { backup or version control what you have; add a new, whole little bit to the system, and test it until it's satisfactory } until (you run out of time).



回答3:


It's very feasible.

I suggest starting with the back-end system and objects that respond to "compiled" robocode. What form that "compiled" code takes is all you.

Then, create the interpreter for the robocode. Or, it sounds like you might just be able to make the .NET classes. That's a freebie on the hardest part.

Finally, create any UI you might require...all set.

You might want to have the robots compile as .dlls ...nonetheless, you just have to create the common interface for them, and functionality.




回答4:


feasibility totally depends on your team's ability, familiarity with the framework, etc. I've seen people who could knock something like this out in a week, and others who couldn't do it to save their lives.

The reflection approach you mention sounds like the wrong track, unless I'm misunderstanding you. Your 'Robot' base class should allow developers to override one or more methods, from which they can call functions like 'Shoot', 'Move', etc..

One other app that was similar to this is Terrarium. Developers could code animals and pit them against others in a distributed environment. It was a .NET 1.1 demo app, and is a bit dated, but some of the principals may still be helpful to you. This guy has taken on rewriting it: http://weblogs.asp.net/bsimser/archive/2008/07/16/reintroducing-terrarium-now-with-2-0-goodness.aspx




回答5:


So, kinda like virii, then?




回答6:


Real Robocode will get plugin for running .NET robots soon. It took me 2 years to achieve that. First year spent on refactoring original Robocode. Second one on Java to .NET bridge. And there are the alpha bits. This approach has benefit that you could fight with best Java robots. There is big treasure in the robots actually.



来源:https://stackoverflow.com/questions/505040/developing-a-robocode-type-game-with-net-for-a-school-assignment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!