Wednesday, March 3, 2010
Thursday, February 25, 2010
Robocode with C++/CLI
Recently I spotted question if it's possible to create robot in C++. Here is the answer. Ok, I know, it's not like real C++ with pointers etc, this is managed version of C++, which is safe enough to be runnable in Robocode.
- Download VS 2008 Express C++
- Create new CLR-> Class Library (DLL) project
- Go to project properties, Common Properties, Add New Reference, and add robocode.dll from lib folder of your robocode installation.
- Go to project properties, Configuration properties, General, Common Language Runtime support and set it to Safe MSIL (/clrsafe)
- Go to AssemblyInfo.cpp and delete line with [assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];
- Go to [myCppRobot].h and insert code below
- Compile it, drop the DLL into Robocode and enjoy!
#pragma once using namespace System; using namespace Robocode; namespace myCppR { public ref class MyCplusplusRobot : Robot { public: virtual void Run() override { while(true) { Ahead(100); TurnLeft(100); } } }; }
Monday, February 15, 2010
Robocode .NET - 1.7.2 public beta
This release of Robocode is big achievement for me.
Saturday, February 13, 2010
jni4net version 0.7 released
support for delegates and events
.NET events and delegates are supported by proxygen and runtime. From Java side they could be invoked with Invoke() method which has proper signature. Delegates could be also implemented on Java side, by usual anonymous class and passed back to CLR. So Java could subscribe to .NET events.this.button1.addClick(new system.EventHandler(){ public void Invoke(system.Object sender, system.EventArgs e){ button1.setText("Clicked"); } });Full code is in winforms sample, which is part of binaries.
Other changes
- solved problem with spaces in path to dll/jar
- assembly loading now uses java.io.File or assembly name (breaking change)
- static class is no longer found by name, attribute parameter added (breaking change)
Sunday, January 24, 2010
jni4net version 0.6 released
- Implemented out and ref parameter from C# DateTime.TryParse has second parameter 'out'. This is how to use it from Java:
Out<DateTime> dt=new Out<DateTime>(); if (DateTime.TryParse("2009-08-28",dt)){ System.out.println(dt.getValue()); }
Saturday, January 9, 2010
Robocode .NET - alpha bits
I'm proud to present working version of .NET Robocode for community testing.
It took me almost exactly 2 years.
Enjoy!
Prerequisites
- make sure you have .NET framework >= 2.0 installed on your windows box
- backup your robocode home
Install and start
- Download robocode-1.7.3.0-setup.jar and robocode.dotnet-1.7.3.0-setup.jar
- run robocode-1.7.3.0-setup.jar
- run robocode.dotnet-1.7.3.0-setup.jar
- start robocode.bat
- start new battle with samplecs.MyCsTeam and samplecs.PaintingRobot
- open samplecs.PaintingRobot dialog and enable painting
Optional
- start your Visual Studio
- open robots/samplescs/samplescs.csproj
- or create project new and reference robocode.dll from libs\ (Robot API for .NET)
- and code your own .NET robot :-D
Known gaps
- Robot API xml documentation is not yet ready
- IGraphics/onPaint have just simple operations implemented
- Robot could create unlimited threads, (but could not cause any harm to your computer)
- jni4net 0.6 was not released public yet
- Few unit tests still fail
These binaries above are 1.7.3, but that was just working number. We will merge it to trunk and release as 1.7.2 probably. Sources are in trunk already.
Enjoy!
Friday, December 4, 2009
jni4net version 0.5 released
Second public release of jni4net is out. New features are:
- Simplified proxygen to wrap all classes in DLL or JAR file from command-line, without time spent on config file. It as well provides very simplistic build.cmd. I will write another article about proxygen soon, till then look at new samples.
- Ported java.nio.ByteBuffer to .NET, so you could share same byte array in both VMs. You are able to use BinaryWriter in .NET as well, but same byte order and interface is more convenient.
- There are new Adapt.Enumeration and Adapt.Disposable methods on CLR side. They are convenience adapters from corresponding Java interfaces.
foreach (var prop in Adapt.Enumeration(javaSystemProperties.keys())) { cnt++; }
using (var fis = Adapt.Disposable(new FileInputStream(classPath))) { using (var zis = Adapt.Disposable(new ZipInputStream(fis.Real))) { ZipEntry entry = zis.Real.getNextEntry(); while (entry!=null) { string name = entry.getName(); entry = zis.Real.getNextEntry(); } } }
- Improved proxygen code generator
- Few minor bugfixes
- New troubleshooter page
Labels:
jni4net
Subscribe to:
Posts (Atom)