public static void ComponentDeleteAddTest() { LogScene(); Console.WriteLine("\n\n\n删除组件...\n\n\n"); Console.WriteLine("\n\n\n重命名对象0...\n\n\n"); Component com = Scene.GetGameObjects()[0].Components[0];//删除Transform Scene.GetGameObjects()[0].Name = "CSharp Renamed Object"; Object.Destory(com); LogScene(); Console.WriteLine("\n\n\n创建组件..."); Transform newcom = new Transform(); Console.WriteLine("添加组件...\n\n\n"); newcom.Position = new Vec3(9f, 9f, 9f); newcom.Rotation = new Vec3(90f, 180f, 270f); newcom.Scale = new Vec3(1.1f, 1.1f, 1.1f); Scene.GetGameObjects()[0].AddComponent(newcom);//添加新的Transform LogScene(); TTT t = new TTT(); Scene.GetGameObjects()[0].AddComponent(t); LogScene(); //序列化 Serializer.Serialize(Scene.GetMainScene()); Console.ReadLine(); }
public Board(int dim, bool singlePlayer, ICallBack player, TTT server) { this.dim = dim; this.singlePlayer = singlePlayer; this.server = server; initBoard(); moveCount = 0; gameEnded = false; player1 = player; if (singlePlayer) { rand = new Random(); } game = new Game(); game.BoardSize = dim; game.Player1 = server.getPlayerData(player).Id; game.StartTime = DateTime.Now; game.Moves = ""; // simple array if (singlePlayer) { game.Player2 = 1; } waitingForPlayer2 = !singlePlayer; }
private void Search6_Timeline() { if (!TTT.HasSeed) { FormUtil.Error("Please Calibrate Timeline"); return; } var timeline = TTT.gettimeline(); int min = Math.Max((int)Frame_min.Value, timeline.Startingframe + 2); int max = (int)TimeSpan.Value * 60 + min; timeline.Maxframe = max; timeline.Generate(ForMainForm: true); int listlength = timeline.TinyLength; // Prepare var rng = new MersenneTwister(Seed.Value); for (int i = 0; i < min; i++) { rng.Next(); } getsetting(rng); Frame.standard = (int)(TargetFrame.Value - min); for (int i = 0; i < listlength; i++) { var tinyframe = timeline.results[i]; if (tinyframe.unhitable) { continue; } if (tinyframe.framemax < min) { continue; } RNGPool.TinySynced = tinyframe.sync == true; // For stationary for (int j = tinyframe.framemin + 2; j <= tinyframe.framemax; j += 2, RNGPool.AddNext(rng), RNGPool.AddNext(rng)) { while (j < min) { j += 2; } RNGPool.tinystatus = tinyframe.tinystate.Clone(); RNGPool.tinystatus.Currentframe = j; RNGResult result = RNGPool.Generate6(); if (!filter.CheckResult(result)) { continue; } Frames.Add(new Frame(result, frame: j, time: j - min)); Frames.Last()._tinystate = new PRNGState(tinyframe.tinystate.Status); if (Frames.Count > MAX_RESULTS_NUM) { return; } } } }
private void Search6_Timeline() { if (!TTT.HasSeed) { Error("Please Calibrate Timeline"); return; } RNGPool.timeline = TTT.gettimeline(); int min = Math.Max((int)Frame_min.Value, RNGPool.timeline.Startingframe + 2); int max = (int)TimeSpan.Value * 60 + min; RNGPool.timeline.Maxframe = max; RNGPool.timeline.Generate(Method == 0); // Consider Stationary delay int listlength = RNGPool.timeline.TinyLength; // Prepare var rng = new MersenneTwister(Seed.Value); for (int i = 0; i < min; i++) { rng.Next(); } getsetting(rng); for (int i = 0; i < listlength; i++) { var tinyframe = RNGPool.timeline.results[i]; if (tinyframe.unhitable) { continue; } if (tinyframe.framemax < min) { continue; } for (int j = tinyframe.framemin + 2; j <= tinyframe.framemax; j += 2, RNGPool.AddNext(rng), RNGPool.AddNext(rng)) { while (j < min) { j += 2; } RNGPool.tinystatus = (TinyStatus)tinyframe.tinystate.DeepCopy(); RNGPool.tinystatus.Currentframe = j; RNGResult result = RNGPool.Generate6(); if (!filter.CheckResult(result)) { continue; } Frames.Add(new Frame(result, frame: j, time: j - min)); Frames.Last()._tinystate = new PRNGState(tinyframe.state); if (Frames.Count > 100000) { return; } } } }
private void Start() { End.SetActive(false); game = new TTT(); //minimaxSearch = MinimaxSearch<State, int, int>.createFor(game); alphabetaSearch = AlphaBetaSearch <StateTTT, int, int> .createFor(game); CurrentState = game.getInitialState(); CheckisTerminal(); }
private void Start() { TTT game = new TTT(); MinimaxSearch <StateTTT, int, int> minimaxSearch = MinimaxSearch <StateTTT, int, int> .createFor(game); AlphaBetaSearch <StateTTT, int, int> alphabetaSearch = AlphaBetaSearch <StateTTT, int, int> .createFor(game); StateTTT state = game.getInitialState(); int action1 = -100000; int action2 = -100000; action1 = minimaxSearch.makeDecision(state); action2 = alphabetaSearch.makeDecision(state); Debug.Log("Chosen action is " + action1 + " and node minimax " + minimaxSearch.getMetrics()); Debug.Log("Chosen action is " + action2 + " and node alphabeta " + alphabetaSearch.getMetrics()); }
public Board(int dim, bool singlePlayer, ICallBack player, TTT server) { this.dim = dim; this.singlePlayer = singlePlayer; this.server = server; initBoard(); moveCount = 0; gameEnded = false; player1 = player; if (singlePlayer) rand = new Random(); game = new Game(); game.BoardSize = dim; game.Player1 = server.getPlayerData(player).Id; game.StartTime = DateTime.Now; game.Moves = ""; // simple array if (singlePlayer) game.Player2 = 1; waitingForPlayer2 = !singlePlayer; }
public string RabbitMQDemo() { TTT name = null; //注册AMQP接受事件 Core.Instance.AMQPReceive(".NETTest", (consumer) => { consumer.Received += (ch, ea) => { byte[] body = ea.Body; name = body.SystemDeserializer <TTT>(); }; return(consumer); }); Core.Instance.AMQPSend(".NETTest", ".NETTest", "1", new TTT("测试").SystemSerializer()); while (name == null) { } return(name.Text); }
public void TeleportTargetSelect() { ToBeChecked.Clear(); ValidTargets.Clear(); TargetLocations.Clear(); PossibleTeleportDestinations.Clear(); if (Grid == null) { Grid = GetComponent <Pathfinding>().Grid; } foreach (GameObject T in GetComponent <Pathfinding>().CurrentLocation.GetComponent <Tile>().Adjacent) { ToBeChecked.Add(T); } foreach (GameObject T in ToBeChecked) { if (T.GetComponent <Pathnode>().CurrentOccupant != null) { if (T.GetComponent <Pathnode>().CurrentOccupant.GetComponent <Unit>().Owner == GetComponent <Unit>().Owner) { ValidTargets.Add(T.GetComponent <Pathnode>().CurrentOccupant); TargetLocations.Add(T); } } } foreach (Transform TTT in Grid) { if (TargetLocations.Contains(TTT.gameObject) == false) { TTT.GetComponent <Pathnode>().Fade(); } } }
public async Task UpdateTile(MouseState mouseState, Player player) { var s2w = TTT.ScreenToWorld(mouseState.Position.ToVector2()); var rect = new Rectangle((int)s2w.X, (int)s2w.Y, 1, 1); var tile = TTT.Map.Tiles.FirstOrDefault(x => rect.Intersects(x.SpriteRectangle)); if (tile != null && tile.Player == Player.None) { TTT.Map.Tiles.Remove(tile); await tile.Update(player); TTT.Map.Tiles.Add(tile); await eventService.IsGameOver(TTT.Map); if (player == Player.Human) { TTT.Turn = Player.Computer; } else { TTT.Turn = Player.Human; } } }
internal Boolean ProcessToken(ref TimeSpanToken tok, ref TimeSpanResult result) { if (tok.ttt == TTT.NumOverflow) { result.SetFailure(ParseFailureKind.Overflow, "Overflow_TimeSpanElementTooLarge", null); return false; } if (tok.ttt != TTT.Sep && tok.ttt != TTT.Num) { // Some unknown token or a repeat token type in the input result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan", null); return false; } switch (tok.ttt) { case TTT.Sep: if (!AddSep(tok.sep, ref result)) return false; break; case TTT.Num: if (tokenCount == 0) { if (!AddSep(String.Empty, ref result)) return false; } if (!AddNum(tok, ref result)) return false; break; default: break; } lastSeenTTT = tok.ttt; Debug.Assert(tokenCount == (SepCount + NumCount), "tokenCount == (SepCount + NumCount)"); return true; }
public string NetSocketCoreDemo() { //1.初始化服务端网络通讯模块 NetSocketCore server = new NetSocketCore("127.0.0.1", 9000); //2.监听端口 server.LinkBind(); //3.初始化客户端网络通讯模块 NetSocketCore client = new NetSocketCore("127.0.0.1", 9000); //4.连接服务端 Socket socket = client.Connect(); //5.往服务端发送消息 TTT ttt = new TTT("Hello mytest!"); client.Send(ttt.SystemSerializer); NetSocketCore client2 = new NetSocketCore("127.0.0.1", 9000); Socket socket2 = client2.Connect(); ttt = new TTT("Hello mytest2!"); client2.Send(ttt.SystemSerializer); NetSocketCore client3 = new NetSocketCore("127.0.0.1", 9000); Socket socket3 = client3.Connect(); ttt = new TTT("Hello mytest3!"); client3.Send(ttt.SystemSerializer); NetSocketCore client4 = new NetSocketCore("127.0.0.1", 9000); Socket socket4 = client4.Connect(); ttt = new TTT("Hello mytest4!"); client4.Send(ttt.SystemSerializer); NetSocketCore client5 = new NetSocketCore("127.0.0.1", 9000); Socket socket5 = client5.Connect(); ttt = new TTT("Hello mytest5!"); client5.Send(ttt.SystemSerializer); NetSocketCore client6 = new NetSocketCore("127.0.0.1", 9000); Socket socket6 = client6.Connect(); ttt = new TTT("Hello mytest6!"); client6.Send(ttt.SystemSerializer); string result = ""; //服务端接受客户端传送的数据 Task.Run(async() => { result += "\n" + await Task.Run(async() => { foreach (var pair in server.SocketsMap) { result += "\n" + await Task.Run(() => { byte[] bb = new byte[NetSocketCore.ByteSize]; pair.Value.Receive(bb); TTT tt = bb.SystemDeserializer <TTT>(); return(tt.Text); }); Console.WriteLine(result); } return(result); }); }); Thread.Sleep(10000); return(result); }
internal void Init(DateTimeFormatInfo dtfi) { Debug.Assert(dtfi != null); lastSeenTTT = TTT.None; tokenCount = 0; SepCount = 0; NumCount = 0; literals = new String[MaxLiteralTokens]; numbers = new TimeSpanToken[MaxNumericTokens]; m_fullPosPattern = dtfi.FullTimeSpanPositivePattern; m_fullNegPattern = dtfi.FullTimeSpanNegativePattern; m_posLocInit = false; m_negLocInit = false; }
public TimeSpanToken(int leadingZeroes, int number) { ttt = TTT.Num; num = number; zeroes = leadingZeroes; sep = null; }
internal String sep; // Store the literal that we are parsing (if any) public TimeSpanToken(int number) { ttt = TTT.Num; num = number; zeroes = 0; sep = null; }
static void Main(string[] args) { Profiler.Init(); Console.WriteLine("Hello World!"); TTT tt = new TTT(); tt.tt1 = 1; tt.tt2 = 2; tt.tt3 = 3; tt.tt4 = 4; FlatBuffer buffer = new FlatBuffer(2); CircularBuffer circularBuffer = new CircularBuffer(); buffer.Wirte <TTT>(tt); circularBuffer.Enqueue <TTT>(tt); tt.tt1 = 5; tt.tt2 = 6; tt.tt3 = 7; tt.tt4 = 8; buffer.Wirte <TTT>(tt); circularBuffer.Enqueue <TTT>(tt); tt.tt1 = 0; tt.tt2 = 0; tt.tt3 = 0; tt.tt4 = 0; buffer.Read <TTT>(out tt); tt.tt1 = 0; tt.tt2 = 0; tt.tt3 = 0; tt.tt4 = 0; circularBuffer.Dequeue <TTT>(out tt); tt.tt1 = 0; tt.tt2 = 0; tt.tt3 = 0; tt.tt4 = 0; buffer.Read <TTT>(out tt); tt.tt1 = 0; tt.tt2 = 0; tt.tt3 = 0; tt.tt4 = 0; circularBuffer.Dequeue <TTT>(out tt); Profiler.Fin(); }
public void GenerateMovementOptions() { ToCheck.Clear(); Checked.Clear(); CanMoveTo.Clear(); foreach (Transform node in Grid) { node.GetComponent <Pathnode>().SetMPRequired(1); TileType tileType = node.GetComponent <Tile>().GetTile(); if (tileType == TileType.grass) { node.GetComponent <Pathnode>().SetMPRequired(Grass); } if (tileType == TileType.forest) { node.GetComponent <Pathnode>().SetMPRequired(Forest); } if (tileType == TileType.water) { node.GetComponent <Pathnode>().SetMPRequired(Water); } if (tileType == TileType.hills) { node.GetComponent <Pathnode>().SetMPRequired(Hills); } if (tileType == TileType.castle) { node.GetComponent <Pathnode>().SetMPRequired(Castle); } if (tileType == TileType.sand) { node.GetComponent <Pathnode>().SetMPRequired(Sand); } } //Debug.Log("calculating movement"); CurrentLocation.GetComponent <Pathnode>().MPRemain = MovePoints; ToCheck.Add(CurrentLocation); CanMoveTo.Add(CurrentLocation); FindAvailableTiles(CurrentLocation); foreach (GameObject T in ToCheck.ToArray()) { FindAvailableTiles(T); } foreach (Transform TTT in Grid) { if (CanMoveTo.Contains(TTT.gameObject) == false) { TTT.GetComponent <Pathnode>().Fade(); } } }