Setting Up Your Robot
From Marvin's Arena
Contents |
Use the MyRobot template
You can use the Visual Studio template to create a new robot. The template contains the standard robot definition and the class library settings.
Create a new project and select MyRobot. You might need to adjust the output path and the reference to MarvinsArena.Robot.
Do it on your own
You can create the robot all by yourself.
- Create a new class library for C#, C++ or Visual Basic
- Copy one of the standard robots below to the new class file
- Set the output path in the properties
- Add a reference to "MarvinsArena.Robot.dll"
- Compile the robot
- Run the game
- Improve your robot
Name, author, description
To modify the displayed information in Marvin's Arena you need to modify the projects settings.
In C# open the file "Properties/AssemblyInfo.cs" or the properties dialog and set these values:
[assembly: AssemblyTitle("NAME")] [assembly: AssemblyDescription("DESCRIPTION")] [assembly: AssemblyCopyright("AUTHOR")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
In Visual Basic open the project properties -> Assembly information.
Standard Robot: C#
MyRobot.cs
using System; using MarvinsArena.Robot; namespace MyRobot { /// <summary> /// My robot /// </summary> public class MyRobot : BaseRobot, IRobot { // This is the place to define class variables /// <summary> /// Initialize local variables /// </summary> public void Initialize() { // TODO: Assign values to variables and event handler } /// <summary> /// Run the robot /// </summary> public void Run() { // TODO: Place your logic here } } }
Standard Robot: Visual Basic
MyRobot.vb
Imports MarvinsArena.Robot ''' <summary> ''' My robot ''' </summary> ''' <remarks></remarks> Public Class MyRobot Inherits BaseRobot Implements IRobot ' This is the place to define class variables ''' <summary> ''' Initialize local variables ''' </summary> ''' <remarks></remarks> Public Sub Initialize() Implements IRobot.Initialize ' TODO: Assign values to variables and event handler End Sub ''' <summary> ''' Run the robot ''' </summary> ''' <remarks></remarks> Public Sub Run() Implements IRobot.Run ' TODO: Place your logic here End Sub End Class
Standard Robot: C++
Creating a C++ robot requires you to modify some properties to get a
- Create a new class library
- Open properties
- Add a reference to MarvinsArena.Robot.dll
- Configuration -> Linker -> General -> Output File: (Marvin's Arena installation Directory)\Robots\$(ProjectName).dll
- Configuration -> Genral -> Common Language Runtime support -> Safe MSIL Common Language Runtime Support (/clr:safe)
- Remove [assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; from AssemblyInfo.cpp
- Delete references to app.ico, rc.ref, resource.h
MyRobotCPP.h
#pragma once using namespace System; using namespace MarvinsArena::Robot; namespace MyRobot { /// <summary> /// My robot /// </summary> public ref class MyRobotCPP : BaseRobot, IRobot { private: // This is the place to define class variables public: virtual void Initialize(); virtual void Run(); }; }
MyRobotCPP.cpp
#include "MyRobotCPP.h" namespace MyRobot { /// <summary> /// Initialize local variables /// </summary> void MyRobotCPP::Initialize() { // TODO: Assign values to variables and event handler } /// <summary> /// Run the robot /// </summary> void MyRobotCPP::Run() { // TODO: Place your logic here } }
Tutorials
Go on with the Tutorials.