Beispiel #1
0
		public void Make( ChainModel target, Game game, int chainLimit ){
			ModelBlock[][] model = target.Model;
			int x = 0, y = game.GetFloorHeight(), dir = 1, chain = 0, bottom = y;
			target.Bottom = y;
			Pattern p;
			IDCount = 0;
			
			//目標形を用意する。
			SetPattern( model, p = Tail, chain, x, y, dir );
			while( true ){
				x 		+= p.NextX * dir;
				dir 	*= p.NextDir;
				chain 	+= p.Chain;
				y 		+= p.NextY;
				var j	= (dir > 0 || JointLeft == null) ? Joint : JointLeft;
				int nx = x + dir * (j.Width - 1);
				if( chain >= chainLimit ) break;
				if( (dir < 0 && nx <= Wall) || (dir > 0 && Game.Width - 1 <= nx) ){
						SetPattern( model, p = j, chain, x, y, dir );
				}else 	SetPattern( model, p = Body, chain, x, y, dir );
			}
			
			SetPattern( model, p = Head, chain, x, y, dir );
			chain 	+= p.Chain;
			SetupModel( model, game, target.Bottom );
			
			target.ChainLimit 	= chain;
		}
Beispiel #2
0
        private void _btnGiveUp_ButtonPressEvent(object o, ButtonPressEventArgs args)
        {
            var dialog = new Dialog("Закончить игру?", Program.mv, DialogFlags.Modal);

            dialog.AddButton("Да", ResponseType.Yes).ButtonReleaseEvent += new ButtonReleaseEventHandler((obj, e) =>
            {
                if (ClientManager == null)
                {
                    Game.GiveUpPlayer(Game.CurrentPlayer);
                }
                else
                {
                    ClientManager.Server.GiveUp();
                }
                dialog.Destroy();
            });
            dialog.AddButton("Нет", ResponseType.No).ButtonReleaseEvent += new ButtonReleaseEventHandler((obj, e) =>
            {
                dialog.Destroy();
            });
            //dialog.ShowNow();
            var t = dialog.Run();

            System.Diagnostics.Debug.WriteLine(t);
        }
Beispiel #3
0
		///複製を作る。
		public Game Clone(){
			var clone = new Game();
			clone.Score			= Score;
			clone.MaxChain		= MaxChain;
			clone.CurrentStep	= CurrentStep;
			clone.GameOver		= GameOver;
			
			HeightList.CopyTo( clone.HeightList, 0 );
			
			for(int x = 0; x < Width; x++ )	Field[x].CopyTo( clone.Field[x], 0 );
			
			return clone;
		}
Beispiel #4
0
		public static void Main(string[] args){
			//動作確認用
			//Game.Init( new StreamReader( "../../../../sample2012/sample_input.txt" ) );
			
			Game.Init( Console.In );
			Game game = new Game();
			
			//Sサイズ用AI
			//GameAI AI = new CombinedAI( game, Config.SmallAIList );
			
			//Mサイズ用AI
			//GameAI AI = new CombinedAI( game, Config.MediumAIList );
			
			//Lサイズ用AI
			GameAI AI = new AdvancedAI( game, Config.LargeAIList[0] );
			
			
			while( !game.GameOver && game.CurrentStep < Game.StepNum ){
				AI.Next();
				Console.Write( AI.LastPos + " " + AI.LastRot + "\n" );
			}
		}
Beispiel #5
0
		//足場の保存期間を指定、ブロックの空きを埋める。
		public void SetupModel( ModelBlock[][] model, Game game, int bottom ){
			for( int i = 0, w = model.Length; i < w; i++ ){
				int min = int.MaxValue;
				for( int j = model[i].Length - 1; j >= 0; j--){
					if( model[i][j] == null ){
						if( j < bottom && game.Field[i][j] > Game.Sum )	
							model[i][j] = new ModelBlock(IDCount++, i, j, -1, min, false, 1, game.Field[i][j] );
						else								
							model[i][j] = new ModelBlock(IDCount++, i, j, -1, min);
					
						continue;
					}
					var block = model[i][j];
					if( block.Chain >= 0 )				if( min > block.Chain ) min = block.Chain;
					if( block.Ground == int.MaxValue ) 	block.Ground = min;
				}
			}
		}