public async Task TournamentController_BidContest()
        {
            Log.Level = 5;
            var t = await TournamentLoader.LoadAsync(File.OpenRead("uBidParscore.pbn"));

            var c = new TournamentController(t, new ParticipantInfo()
            {
                PlayerNames = new Participant("North", "East", "South", "West"), ConventionCardNS = "RoboBridge", ConventionCardWE = "RoboBridge", UserId = Guid.NewGuid()
            }, BridgeEventBus.MainEventBus);
            var r = new SeatCollection <BridgeRobot>(new BridgeRobot[] { new TestRobot(Seats.North, BridgeEventBus.MainEventBus), new TestRobot(Seats.East, BridgeEventBus.MainEventBus), new TestRobot(Seats.South, BridgeEventBus.MainEventBus), new TestRobot(Seats.West, BridgeEventBus.MainEventBus) });
            await c.StartTournamentAsync();

            Assert.AreEqual <int>(1, t.Boards[0].Results.Count);
            Assert.AreEqual <int>(2, t.Boards[0].Results[0].Contract.Bid.Hoogte);
            Assert.IsFalse(t.Boards[0].Results[0].Play.PlayEnded);
            var whoseTurn = t.Boards[0].Dealer;

            foreach (var bid in t.Boards[0].Results[0].Auction.Bids)
            {
                if (!whoseTurn.IsSameDirection(t.Boards[0].Results[0].Auction.Opener))
                {
                    Assert.IsTrue(bid.IsPass, "no overcalls");
                }

                whoseTurn = whoseTurn.Next();
            }
        }
Exemple #2
0
        public async Task TableManager_2Tables_Test()
        {
            Log.Level = 1;
            var host1 = new TestHost(2002, new BridgeEventBus("Host1"));

            host1.OnHostEvent += Host_OnHostEvent;

            var vms = new SeatCollection <TestClient>();

            Parallel.For(0, 4, (i) =>
            {
                Seats s = (Seats)i;
                vms[s]  = new TestClient();
                vms[s].Connect(s, "localhost", 2002, 120, 1, "Robo" + (s == Seats.North || s == Seats.South ? "NS" : "EW"), false);
            });

            var host2 = new TestHost(2003, new BridgeEventBus("Host2"));

            host2.OnHostEvent += Host_OnHostEvent;

            var vms2 = new SeatCollection <TestClient>();

            Parallel.For(0, 4, (i) =>
            {
                Seats s = (Seats)i;
                vms2[s] = new TestClient();
                vms2[s].Connect(s, "localhost", 2003, 120, 1, "Robo" + (s == Seats.North || s == Seats.South ? "NS" : "EW"), false);
            });

            await host1.WaitForCompletionAsync();
        }
Exemple #3
0
        public SeatOptions(DataTable seatsTable, DataTable sectionsTable, DataTable seatTypesTable,
				DataTable allocTable)
        {
            Seats = new SeatCollection(seatsTable);
            Sections = new SectionCollection(sectionsTable);
            SeatTypes = new SeatTypeCollection(seatTypesTable);
            Allocations = new AllocationCollection(allocTable);
        }
        public async Task TournamentController_NoBoards()
        {
            Log.Level = 5;
            var t = new NoBoardsTournament();
            var c = new TournamentController(t, new ParticipantInfo()
            {
                PlayerNames = new Participant("North", "East", "South", "West"), ConventionCardNS = "RoboBridge", ConventionCardWE = "RoboBridge", UserId = Guid.NewGuid()
            }, BridgeEventBus.MainEventBus);
            var r = new SeatCollection <BridgeRobot>(new BridgeRobot[] { new TestRobot(Seats.North, BridgeEventBus.MainEventBus), new TestRobot(Seats.East, BridgeEventBus.MainEventBus), new TestRobot(Seats.South, BridgeEventBus.MainEventBus), new TestRobot(Seats.West, BridgeEventBus.MainEventBus) });
            await c.StartTournamentAsync();

            Assert.AreEqual <int>(0, t.Boards.Count);
        }
 protected TableManagerHost(BridgeEventBus bus, string name) : base(bus, name)
 {
     this.clients    = new SeatCollection <ClientData>();
     this.moreBoards = true;
     this.lagTimer   = new System.Diagnostics.Stopwatch();
     this.ThinkTime  = new DirectionDictionary <System.Diagnostics.Stopwatch>(new System.Diagnostics.Stopwatch(), new System.Diagnostics.Stopwatch());
     this.boardTime  = new DirectionDictionary <TimeSpan>(new TimeSpan(), new TimeSpan());
     this.waiter     = new SemaphoreSlim(initialCount: 0);
     Task.Run(async() =>
     {
         await this.ProcessMessages();
     });
 }
        public async Task TournamentController_Run()
        {
            Log.Level = 4;
            var t = await TournamentLoader.LoadAsync(File.OpenRead("WC2005final01.pbn"));

            var c = new TournamentController(t, new ParticipantInfo()
            {
                PlayerNames = new Participant("North", "East", "South", "West"), ConventionCardNS = "RoboBridge", ConventionCardWE = "RoboBridge", UserId = Guid.NewGuid()
            }, BridgeEventBus.MainEventBus);
            var r = new SeatCollection <BridgeRobot>(new BridgeRobot[] { new TestRobot(Seats.North, BridgeEventBus.MainEventBus), new TestRobot(Seats.East, BridgeEventBus.MainEventBus), new TestRobot(Seats.South, BridgeEventBus.MainEventBus), new TestRobot(Seats.West, BridgeEventBus.MainEventBus) });
            await c.StartTournamentAsync();

            Assert.AreEqual <int>(3, t.Boards[0].Results.Count);
            Assert.AreEqual <int>(5, t.Boards[0].Results[0].Contract.Bid.Hoogte);
            Assert.IsTrue(t.Boards[0].Results[0].Play.PlayEnded);
            Assert.IsFalse(t.Boards[0].Results[2].Auction.Bids[0].IsPass);      // opening
            Assert.IsFalse(t.Boards[0].Results[2].Auction.Bids[1].IsPass);      // overcall
        }
Exemple #7
0
        public async Task TableManager_Client_Test()
        {
            Log.Level = 4;
            // Comment the next 3 lines if you want to test against a real TableManager
#if useOwnHost
            var host = new TestHost(2001, new BridgeEventBus("TM_Host"));
            host.OnHostEvent += Host_OnHostEvent;
#endif

            var vms = new SeatCollection <TestClient>();
            Parallel.For(0, 4, (i) =>
            {
                Seats s = (Seats)i;
                vms[s]  = new TestClient();
                vms[s].Connect(s, "localhost", 2001, 120, 1, "Robo" + (s == Seats.North || s == Seats.South ? "NS" : "EW"), false);
            });

            await host.WaitForCompletionAsync();
        }
Exemple #8
0
 public TMBoardResult(TableManagerClient _owner, Board2 board, SeatCollection <string> newParticipants)
     : base("TMBoardResult." + _owner.seat, board, newParticipants, _owner.EventBus, null)
 {
     this.tmc = _owner;
 }
 public HostBoardResult(TableManagerHost h, Board2 board, SeatCollection <string> newParticipants, BridgeEventBus bus)
     : base("HostBoardResult", board, newParticipants, bus, null)
 {
     this.host = h;
 }