Beispiel #1
0
 public static State UnpackNewestEventArchive(ImList <EventArchive> eventArchives, State state)
 {
     return(state
            & Store.UpdateGameState(eventArchives[0].Snapshot)
            & Store.UpdateEventStoreList((Store.GetEventStoreList(state) * eventArchives[0].Archive) & Im.Sort)
            & Store.UpdateEventArchives(Im.Tail(eventArchives))
            );
 }
        public static EventParameters operator +(EventParameter parameter1, EventParameter parameter2)
        {
            var parameterList = new ImList <EventParameter>()
                                + parameter1
                                + parameter2
            ;

            return(new EventParameters(parameterList));
        }
 public EventArchive(
     ImList <Event> archive,
     float archivedUntil,
     GameState snapshot
     )
 {
     Archive       = archive;
     ArchivedUntil = archivedUntil;
     Snapshot      = snapshot;
 }
Beispiel #4
0
        public static State OverlayOnEventStoreList(ImList <Event> eventList, State state)
        {
            var eventStoreList = Store.GetEventStoreList(state);

            return(Store.UpdateEventStoreList(
                       eventList
                       & Im.Overlay((evnt1, evnt2) => evnt1.Equals(evnt2), eventStoreList)
                       & Im.Sort
                       , state
                       ));
        }
Beispiel #5
0
        public void Map_x()
        {
            var l = ImList.List(5, 6, 7);

            var ml = l.Map((_, i) => i);

            CollectionAssert.AreEqual(new[] { 0, 1, 2 }, ml.ToArray());

            var z  = ImZipper.Zip(5, 6, 7);
            var mz = z.Map((_, i) => i);

            CollectionAssert.AreEqual(new[] { 0, 1, 2 }, mz.ToArray());
        }
     public ImList <int>[] AllMoveOptions()
     {
         if (FirstRollResult == SecondRollResult)
         {
             return new []
                    {
                        ImList <int> .Create(Enumerable.Repeat(FirstRollResult, 4))
                    }
         }
         ;
         return(new []
         {
             ImList <int> .Create(FirstRollResult, SecondRollResult),
             ImList <int> .Create(SecondRollResult, FirstRollResult)
         });
     }
 }
Beispiel #7
0
        public void Scenario4ImList()
        {
            var l = new ImList <D>();

            for (int idx = 1; idx <= cntAdd; idx++)
            {
                l = l.Add(new D(idx));
            }
            for (int idx = 1; idx <= cntRead; idx++)
            {
                var a = l.ToArray();
                if (a.Length != cntAdd)
                {
                    throw new Exception($"{a.Length} != {cntAdd}");
                }
            }
        }
Beispiel #8
0
 private IEnumerable <ImList <SingleGameMove> > MoveOptions(ImList <int> moves, GameColor player)
 {
     if (moves.IsNil)
     {
         yield return(ImList <SingleGameMove> .Nil);
     }
     else
     {
         foreach (var firstMove in this.SingleMoveOptions(moves.HeadUnsafe, player))
         {
             foreach (var restMoves in this.DoSingleMove(firstMove).MoveOptions(moves.TailUnsafe, player))
             {
                 yield return(ImList <SingleGameMove> .Cons(firstMove, restMoves));
             }
         }
     }
 }
Beispiel #9
0
 public State(
     string me,
     Event processing,
     EventStore eventStore,
     ImList <EventArchive> eventArchives,
     GameState gameState,
     UIState uiState,
     ImList <RenderCommand> renderData
     )
 {
     Me               = me;
     Processing       = processing;
     ActiveEventStore = eventStore;
     EventArchives    = eventArchives;
     CurrentGameState = gameState;
     CurrentUIState   = uiState;
     RenderData       = renderData;
 }
Beispiel #10
0
        public void Scenario4ImListLock()
        {
            var lst   = new ImList <D>();
            var datas = GetDatas();

            Run(
                () => {
                foreach (var d in datas.datas1)
                {
                    lock (this) {
                        var ll = System.Threading.Volatile.Read(ref lst);
                        ll     = ll.Add(d);
                        System.Threading.Volatile.Write(ref lst, ll);
                        System.Threading.Interlocked.MemoryBarrier();
                    }
                    eatTime();
                }
            },
                () => {
                foreach (var d in datas.datas2)
                {
                    lock (this) {
                        var ll = System.Threading.Volatile.Read(ref lst);
                        ll     = ll.Add(d);
                        System.Threading.Volatile.Write(ref lst, ll);
                        System.Threading.Interlocked.MemoryBarrier();
                    }
                    eatTime();
                }
            }
                );

            for (int idx = 1; idx <= cntRead; idx++)
            {
                var a = lst.ToArray();
                if (a.Length != 2 * cntAdd)
                {
                    throw new Exception($"{a.Length} != 2*{cntAdd}");
                }
            }
        }
Beispiel #11
0
 public ReceivePackageEvent(EventId eventId, string progress, ImList <Event> events) : base(eventId)
 {
     Progress = progress;
     Events   = events;
 }
Beispiel #12
0
 public EventStore(ImList <Event> store, ImList <Event> outbox, string progressId)
 {
     Store      = store;
     Outbox     = outbox;
     ProgressId = progressId;
 }
Beispiel #13
0
 public void Can_map_with_index() =>
 CollectionAssert.AreEqual(
     new[] { 1, 3, 5, 7 },
     ImList.List(1, 2, 3, 4).Map((x, i) => x + i).ToArray());
Beispiel #14
0
 public static State UpdateRenderData(ImList <RenderCommand> renderData, State state)
 {
     state.RenderData = renderData;
     return(state);
 }
Beispiel #15
0
 public EventStore(List <Event> store, List <Event> outbox, string progressId)
 {
     Store      = new ImList <Event>(store);
     Outbox     = new ImList <Event>(outbox);
     ProgressId = progressId;
 }
 public EventParameters()
 {
     Parameters = new ImList <EventParameter>();
 }
Beispiel #17
0
 public static Func <State, State> UpdateEventArchives(ImList <EventArchive> eventArchives)
 {
     return(Curry <ImList <EventArchive>, State, State> .New(UpdateEventArchives)(eventArchives));
 }
Beispiel #18
0
 public static Func <State, State> UnpackNewestEventArchive(ImList <EventArchive> eventArchives)
 {
     return(Curry <ImList <EventArchive>, State, State> .New(UnpackNewestEventArchive)(eventArchives));
 }
Beispiel #19
0
 public static Func <State, State> UpdateEventStoreList(ImList <Event> eventStoreList)
 {
     return(Curry <ImList <Event>, State, State> .New(UpdateEventStoreList)(eventStoreList));
 }
Beispiel #20
0
 public WholeMove(ImList <SingleGameMove> moves)
 {
     Moves = moves;
 }
Beispiel #21
0
 public static Func <State, State> OverlayOnEventStoreList(ImList <Event> eventList)
 {
     return(Curry <ImList <Event>, State, State> .New(OverlayOnEventStoreList)(eventList));
 }
Beispiel #22
0
 public static ImList <T> ToImList <T>(this IEnumerable <T> @this)
 {
     return(ImList <T> .Create(@this));
 }
 public EventParameters(ImList <EventParameter> parameters)
 {
     Parameters = parameters;
 }
 public EventParameters(List <EventParameter> parameters)
 {
     Parameters = new ImList <EventParameter>(parameters);
 }
Beispiel #25
0
        public void TestMethodImList()
        {
            ImList ret = SlackClient.ImControler.List();

            Assert.IsTrue(ret.Ok);
        }
Beispiel #26
0
 public static State UpdateEventArchives(ImList <EventArchive> eventArchives, State state)
 {
     state.EventArchives = eventArchives;
     return(state);
 }
Beispiel #27
0
 public void Can_map() =>
 CollectionAssert.AreEqual(
     new[] { 2, 4, 6, 8 },
     ImList.List(1, 2, 3, 4).Map(i => i * 2).ToArray());
Beispiel #28
0
 public static void Render(GameObject gameObject, ImList <RenderCommand> renderData)
 {
     Im.Fold(HandleRenderCommand, gameObject, renderData);
 }