public void Alice_can_not_create_move_operation_because_she_has_not_such_activity() { var a = new Location( "A" ); var alice = Factory.CreateAgent< IActive >( "Alice" ); alice.As< IActive >().AddIntention( Lib.Activities.Movement, alice, a ); }
public void Abilities_ordering_does_not_cause_on_the_proceed_success() { var world = Factory.CreateWorld(); var alice = world.IReality.AddAgent( Factory.CreateAgent< IActive, IVirtual, IDesirous, IThinking >( "Alice" ) ); var bob = world.IReality.AddAgent( Factory.CreateAgent< IThinking, IDesirous, IVirtual, IActive >( "Bob" ) ); var a = new Location( "A" ); var b = new Location( "B" ); alice.As< IActive >().AddActivity( Lib.Activities.Movement ); alice.As< IVirtual >().AddAttribute( new Position( a ) ); alice.As< IActive >().AddIntention( Lib.Activities.Movement, alice, b ); bob.As< IActive >().AddActivity( Lib.Activities.Movement ); bob.As< IVirtual >().AddAttribute( new Position( a ) ); bob.As< IActive >().AddIntention( Lib.Activities.Movement, bob, b ); world.Proceed(); Log( world.Dump() ); Assert.That( alice.Get( Its.Virtual.Location ), Is.EqualTo( b ) ); Assert.That( bob.Get( Its.Virtual.Location ), Is.EqualTo( b ) ); }
public void Alice_asks_Bob_to_pass_her_throw_door() { var world = Factory.CreateWorld( "The House" ); var alice = world.IReality.AddAgent( Factory.CreateAgent< IVirtual >( "Alice" ) ); var bob = world.IReality.AddAgent( Factory.CreateAgent< IVirtual >( "Bob" ) ); var a = new Location( "A" ); var b = new Location( "B" ); var c = new Location( "C" ); alice.As< IVirtual >().AddAttribute( new Position( a ) ); alice.As< IDesirous >().AddDesire( new LocationDesire( alice, b ) ); bob.As< IVirtual >().AddAttribute( new Position( b ) ); Log( world.Dump() ); Assert.AreEqual( a, alice.As< IVirtual >().GetAttribute< IPosition >().Location ); Assert.AreEqual( b, bob.As< IVirtual >().GetAttribute< IPosition >().Location ); world.Proceed(); world.Proceed(); world.Proceed(); world.Proceed(); Log( world.Dump() ); Assert.AreEqual( b, alice.As< IVirtual >().GetAttribute< IPosition >().Location ); Assert.AreEqual( c, bob.As< IVirtual >().GetAttribute< IPosition >().Location ); Assert.Ignore(); }
public void Alice_can_move_in_her_outer_world() { var world = Factory.CreateWorld( "The World" ); var alice = world.IReality.AddAgent( Factory.CreateAgent< IVirtual >( "Alice" ) ); var a = new Location( "A" ); var b = new Location( "B" ); var c = new Location( "C" ); var move = new Dictionary< ILocation, ILocation > { { a, b }, { b, c }, { c, a } }; alice.As< IVirtual >().AddAttribute( new Position( a ) ); world.IThinking.AddBelief( reality => { var alicePosition = reality.GetAgent( alice ).As< IVirtual >().GetAttribute< IPosition >(); alicePosition.Location = move[ alicePosition.Location ]; } ); Log( world.Dump() ); Assert.True( world.IReality.Contains( alice ) ); Assert.That( world.GetAgent( alice ).Get( Its.Virtual.Location ), Is.EqualTo( a ) ); world.IThinking.ImplementBeliefs(); Log( world.Dump() ); Assert.That( world.GetAgent( alice ).Get( Its.Virtual.Location ), Is.EqualTo( b ) ); world.IThinking.ImplementBeliefs(); Log( world.Dump() ); Assert.That( world.GetAgent( alice ).Get( Its.Virtual.Location ), Is.EqualTo( c ) ); world.IThinking.ImplementBeliefs(); Log( world.Dump() ); Assert.That( world.GetAgent( alice ).Get( Its.Virtual.Location ), Is.EqualTo( a ) ); }
public void World_can_think_and_change_reality() { var locA = new Location( "A" ); var locB = new Location( "B" ); var world = Factory.CreateWorld( "The World" ); var alice = world.IReality.AddAgent( Factory.CreateAgent< IVirtual >( "Alice" ) ); alice.As< IVirtual >().AddAttribute( new Position( locA ) ); world.IThinking.AddBelief( reality => { reality.GetAgent( alice ).As< IVirtual >().GetAttribute< IPosition >().Location = locB; } ); Log( world.Dump() ); Log( alice.Dump() ); Assert.AreEqual( "The World", world.Name ); Assert.True( world.IReality.Contains( alice ) ); Assert.AreEqual( locA, alice.As< IVirtual >().GetAttribute< IPosition >().Location ); Log( "Thinking...\n" ); world.IThinking.ImplementBeliefs(); Log( world.Dump() ); Assert.That( world.IReality.Contains( alice ) ); Assert.AreEqual( locB, alice.As< IVirtual >().GetAttribute< IPosition >().Location ); }
public void Alice_desires_meet_Bob_then_she_thinks_and_decides_to_move_to_B() { // todo:> let IThinking.InnerReality points to one of the ThinkingProcess's reality var world = Factory.CreateWorld(); var a = new Location( "A" ); var b = new Location( "B" ); var c = new Location( "C" ); var alice = world.IReality.AddAgent( Factory.CreateAgent< IVirtual, IDesirous, IThinking, IDeciding, IActive >( "alice" ) ); var bob = alice.As< IThinking >() .InnerReality.AddAgent( Factory.CreateAgent< IVirtual, IDesirous, IThinking, IDeciding, IActive >( "bob" ) ); // todo:> use extentions to simify: bob.AddPosiotion(c), bob.AddLocationDesire(b) bob.As< IVirtual >().AddAttribute( new Position( c ) ); bob.As< IActive >().AddActivity( Lib.Activities.Movement ); bob.As< IDesirous >().AddDesire( new LocationDesire( bob, b ) ); alice.As< IVirtual >().AddAttribute( new Position( c ) ); alice.As< IActive >().AddActivity( Lib.Activities.Movement ); // alice.As< IDesirous >().AddDesire( new MeetingDesire( bob ) ); world.Proceed(); Log( alice.Dump() ); Assert.That( alice.Get( Its.Virtual.Location ), Is.EqualTo( b ) ); Assert.That( bob.Get( Its.Virtual.Location ), Is.EqualTo( b ) ); }
public void Access_agent_location_directly() { var world = Factory.CreateWorld(); var alice = world.IReality.AddAgent( Factory.CreateAgent< IVirtual >( "Alice" ) ); var a = new Location( "A" ); alice.Set( Its.Virtual.Location, a ); Assert.That( alice.Get( Its.Virtual.Location ), Is.EqualTo( a ) ); }
public void Alice_can_not_proceed_move_operation_because_she_has_not_such_activity() { var a = new Location( "A" ); var world = Factory.CreateWorld(); var alice = world.IReality.AddAgent( Factory.CreateAgent< IVirtual, IThinking, IDesirous, IActive >( "Alice" ) ); alice.As< IActive >().AddIntention( Lib.Activities.Movement, alice, a ); world.Proceed(); }
public void Access_agent_location_via_position() { var world = Factory.CreateWorld(); var alice = world.IReality.AddAgent( Factory.CreateAgent< IVirtual >( "Alice" ) ); var a = new Location( "A" ); alice.Set( Its.Virtual.Position, new Position() ); alice.Get( Its.Virtual.Position ).Location = a; Assert.That( alice.Get( Its.Virtual.Position ).Location, Is.EqualTo( a ) ); }
public void World_has_properties() { var locA = new Location( "A" ); var world = Factory.CreateWorld( "The World" ); var alice = world.IReality.AddAgent( Factory.CreateAgent< IVirtual >( "Alice" ) ); alice.As< IVirtual >().AddAttribute( new Position( locA ) ); Log( world.Dump() ); Assert.AreEqual( "The World", world.Name ); Assert.AreSame( world.IReality, world.IThinking.InnerReality ); Assert.That( world.IReality.Contains( alice ) ); }
public void Desire_can_be_named_and_names_are_dumped() { var a = new Location( "A" ); var agent = Factory.CreateAgent< IDesirous, IThinking >(); agent.As< IDesirous >().AddDesire( new EmptyDesire() ); agent.As< IDesirous >().AddDesire( new ExistingDesire( agent ) ); agent.As< IDesirous >().AddDesire( new LocationDesire( agent, a ) ); var dump = Log( agent.Dump() ); Assert.That( dump, Is.StringContaining( "SomeAgent" ) ); Assert.That( dump, Is.StringContaining( "Nothing(,INothing )" ) ); Assert.That( dump, Is.StringContaining( "Existing(SomeAgent,INothing )" ) ); Assert.That( dump, Is.StringContaining( "InLocation(SomeAgent,ILocation A)" ) ); }
public void Activities_Operations_and_Intentions_work_properly() { var world = Factory.CreateWorld(); var alice = world.IReality.AddAgent( Factory.CreateAgent< IVirtual, IDesirous, IThinking, IActive >( "Alice" ) ); var a = new Location( "A" ); var b = new Location( "B" ); alice.As< IVirtual >().AddAttribute( new Position( a ) ); alice.As< IThinking >().InnerReality.AddAgent( alice ); IIntention intention = new Intention< ILocation >( Lib.Activities.Movement, alice, b ); intention.Realize( world.IReality ); Log( world.Dump() ); Assert.That( alice.Get( Its.Virtual.Location ), Is.EqualTo( b ) ); }
public void Alice_desires_B_and_Decides_to_move_to_B() { var world = Factory.CreateWorld(); var alice = world.IReality.AddAgent( Factory.CreateAgent< IVirtual, IDesirous, IDeciding, IActive >( "alice" ) ); var a = new Location( "A" ); var b = new Location( "B" ); alice.As< IActive >().AddActivity( Lib.Activities.Movement ); alice.As< IVirtual >().AddAttribute( new Position( a ) ); alice.As< IDesirous >().AddDesire( new LocationDesire( alice, b ) ); Log( alice.Dump() ); alice.As< IDeciding >().MakeDecision( world.IReality ); alice.As< IDeciding >().Proceed( world.IReality ); Log( alice.Dump() ); Assert.That( alice.As< IActive >().ContainsIntention( Lib.Activities.Movement, alice, b ) ); }
public void Alice_desires_be_in_B_then_decides_move_to_B_and_then_moves_to_B() { var world = Factory.CreateWorld(); var alice = world.IReality.AddAgent( Factory.CreateAgent< IVirtual, IDesirous, IDeciding, IActive >( "alice" ) ); var a = new Location( "A" ); var b = new Location( "B" ); alice.As< IActive >().AddActivity( Lib.Activities.Movement ); alice.As< IVirtual >().AddAttribute( new Position( a ) ); alice.As< IDesirous >().AddDesire( new LocationDesire( alice, b ) ); Log( alice.Dump() ); world.Proceed(); Log( alice.Dump() ); Assert.That( alice.Get( Its.Virtual.Location ), Is.EqualTo( b ) ); Assert.False( alice.As< IActive >().ContainsIntention( Lib.Activities.Movement, alice, b ) ); }
public void Alice_desires_to_be_in_location_B_and_is_satisfied_by_suggestion_that_she_is() { var world = Factory.CreateWorld(); var alice = world.IReality.AddAgent( Factory.CreateAgent< IVirtual, IDesirous, IThinking >( "Alice" ) ); var a = new Location( "A" ); var b = new Location( "B" ); alice.As< IVirtual >().AddAttribute( new Position( a ) ); var herself = alice.As< IThinking >().InnerReality.AddAgent( alice ); IDesire desire = new LocationDesire( alice, b ); alice.As< IDesirous >().AddDesire( desire ); Log( world.Dump() ); alice.As< IVirtual >().GetAttribute< IPosition >().Location = b; Assert.False( desire.IsSatisfiedIn( alice.As< IThinking >().InnerReality ) ); alice.As< IVirtual >().GetAttribute< IPosition >().Location = a; herself.As< IVirtual >().GetAttribute< IPosition >().Location = b; Assert.True( desire.IsSatisfiedIn( alice.As< IThinking >().InnerReality ) ); }
public void No_intentions_after_proceed() { var a = new Location( "A" ); var b = new Location( "B" ); var world = Factory.CreateWorld(); var alice = world.IReality.AddAgent( Factory.CreateAgent< IVirtual, IThinking, IDesirous, IActive >( "Alice" ) ); alice.As< IActive >().AddActivity( Lib.Activities.Movement ); alice.As< IVirtual >().AddAttribute( new Position( a ) ); alice.As< IActive >().AddIntention( Lib.Activities.Movement, alice, b ); alice.As< IThinking >().InnerReality.AddAgent( alice, "aAlice" ); var dump1 = Log( world.Dump() ); { world.Proceed(); } var dump2 = Log( world.Dump() ); Assert.That( dump1, Is.StringContaining( "MoveTo(Alice,B) <Intention`1>" ) ); Assert.That( dump2, Is.Not.StringContaining( "MoveTo(Alice,B) <Intention`1>" ) ); }
public void Alice_and_Bob_have_positions() { var house = Factory.CreateReality( "The House" ); var alice = house.AddAgent( Factory.CreateAgent< IVirtual >( "Alice" ) ); var bob = house.AddAgent( Factory.CreateAgent< IVirtual >( "Bob" ) ); var initial = new Location( "Initial" ); var destination = new Location( "Destination" ); alice.As< IVirtual >().AddAttribute( new Position( initial ) ); bob.As< IVirtual >().AddAttribute( new Position( destination ) ); var dump = house.Dump(); Log( house.Dump() ); Assert.That( dump.Contains( "Position" ) ); Assert.That( dump.Contains( "Location" ) ); Assert.That( dump.Contains( "Destination" ) ); Assert.That( dump.Contains( "Initial" ) ); Assert.AreEqual( "Destination", destination.ILocation.Name ); Assert.AreEqual( initial, alice.As< IVirtual >().GetAttribute< IPosition >().Location ); Assert.AreEqual( destination, bob.As< IVirtual >().GetAttribute< IPosition >().Location ); }
public void Bob_has_inadequate_selfimage() { var a = new Location( "A" ); var b = new Location( "B" ); var world = Factory.CreateWorld(); var bob = Factory.CreateAgent< IVirtual, IThinking, IDesirous, IActive >( "Bob" ); bob.As< IActive >().AddActivity( Lib.Activities.Movement ); bob.As< IVirtual >().AddAttribute( new Position( a ) ); var wBob = world.IReality.AddAgent( bob, "wBob" ); var bBob = wBob.As< IThinking >().InnerReality.AddAgent( wBob, "bBob" ); wBob.As< IActive >().AddIntention( Lib.Activities.Movement, bob, b ); Log( world.Dump() ); { world.Proceed(); } Log( world.Dump() ); Assert.That( bob.Get( Its.Virtual.Location ), Is.EqualTo( a ) ); Assert.That( wBob.Get( Its.Virtual.Location ), Is.EqualTo( b ) ); Assert.That( bBob.Get( Its.Virtual.Location ), Is.Not.EqualTo( b ) ); }
public void World_thinks_that_Alice_goes_to_B() { var world = Factory.CreateWorld(); var alice = world.IReality.AddAgent( Factory.CreateAgent< IVirtual, IDesirous, IThinking, IActive >( "Alice" ) ); var a = new Location( "A" ); var b = new Location( "B" ); alice.As< IActive >().AddActivity( Lib.Activities.Movement ); alice.As< IVirtual >().AddAttribute( new Position( a ) ); alice.As< IActive >().AddIntention( Lib.Activities.Movement, alice, b ); Log( world.Dump() ); Assert.That( alice.Get( Its.Virtual.Location ), Is.EqualTo( a ) ); world.Proceed(); Log( world.Dump() ); Assert.That( alice.Get( Its.Virtual.Location ), Is.EqualTo( b ) ); }
public void Alice_has_adequate_selfimage() { var a = new Location( "A" ); var b = new Location( "B" ); var world = Factory.CreateWorld(); var alice = Factory.CreateAgent< IVirtual, IThinking, IDesirous, IActive >( "Alice" ); alice.As< IActive >().AddActivity( Lib.Activities.Movement ); alice.As< IVirtual >().AddAttribute( new Position( a ) ); alice.As< IActive >().AddIntention( Lib.Activities.Movement, alice, b ); var wAlice = world.IReality.AddAgent( alice, "wAlice" ); var aAlice = wAlice.As< IThinking >().InnerReality.AddAgent( wAlice, "aAlice" ); Log( world.Dump() ); { world.Proceed(); } Log( world.Dump() ); Assert.That( alice.Get( Its.Virtual.Location ), Is.EqualTo( a ) ); Assert.That( wAlice.Get( Its.Virtual.Location ), Is.EqualTo( b ) ); Assert.That( aAlice.Get( Its.Virtual.Location ), Is.EqualTo( b ) ); }
public void Set_agent_position() { var world = Factory.CreateWorld(); var alice = world.IReality.AddAgent( Factory.CreateAgent< IVirtual >( "Alice" ) ); var a = new Location( "A" ); var p = new Position( a ); alice.Set( Its.Virtual.Position, p ); Assert.That( alice.As< IVirtual >().GetAttribute< IPosition >(), Is.EqualTo( p ) ); }
public void Change_agent_location_via_position() { var world = Factory.CreateWorld(); var alice = world.IReality.AddAgent( Factory.CreateAgent< IVirtual >( "Alice" ) ); var a = new Location( "A" ); var b = new Location( "B" ); var c = new Location( "C" ); alice.Set( Its.Virtual.Location, a ); Assert.That( alice.Get( Its.Virtual.Location ), Is.EqualTo( a ) ); alice.Set( Its.Virtual.Location, b ); Assert.That( alice.Get( Its.Virtual.Location ), Is.EqualTo( b ) ); alice.Set( Its.Virtual.Location, c ); Assert.That( alice.Get( Its.Virtual.Location ), Is.EqualTo( c ) ); alice.Get( Its.Virtual.Position ).Location = a; Assert.That( alice.Get( Its.Virtual.Location ), Is.EqualTo( a ) ); Assert.That( alice.Get( Its.Virtual.Location ), Is.EqualTo( a ) ); }
public void Alice_thinks_that_she_goes_to_B_but_in_really_not() { var world = Factory.CreateWorld(); var alice0 = world.IReality.AddAgent( Factory.CreateAgent< IVirtual, IThinking, IDesirous, IActive >( "Alice" ) ); var a = new Location( "A" ); var b = new Location( "B" ); alice0.As< IActive >().AddActivity( Lib.Activities.Movement ); alice0.As< IVirtual >().AddAttribute( new Position( a ) ); alice0.As< IActive >().AddIntention( Lib.Activities.Movement, alice0, b ); var alice1 = alice0.As< IThinking >().InnerReality.AddAgent( alice0 ); Log( world.Dump() ); alice0.Proceed( world.IReality ); Log( world.Dump() ); Assert.That( alice1.Get( Its.Virtual.Location ), Is.EqualTo( b ) ); Assert.That( alice0.Get( Its.Virtual.Location ), Is.Not.EqualTo( b ) ); }
public void Position_location_name_should_be_cloned() { var alice = Factory.CreateAgent< IVirtual >( "Alice" ); var a = new Location( "A" ); alice.As< IVirtual >().AddAttribute( new Position( a ) ); var clone = alice.Clone(); Assert.AreEqual( "A", clone.As< IVirtual >().GetAttribute< IPosition >().Location.Name ); Log( clone.Dump() ); }
public void Intentions_are_dumped() { var world = Factory.CreateWorld(); var alice = world.IReality.AddAgent( Factory.CreateAgent< IVirtual, IDesirous, IThinking, IActive >( "Alice" ) ); ILocation a = new Location( "A" ); ILocation b = new Location( "B" ); alice.As< IVirtual >().AddAttribute( new Position( a ) ); alice.As< IThinking >().InnerReality.AddAgent( alice ); alice.As< IActive >().AddActivity( Lib.Activities.Movement ); alice.As< IActive >().AddIntention( Lib.Activities.Movement, alice, b ); var dump = Log( world.Dump() ); Assert.That( dump, Is.StringContaining( "<ActiveAbility>" ) ); Assert.That( dump, Is.StringContaining( "Intentions" ) ); Assert.That( dump, Is.StringContaining( "MoveTo(Alice,B)" ) ); }