Archive Browser
Download LangtonsAntSimulator.zip version 2.0.0.0, last updated 08/03/2011 (366.76 KB)
Download- md5: 347f7d65e83267424d0afa1dffdaae45
using System.Linq;
using System.Windows.Forms;
namespace LangontsAntSimulator
{
public partial class ActorViewer : UserControl
{
#region Private Member Declarations
private IActor _actor;
private ISimulation _simulation;
#endregion Private Member Declarations
#region Public Constructors
public ActorViewer()
{
InitializeComponent();
}
#endregion Public Constructors
#region Public Methods
public void UpdateUi()
{
string location;
string facing;
string nextMove;
location = string.Empty;
facing = string.Empty;
nextMove = string.Empty;
if (this.Simulation != null && this.Actor != null)
{
LangtonsAntSimulation simulation;
IBlock currentBlock;
Direction nextFacing;
location = string.Format("X:{0}, Y:{1}", this.Actor.Location.X, this.Actor.Location.Y);
currentBlock = this.Simulation.Blocks.FirstOrDefault(b => b.Location == this.Actor.Location);
if (currentBlock != null)
{
facing = string.Format("{0} ({1})", this.Actor.Facing.ToString(), currentBlock.IsTagged ? "Black" : "White");
simulation = (LangtonsAntSimulation)this.Simulation;
nextFacing = simulation.GetNextFacing(currentBlock, this.Actor.Facing);
nextMove = nextFacing.ToString();
}
}
locationTextBox.Text = location;
facingTextBox.Text = facing;
nextMoveTextBox.Text = nextMove;
}
#endregion Public Methods
#region Public Properties
public IActor Actor
{
get { return _actor; }
set
{
_actor = value;
this.UpdateUi();
}
}
public ISimulation Simulation
{
get { return _simulation; }
set
{
_simulation = value;
this.UpdateUi();
}
}
#endregion Public Properties
}
}
Donate
This software may be used free of charge, but as with all free software there are costs involved to develop and maintain.
If this site or its services have saved you time, please consider a donation to help with running costs and timely updates.
Donate