Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions Bot_SD/Ants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using System.IO;
using System.Collections.Generic;
using static Ants.Logger;
using System.Diagnostics;
using System.Threading;

namespace Ants {

Expand Down Expand Up @@ -32,12 +30,6 @@ public void PlayGame(Bot bot) {

Log.Debug("Starting Up");

//while (!Debugger.IsAttached)
//{
// Thread.Sleep(100);
//}


List<string> input = new List<string>();

try {
Expand All @@ -61,14 +53,12 @@ public void PlayGame(Bot bot) {
}
}
} catch (Exception e) {
#if DEBUG
Log.Fatal(e, "Fatal error ");
#if DEBUG
FileStream fs = new FileStream("debug.log", System.IO.FileMode.Create, System.IO.FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine(e);
sw.Close();
fs.Close();

#endif
}

Expand Down
9 changes: 2 additions & 7 deletions Bot_SD/Bot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@ public abstract class Bot {

public abstract void DoTurn(GameState state);

public static void IssueOrder(GameState state, Location loc, Direction direction, string action) {
public static void IssueOrder(GameState state, Location loc, Direction direction) {
System.Console.Out.WriteLine("o {0} {1} {2}", loc.Row, loc.Col, direction.ToChar());

Logger.Log.Trace("Ant Moved : {0} => {1} ({2}) ", loc, direction,action);

if (state.OccupiedNextRound.At(loc) != true)
Logger.Log.Error("Source Location was not occupied (ant moved)... ANT {0} {1}", loc, new System.Diagnostics.StackTrace(1, true));

if (state.OccupiedNextRound.At(state.GetDestination(loc, direction)) == true)
Logger.Log.Error( "Dest Location is occupied... ANT {0} {1}", loc, new System.Diagnostics.StackTrace(1,true));
Logger.Log.Error("Location was not occupied...");

state.OccupiedNextRound.Set(loc, false);
state.OccupiedNextRound.Set(state.GetDestination(loc, direction), true);
Expand Down
12 changes: 5 additions & 7 deletions Bot_SD/Logging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Ants
{
public static class Logger
{
public static string filePath = string.Format("{0}{1}text-{2:yyyy-MM-dd_HH-mm-ss}.txt",
public static string filePath = string.Format("{0}{1}text-{2:yyyy-MM-dd_hh-mm-ss-tt}.txt",
AppDomain.CurrentDomain.BaseDirectory,
Path.DirectorySeparatorChar,
DateTime.Now);
Expand All @@ -18,14 +18,12 @@ public static class Logger

static Logger()
{
//var config = new NLog.Config.LoggingConfiguration();
//var logfile = new NLog.Targets.FileTarget("logfile") { FileName = filePath };
//var layout = NLog.Layouts.Layout.FromString("${longdate} ${message} ${exception:format=ToString,StackTrace}");
var config = new NLog.Config.LoggingConfiguration();
var logfile = new NLog.Targets.FileTarget("logfile") { FileName = filePath };
//var logconsole = new NLog.Targets.ConsoleTarget("logconsole");
//config.AddRule(LogLevel.Debug, LogLevel.Fatal, logconsole);
//logfile.Layout = layout;
//config.AddRule(LogLevel.Trace, LogLevel.Fatal, logfile);
//NLog.LogManager.Configuration = config;
config.AddRule(LogLevel.Debug, LogLevel.Fatal, logfile);
NLog.LogManager.Configuration = config;


Log = LogManager.GetCurrentClassLogger();
Expand Down
Loading