Skip to content

Commit

Permalink
Merge pull request #105 from SethKitchen/master
Browse files Browse the repository at this point in the history
Add C# Support
  • Loading branch information
Sanjay-Ganeshan authored Jan 13, 2018
2 parents 77acb9f + 3cf1175 commit a029f58
Show file tree
Hide file tree
Showing 90 changed files with 4,948 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
8 changes: 8 additions & 0 deletions SandboxDockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ RUN apk add --update --no-cache \
rm -r /root/.cache
RUN pip3 install numpy

# Install mono
RUN apk add --no-cache --virtual=.build-dependencies wget ca-certificates tar xz && \
wget "https://www.archlinux.org/packages/extra/x86_64/mono/download/" -O "/tmp/mono.pkg.tar.xz" && \
tar -xJf "/tmp/mono.pkg.tar.xz" && \
cert-sync /etc/ssl/certs/ca-certificates.crt && \
apk del .build-dependencies && \
rm /tmp/*

# Install battlecode bindings
ADD . /battlecode

Expand Down
41 changes: 41 additions & 0 deletions VisualStudioCSSolution/AI.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BattleCodeCSharp;

namespace BattleCodeCSharp
{
class AI
{
public static void Main()
{
Console.WriteLine("Player c# bot starting");
Direction dir = Direction.North;
Direction opposite = bc.Direction_opposite(dir);
Console.WriteLine("Opposite direction of " + dir.ToString() + " is " + opposite.ToString());
Console.WriteLine("Connection to manager...");
GameController gc = new GameController();
Console.WriteLine("Connected!");
while (true)
{
uint round = gc.round();
Console.WriteLine("Round: " + round);
VecUnit units = gc.my_units();
uint len = units.len();
for (uint i = 0; i < len; i++)
{
Unit unit = units.index(i);
ushort id = unit.id();
if (gc.can_move(id, Direction.North) > 0 && gc.is_move_ready(id) > 0)
{
gc.move_robot(id, Direction.North);
}
}
gc.next_turn();
}

}
}
}
83 changes: 83 additions & 0 deletions VisualStudioCSSolution/AsteroidPattern.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
//------------------------------------------------------------------------------
// <auto-generated />
//
// This file was automatically generated by SWIG (http://www.swig.org).
// Version 3.0.12
//
// Do not make changes to this file unless you know what you are doing--modify
// the SWIG interface file instead.
//------------------------------------------------------------------------------


public class AsteroidPattern : global::System.IDisposable {
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
protected bool swigCMemOwn;

internal AsteroidPattern(global::System.IntPtr cPtr, bool cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}

internal static global::System.Runtime.InteropServices.HandleRef getCPtr(AsteroidPattern obj) {
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}

~AsteroidPattern() {
Dispose();
}

public virtual void Dispose() {
lock(this) {
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
if (swigCMemOwn) {
swigCMemOwn = false;
bcPINVOKE.delete_AsteroidPattern(swigCPtr);
}
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
global::System.GC.SuppressFinalize(this);
}
}

public AsteroidPattern(ushort seed, PlanetMap mars_map) : this(bcPINVOKE.new_AsteroidPattern(seed, PlanetMap.getCPtr(mars_map)), true) {
if (bcPINVOKE.SWIGPendingException.Pending) throw bcPINVOKE.SWIGPendingException.Retrieve();
}

public void validate() {
bcPINVOKE.AsteroidPattern_validate(swigCPtr);
if (bcPINVOKE.SWIGPendingException.Pending) throw bcPINVOKE.SWIGPendingException.Retrieve();
}

public byte has_asteroid(uint round) {
byte ret = bcPINVOKE.AsteroidPattern_has_asteroid(swigCPtr, round);
if (bcPINVOKE.SWIGPendingException.Pending) throw bcPINVOKE.SWIGPendingException.Retrieve();
return ret;
}

public AsteroidStrike asteroid(uint round) {
global::System.IntPtr cPtr = bcPINVOKE.AsteroidPattern_asteroid(swigCPtr, round);
AsteroidStrike ret = (cPtr == global::System.IntPtr.Zero) ? null : new AsteroidStrike(cPtr, false);
if (bcPINVOKE.SWIGPendingException.Pending) throw bcPINVOKE.SWIGPendingException.Retrieve();
return ret;
}

public AsteroidPattern clone() {
global::System.IntPtr cPtr = bcPINVOKE.AsteroidPattern_clone(swigCPtr);
AsteroidPattern ret = (cPtr == global::System.IntPtr.Zero) ? null : new AsteroidPattern(cPtr, false);
if (bcPINVOKE.SWIGPendingException.Pending) throw bcPINVOKE.SWIGPendingException.Retrieve();
return ret;
}

public string debug() {
string ret = bcPINVOKE.AsteroidPattern_debug(swigCPtr);
if (bcPINVOKE.SWIGPendingException.Pending) throw bcPINVOKE.SWIGPendingException.Retrieve();
return ret;
}

public string to_json() {
string ret = bcPINVOKE.AsteroidPattern_to_json(swigCPtr);
if (bcPINVOKE.SWIGPendingException.Pending) throw bcPINVOKE.SWIGPendingException.Retrieve();
return ret;
}

}
96 changes: 96 additions & 0 deletions VisualStudioCSSolution/AsteroidStrike.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
//------------------------------------------------------------------------------
// <auto-generated />
//
// This file was automatically generated by SWIG (http://www.swig.org).
// Version 3.0.12
//
// Do not make changes to this file unless you know what you are doing--modify
// the SWIG interface file instead.
//------------------------------------------------------------------------------


public class AsteroidStrike : global::System.IDisposable {
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
protected bool swigCMemOwn;

internal AsteroidStrike(global::System.IntPtr cPtr, bool cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}

internal static global::System.Runtime.InteropServices.HandleRef getCPtr(AsteroidStrike obj) {
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}

~AsteroidStrike() {
Dispose();
}

public virtual void Dispose() {
lock(this) {
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
if (swigCMemOwn) {
swigCMemOwn = false;
bcPINVOKE.delete_AsteroidStrike(swigCPtr);
}
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
global::System.GC.SuppressFinalize(this);
}
}

public AsteroidStrike(uint karbonite, MapLocation location) : this(bcPINVOKE.new_AsteroidStrike(karbonite, MapLocation.getCPtr(location)), true) {
if (bcPINVOKE.SWIGPendingException.Pending) throw bcPINVOKE.SWIGPendingException.Retrieve();
}

public AsteroidStrike clone() {
global::System.IntPtr cPtr = bcPINVOKE.AsteroidStrike_clone(swigCPtr);
AsteroidStrike ret = (cPtr == global::System.IntPtr.Zero) ? null : new AsteroidStrike(cPtr, false);
if (bcPINVOKE.SWIGPendingException.Pending) throw bcPINVOKE.SWIGPendingException.Retrieve();
return ret;
}

public string debug() {
string ret = bcPINVOKE.AsteroidStrike_debug(swigCPtr);
if (bcPINVOKE.SWIGPendingException.Pending) throw bcPINVOKE.SWIGPendingException.Retrieve();
return ret;
}

public string to_json() {
string ret = bcPINVOKE.AsteroidStrike_to_json(swigCPtr);
if (bcPINVOKE.SWIGPendingException.Pending) throw bcPINVOKE.SWIGPendingException.Retrieve();
return ret;
}

public byte eq(AsteroidStrike other) {
byte ret = bcPINVOKE.AsteroidStrike_eq(swigCPtr, AsteroidStrike.getCPtr(other));
if (bcPINVOKE.SWIGPendingException.Pending) throw bcPINVOKE.SWIGPendingException.Retrieve();
return ret;
}

public uint karbonite {
set {
bcPINVOKE.AsteroidStrike_karbonite_set(swigCPtr, value);
if (bcPINVOKE.SWIGPendingException.Pending) throw bcPINVOKE.SWIGPendingException.Retrieve();
}
get {
uint ret = bcPINVOKE.AsteroidStrike_karbonite_get(swigCPtr);
if (bcPINVOKE.SWIGPendingException.Pending) throw bcPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}

public MapLocation location {
set {
bcPINVOKE.AsteroidStrike_location_set(swigCPtr, MapLocation.getCPtr(value));
if (bcPINVOKE.SWIGPendingException.Pending) throw bcPINVOKE.SWIGPendingException.Retrieve();
}
get {
global::System.IntPtr cPtr = bcPINVOKE.AsteroidStrike_location_get(swigCPtr);
MapLocation ret = (cPtr == global::System.IntPtr.Zero) ? null : new MapLocation(cPtr, false);
if (bcPINVOKE.SWIGPendingException.Pending) throw bcPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}

}
52 changes: 52 additions & 0 deletions VisualStudioCSSolution/Delta.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//------------------------------------------------------------------------------
// <auto-generated />
//
// This file was automatically generated by SWIG (http://www.swig.org).
// Version 3.0.12
//
// Do not make changes to this file unless you know what you are doing--modify
// the SWIG interface file instead.
//------------------------------------------------------------------------------


public class Delta : global::System.IDisposable {
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
protected bool swigCMemOwn;

internal Delta(global::System.IntPtr cPtr, bool cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}

internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Delta obj) {
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}

~Delta() {
Dispose();
}

public virtual void Dispose() {
lock(this) {
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
if (swigCMemOwn) {
swigCMemOwn = false;
bcPINVOKE.delete_Delta(swigCPtr);
}
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
global::System.GC.SuppressFinalize(this);
}
}

public Delta() : this(bcPINVOKE.new_Delta(), true) {
if (bcPINVOKE.SWIGPendingException.Pending) throw bcPINVOKE.SWIGPendingException.Retrieve();
}

public string to_json() {
string ret = bcPINVOKE.Delta_to_json(swigCPtr);
if (bcPINVOKE.SWIGPendingException.Pending) throw bcPINVOKE.SWIGPendingException.Retrieve();
return ret;
}

}
22 changes: 22 additions & 0 deletions VisualStudioCSSolution/Direction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated />
//
// This file was automatically generated by SWIG (http://www.swig.org).
// Version 3.0.12
//
// Do not make changes to this file unless you know what you are doing--modify
// the SWIG interface file instead.
//------------------------------------------------------------------------------


public enum Direction {
North = 0,
Northeast = 1,
East = 2,
Southeast = 3,
South = 4,
Southwest = 5,
West = 6,
Northwest = 7,
Center = 8
}
Loading

0 comments on commit a029f58

Please sign in to comment.