Inheritance: MonoBehaviour
コード例 #1
0
    //
    //
    //
    public string GetDeviceInfo()
    {
        string dev;

        //if (PlayerPrefs.HasKey(LoginManager.LOCAL_DEVICE_NO))
        //{
        //    dev = PlayerPrefs.GetString(LoginManager.LOCAL_DEVICE_NO);
        //    return dev;
        //}
        dev = GA.GetDeviceInfo();
        if (dev == null)
        {
            dev = SystemInfo.deviceUniqueIdentifier;
        }
#if UNITY_IPHONE
        //dev =  _GetIDFA();
        if (dev.Length >= 36)
        {
            dev = dev.Substring(0, 36);
        }

        //处理ios 6.0 出现的idfa获取为0的问题
        if (dev == "00000000-0000-0000-0000-000000000000")
        {
            dev = SystemInfo.deviceUniqueIdentifier;
        }
#endif
        //PlayerPrefs.SetString(LoginManager.LOCAL_DEVICE_NO, dev);
        return(dev);
    }
コード例 #2
0
        public void Test2()
        {
            var now = new DateTime(2015, 2, 1);
            StreamTextWriterFactory writerFactory = new StreamTextWriterFactory(new DayLogPathFactory());
            TextLogger logger = new TextLogger(writerFactory, new LogDescriptor());

            writerFactory.NowGetter = () => now;
            logger.Write(new LogItem()
            {
                Time    = now,
                Message = "测试内容。",
                Type    = LogType.Info
            });
            System.Threading.Thread.Sleep(1001);
            var path = GA.FullPath(LogFolder, "2015年02月", "01.log");

            try
            {
                Assert.Equal(now.ToString("HH:mm:ss.ffff") + " [消息] 测试内容。\r\n", GA.IO.ShareReadAllText(path, Encoding.UTF8));
            }
            catch (UnauthorizedAccessException)
            {
                //....
            }
        }
コード例 #3
0
    // use a wind shield prop
    public void UseWindShield()
    {
        if (GetComponent <WindController> ().IsWindMask())        // used one, do nothing
        {
            return;
        }
        if (CurThrowObject == null)         // throwing, do nothing
        {
            return;
        }
        if (GetComponent <GoldController> ().WindShield <= 0)        // 道具不够,显示商店,让玩家购买
        {
            GetComponent <GoldController>().ShowShopCanvas();
            this.PauseGame();
            return;
        }
        GetComponent <WindController> ().ChangeWindMask(true); // wind mask
        GetComponent <GoldController> ().WindShield--;         // change prop num
        var ani = GameCanvas.transform.Find("UIWindSheildButton/-1").gameObject;

        ani.SetActive(true);
        GetComponent <AnimatorScript>().AddRising(ani, 0.5f, 1, new AnimatorDelegate(this.PropsCallback));
        TouchHandler.PlayClickAudio();          // 播放按钮声音

        // umeng
        GA.Use("WindShield", 1, 15);
    }
コード例 #4
0
    // use a basket prop
    public void UseBasket()
    {
        if (CurThrowObject == null || CurThrowObject.tag == "Basket")         // have a basket, do nothing
        {
            return;
        }
        if (GetComponent <GoldController> ().Basket <= 0)        // 道具不够,显示商店,让玩家购买
        {
            GetComponent <GoldController>().ShowShopCanvas();
            this.PauseGame();
            return;
        }
        Destroy(CurThrowObject);                                // destroy current ball
        this.GenerateBasket(Role.transform.position.x + 0.48f); // generate a new basket
        GetComponent <GoldController> ().Basket--;              // change prop num
        var ani = GameCanvas.transform.Find("UIBasketButton/-1").gameObject;

        ani.SetActive(true);
        GetComponent <AnimatorScript>().AddRising(ani, 0.5f, 1, new AnimatorDelegate(this.PropsCallback));
        TouchHandler.PlayClickAudio();                             // 播放按钮声音

        int guide = PlayerPrefs.GetInt(GameConsts.GUIDE_LOCAL, 0); // 需要做新手引导

        if (guide == 0)
        {
            this.ShowGuideTxt(true);
        }

        // umeng
        GA.Use("Basket", 1, 15);
    }
コード例 #5
0
 void Start()
 {
     DontDestroyOnLoad(this.gameObject);
     called = GameObject.Find("GAcarrier").GetComponent <GA> ();         //manggil GA
     //loading text
     starttime = Time.time;
 }
コード例 #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["GoodID"] == null)
         {
             Response.Redirect("GA_GoodExam.aspx");
         }
         else
         {
             string         lGoodID         = Session["GoodID"].ToString();
             GA             Gadmin          = new GA();
             GAController   gadim           = new GAController();
             List <Good>    GoodInfo        = new List <Good>();
             List <ImgInfo> GoodPictureInfo = new List <ImgInfo>();
             GoodInfo                 = gadim.GoodInfo(Gadmin, lGoodID);
             GoodPictureInfo          = gadim.GoodPictureInfo(Gadmin, lGoodID);
             tbxGoodName.Text         = GoodInfo[0].GoodName;
             tbxGoodPrice.Text        = GoodInfo[0].GoodPrice;
             tbxGoodIncontory.Text    = GoodInfo[0].GoodIncentory.ToString();
             tbxGoodSales.Text        = GoodInfo[0].SalesVolume.ToString();
             tbxGoodImgTitle.Text     = GoodPictureInfo[0].ImgTitle;
             tbxGoodImgUrl.Text       = GoodPictureInfo[0].ImgAddress;
             tbxGoodIncontory.Enabled = false;
             tbxGoodSales.Enabled     = false;
         }
     }
 }
コード例 #7
0
        /// <summary>
        /// Call each time a step finished
        /// </summary>
        /// <param name="ga"></param>
        /// <param name="step"></param>
        private void Ga_StepFinish(GA ga, int step)
        {
            if (IsDisposed)
            {
                return;
            }

            //Console.WriteLine("Step " + step);
            Invoke((Action) delegate()
            {
                progressBar1.Value  = 100 * step / ga.Generations;
                label_progress.Text = string.Format("{0}/{1} {2}%", step, ga.Generations, progressBar1.Value);

                // open a preview window show result
                if (optResultsWindow == null || optResultsWindow.IsDisposed)
                {
                    optResultsWindow = new OptimizationResultsWindow();
                    optResultsWindow.OnIndividualSelected   += OptResultsWindow_OnIndividualSelected;
                    optResultsWindow.OnApplyIndividualClick += OptResultsWindow_OnApplyIndividualClick;
                    optResultsWindow.Show();
                }

                optResultsWindow.visualizeNonDominatedSet(ga.NonDominatedSet);
            });
        }
コード例 #8
0
ファイル: BasePage.cs プロジェクト: tukhoi/DocBao
        protected async Task MyOnNavigatedTo()
        {
            try
            {
                if (IsMainPage() &&
                    (AppConfig.AppUpdate == UpdateVersion.NotSet || AppConfig.AppUpdate == UpdateVersion.V1_4) &&
                    !popUpNewVersion.IsOpen)
                {
                    this.IsEnabled           = false;
                    ApplicationBar.IsVisible = false;
                    PopUpNewVersion();
                    popUpNewVersion.IsOpen = true;
                }
            }
            catch (Exception ex)
            {
                GA.LogException(ex);
                ClearPopUpError();
            }

            var updatedFeeds = await _feedManager.LoadAsync();

            if (updatedFeeds != null && updatedFeeds.Count > 0)
            {
                var message = FeedHelper.BuildUpdateStatus(updatedFeeds);
                var count   = updatedFeeds.Count > AppConfig.MAX_NEW_UPDATE_MESSENGER_WAIT
                    ? AppConfig.MAX_NEW_UPDATE_MESSENGER_WAIT
                    : updatedFeeds.Count;

                Messenger.ShowToast(message, miliSecondsUntilHidden: count * 2000);
            }
        }
コード例 #9
0
    // Use this for initialization
    void Start()
    {
//		GA.StartWithAppKeyAndReportPolicyAndChannelId ("5abaee4db27b0a487f000095", Analytics.ReportPolicy.BATCH, "App Store");
        GA.Start();
        GA.StartLevel("02");
        print("我开启了友盟统计");
    }
コード例 #10
0
    private void Start()
    {
        Application.runInBackground = true;
        var sampleArea = GameObject.Find("SampleArea");

        Area = sampleArea == null
            ? Camera.main.rect
            : sampleArea.GetComponent <RectTransform>().rect;

        var generationTextGO = GameObject.Find("CurrentInfo/Background/GenerationText");

        if (generationTextGO != null)
        {
            var fitnessTextGO = GameObject.Find("CurrentInfo/Background/FitnessText");
            m_generationText = generationTextGO.GetComponent <Text>();
            m_fitnessText    = fitnessTextGO.GetComponent <Text>();

            m_previousGenerationText      = GameObject.Find("PreviousInfo/Background/GenerationText").GetComponent <Text>();
            m_previousFitnessText         = GameObject.Find("PreviousInfo/Background/FitnessText").GetComponent <Text>();
            m_previousGenerationText.text = string.Empty;
            m_previousFitnessText.text    = string.Empty;
        }

        if (m_generationText != null)
        {
            m_generationText.text = string.Empty;
            m_fitnessText.text    = string.Empty;
        }

        GA = CreateGA();
        GA.GenerationRan += delegate {
            m_previousBestFitness    = GA.BestChromosome.Fitness.Value;
            m_previousAverageFitness = GA.Population.CurrentGeneration.Chromosomes.Average(c => c.Fitness.Value);
            Debug.Log($"Generation: {GA.GenerationsNumber} - Best: ${m_previousBestFitness} - Average: ${m_previousAverageFitness} - Population : {GA.Population.MaxSize} ");

            if (ChromosomesCleanupEnabled)
            {
                foreach (var c in GA.Population.CurrentGeneration.Chromosomes)
                {
                    c.Fitness = null;
                }
            }
        };
        StartSample();

        m_gaThread = new Thread(() =>
        {
            try
            {
                Thread.Sleep(1000);
                Debug.Log("Starting GA");
                GA.Start();
            }
            catch (Exception ex)
            {
                Debug.LogError($"GA thread error: {ex.Message}");
            }
        });
        m_gaThread.Start();
    }
コード例 #11
0
ファイル: TestCase.cs プロジェクト: qb-lxl/SDKDemo
    // Use this for initialization
    void Start()
    {
        //JSONNode N = new Json


        //N[1] = "Hello world";
        //N[1] = "string";



        //Debug.Log("JSON: " + N.ToString());



        //设置Umeng Appkey

        GA.StartWithAppKeyAndChannelId("551bc899fd98c55326000032", "App Store");



        //调试时开启日志
        GA.SetLogEnabled(true);

        GA.SetLogEncryptEnabled(true);



        GA.ProfileSignIn("fkdafjadklfjdklf");

        GA.ProfileSignIn("jfkdajfdakfj", "app strore");

        print("GA.ProfileSignOff();");

        GA.ProfileSignOff();
    }
コード例 #12
0
        /// <summary>
        /// Main program.
        /// </summary>
        static void Main(string[] args)
        {
            // Get the selected fitness type.
            IFitness myFitness = GetFitnessMethod();

            // Genetic algorithm setup.
            _ga = new GA(_crossoverRate, _mutationRate, 100, 10000000, _genomeSize);

            // Get the target fitness for this method.
            _targetFitness = myFitness.TargetFitness;

            // Run the genetic algorithm and get the best brain.
            string program = GAManager.Run(_ga, fitnessFunction, OnGeneration);

            // Display the final program.
            Console.WriteLine(program);
            Console.WriteLine();

            // Compile to executable.
            BrainPlus.Compile(program, "output.exe", myFitness);

            // Run the result for the user.
            string result = myFitness.RunProgram(program);

            Console.WriteLine(result);

            Console.ReadKey();
        }
コード例 #13
0
	public static void Main()
	{
		//  Crossover		= 80%
		//  Mutation		=  5%
		//  Population size = 100
		//  Generations		= 2000
		//  Genome size		= 2
		GA ga = new GA(0.8,0.05,100,2000,2);
		
		ga.FitnessFunction = new GAFunction(theActualFunction);

		//ga.FitnessFile = @"H:\fitness.csv";
		ga.Elitism = true;
		ga.Go();

		double[] values;
		double fitness;
		ga.GetBest(out values, out fitness);
		System.Console.WriteLine("Best ({0}):", fitness);
		for (int i = 0 ; i < values.Length ; i++)
			System.Console.WriteLine("{0} ", values[i]);
		
		ga.GetWorst(out values, out fitness);
		System.Console.WriteLine("\nWorst ({0}):", fitness);
		for (int i = 0 ; i < values.Length ; i++)
			System.Console.WriteLine("{0} ", values[i]);
		
	}
コード例 #14
0
    void Start()
    {
        GA.Start();

        //调试时开启日志 发布时设置为false
        GA.SetLogEnabled(true);
    }
コード例 #15
0
 public void SetLevel(int level)
 {
     if (FilterPlatform())
     {
         GA.SetUserLevel(level);
     }
 }
コード例 #16
0
 public void SetAccount()
 {
     if (FilterPlatform())
     {
         GA.ProfileSignIn(GA.GetDeviceInfo());
     }
 }
コード例 #17
0
 public void GAPay(double amount, GA.PaySource source, string item)
 {
     if (FilterPlatform())
     {
         GA.Pay(amount, source, item, 1, amount);
     }
 }
コード例 #18
0
ファイル: CPSetup.cs プロジェクト: guthx/ChinskiListonosz
        public void Run()
        {
            if (Graph.IsEulerian())
            {
                Console.WriteLine("Graf jest eulerowski, wiec algorytm genetyczny nie jest potrzebny");
            }
            else
            {
                var latestFitness = int.MinValue;
                GA.GenerationRan += (sender, e) =>
                {
                    var bestInd     = GA.BestChromosome as CPChromosome;
                    var bestFitness = (int)-bestInd.Fitness.Value;

                    if (bestFitness != latestFitness)
                    {
                        latestFitness = bestFitness;
                        Console.WriteLine("Generation {0}: {1}", GA.GenerationsNumber, bestFitness);
                    }
                };
                GA.Start();
                var bestChromosome = GA.BestChromosome as CPChromosome;
                var phenotype      = bestChromosome.GetValues();
                Graph.AddEdgesToGraph(phenotype);
            }

            PrintShortestPath();
        }
コード例 #19
0
ファイル: LinearDiophantine.cs プロジェクト: mykwillis/genX
        public void Run()
        {
            GA Ga;

            Ga = new GA();

            Ga.EncodingType     = EncodingType.Integer;
            Ga.MinIntValue      = -5000;
            Ga.MaxIntValue      = 5000;
            Ga.ChromosomeLength = Coefficients.Length;
            Ga.PopulationSize   = Coefficients.Length * 10;

            Ga.Objective            = new ObjectiveDelegate( this.LinearDiophantineObjective );
            Ga.ObjectiveType        = ObjectiveType.MinimizeObjective;
            Ga.Terminate            += new TerminateEventHandler( new ObjectiveThresholdTerminator(0).Terminate );
            Ga.Terminate            += new TerminateEventHandler( new EvolutionTimeTerminator( new TimeSpan(0,0,20) ).Terminate );
            Ga.NewPopulation        += new NewPopulationEventHandler( OnNewPopulation_ShowSummary );
            Ga.FitnessScaling       = FitnessScaling.LinearRanked;

            Ga.Run();

            Console.WriteLine("Best Individual: (obj={0})", Ga.BestObjective);
            PopulationSummary ps = new PopulationSummary( Ga, Ga.Population );
            Console.WriteLine(ps.BestChromosome);
            Console.WriteLine("Finished.  Hit return.");
            Console.ReadLine();
        }
コード例 #20
0
    public static void Main()
    {
        //  Crossover		= 80%
        //  Mutation		=  5%
        //  Population size = 100
        //  Generations		= 2000
        //  Genome size		= 2
        GA ga = new GA(0.8,0.05,100,2000,2);

        ga.FitnessFunction = new GAFunction(theActualFunction);

        //ga.FitnessFile = @"H:\fitness.csv";
        ga.Elitism = true;
        ga.Go();

        double[] values;
        double fitness;
        ga.GetBest(out values, out fitness);
        System.Console.WriteLine("Best ({0}):", fitness);
        for (int i = 0 ; i < values.Length ; i++)
            System.Console.WriteLine("{0} ", values[i]);

        ga.GetWorst(out values, out fitness);
        System.Console.WriteLine("\nWorst ({0}):", fitness);
        for (int i = 0 ; i < values.Length ; i++)
            System.Console.WriteLine("{0} ", values[i]);
    }
コード例 #21
0
ファイル: FitnessBase.cs プロジェクト: ejjy/AI-Programmer
        protected GA _ga;                                             // Shared genetic algorithm instance

        public FitnessBase(GA ga, int maxIterationCount)
        {
            _ga = ga;
            _maxIterationCount = maxIterationCount;
            Output             = "";
            Program            = "";
        }
コード例 #22
0
    private IList <CheckersMove> GetNewMoves()
    {
        InitializeGA();
        var termination = new GenerationNumberTermination(GA.GenerationsNumber + m_generationNumber);

        GA.Termination = termination;
        Debug.Log("Running GA...");

        if (GA.State == GeneticAlgorithmState.NotStarted)
        {
            GA.Start();
        }
        else
        {
            GA.Resume();
        }


        Debug.Log("Fitness: " + GA.BestChromosome.Fitness);
        Debug.Log("Generations: " + GA.GenerationsNumber);

        if (GA.BestChromosome.Fitness <= 0)
        {
            Debug.LogError("Lower than zero.");
        }

        if (GA.BestChromosome.Fitness == 0)
        {
            HudController.IsGameOver = true;
        }

        return((GA.BestChromosome as CheckersChromosome).Moves);
    }
コード例 #23
0
ファイル: FitnessBase.cs プロジェクト: ipepe/AI-Programmer
        protected GA _ga; // Shared genetic algorithm instance

        public FitnessBase(GA ga, int maxIterationCount)
        {
            _ga = ga;
            _maxIterationCount = maxIterationCount;
            Output = "";
            Program = "";
        }
コード例 #24
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            Good    lGood     = new Good();
            ImgInfo lGoodinfo = new ImgInfo();

            lGood.GoodName       = tbxGoodName.Text;
            lGood.GoodPrice      = tbxGoodPrice.Text;
            lGood.GoodID         = Convert.ToInt32(Session["GoodID"]);
            lGoodinfo.ImgAddress = tbxGoodImgUrl.Text;
            lGoodinfo.ImgTitle   = tbxGoodImgTitle.Text;
            lGoodinfo.GoodID     = Convert.ToInt32(Session["GoodID"]);
            GA           Gadmin = new GA();
            GAController gadmin = new GAController();

            if (tbxGoodImgTitle.Text == "" || tbxGoodImgUrl.Text == "" || tbxGoodName.Text == "" || tbxGoodPrice.Text == "")
            {
                lbShow.Text = "信息不能为空";
            }
            else
            {
                if (gadmin.UpdateGoodinfo(Gadmin, lGoodinfo, lGood))
                {
                    lbShow.Text = "修改成功";
                }
                else
                {
                    lbShow.Text = "修改失败";
                }
            }
        }
コード例 #25
0
ファイル: GA_Request.cs プロジェクト: vincent2421/Game
    public WWW RequestGameInfo(SubmitSuccessHandler successEvent, SubmitErrorHandler errorEvent)
    {
        string game_key = GA.SettingsGA.GameKey;

        string requestInfo = "game_key=" + game_key + "&keys=area%7Cevent_id%7Cbuild";

        requestInfo = requestInfo.Replace(" ", "%20");

        //Get the url with the request type
        string url = GetURL(Requests[RequestType.GA_GetHeatmapGameInfo]);

        url += "/?" + requestInfo;

        WWW www = null;

                #if !UNITY_WP8 && !UNITY_METRO
        //Set the authorization header to contain an MD5 hash of the JSON array string + the private key
        Hashtable headers = new Hashtable();
        headers.Add("Authorization", GA.API.Submit.CreateMD5Hash(requestInfo + GA.SettingsGA.ApiKey));

        //Try to send the data
        www = new WWW(url, new byte[] { 0 }, headers);
                #else
        //Set the authorization header to contain an MD5 hash of the JSON array string + the private key
        Dictionary <string, string> headers = new Dictionary <string, string>();
        headers.Add("Authorization", GA.API.Submit.CreateMD5Hash(requestInfo + GA.SettingsGA.ApiKey));

        //Try to send the data
        www = new WWW(url, new byte[] { 0 }, headers);
                #endif

        GA.RunCoroutine(Request(www, RequestType.GA_GetHeatmapGameInfo, successEvent, errorEvent), () => www.isDone);

        return(www);
    }
コード例 #26
0
        public List <AllocOutput> GetAllocationsGA(AllocInput allocInput)
        {
            List <AllocOutput> allocations = new List <AllocOutput>();

            GA GAlgo = new GA(allocInput.Tasks, allocInput.Processors, allocInput.Coefficients, allocInput.RefFrequency, allocInput.MaxDuration);

            GAlgo.Train();

            Population pop = GAlgo.GetLastGeneration();

            var uniqueCorrectAllocs = GAlgo.GetCorrectAllocs().GroupBy(elem => elem.GetUniqueId()).Select(group => group.First());

            foreach (var alloc in uniqueCorrectAllocs)
            {
                Dictionary <string, List <string> > processors = new Dictionary <string, List <string> >();
                foreach (var proc in alloc.Processors)
                {
                    processors.Add(proc.Value.Id, proc.Value.Tasks);
                }

                AllocOutput allocOutput = new AllocOutput((allocations.Count + 1).ToString(), alloc.ProgramRuntime, alloc.EnergyConsumed, processors);
                allocations.Add(allocOutput);
            }

            return(allocations);
        }
コード例 #27
0
    public void Start()
    {
        random = new Random();

        // Initialize ga instance
        ga = new GA <char>(populationSize, targetString.Length, random, GetRandomCharacter, FitnessFunction, elitism, mutationRate);
    }
コード例 #28
0
ファイル: GA_Queue.cs プロジェクト: Rainermv/Match3Prototype
    /// <summary>
    /// Submit any queued up data immediately. Useful when you want to control when data is submitted.
    /// </summary>
    public static void ForceSubmit()
    {
        GA_SpecialEvents.SubmitAverageFPS();

        //If we have internet connection then add any archived data to the submit queue
        if (GA.SettingsGA.ArchiveData && GA.SettingsGA.InternetConnectivity)
        {
            List <GA_Submit.Item> archivedItems = GA.API.Archive.GetArchivedData();

            if (archivedItems != null && archivedItems.Count > 0)
            {
                foreach (GA_Submit.Item item in archivedItems)
                {
                    GA_Queue.AddItem(item.Parameters, item.Type, false);
                }

                if (GA.SettingsGA.DebugMode)
                {
                    GA.Log("GA: Network connection detected. Adding archived data to next submit queue.");
                }
            }
        }

        //If we have something to submit and we have not stopped submitting completely then we start submitting data
        if (_queue.Count > 0 && !_submittingData && !_endsubmit)
        {
            _submittingData = true;

            GA.Log("GameAnalytics: Queue submit started");

            GA.API.Submit.SubmitQueue(_queue, Submitted, SubmitError, false, string.Empty, string.Empty);
        }
    }
コード例 #29
0
        public static IntPtr GetAncestor(IHandle hwnd, GA flags)
        {
            IntPtr result = GetAncestor(hwnd.Handle, flags);

            GC.KeepAlive(hwnd);
            return(result);
        }
コード例 #30
0
    void Start()
    {
        GA.StartWithAppKeyAndChannelId("59892f08310c9307b60023d0", "umeng");


        GA.SetLogEnabled(Debug.isDebugBuild);
    }
コード例 #31
0
        protected void btnDownPage_Click(object sender, EventArgs e)
        {
            int lCurrentPage = Convert.ToInt32(ViewState["CurrentPage"]);

            for (int i = 0; i < cblistUpdate.Items.Count; i++)//读取CheckBoxList 选中的值,保存起来
            {
                if (cblistUpdate.Items[i].Selected)
                {
                    info[(lCurrentPage * 10) + i] = cblistUpdate.Items[i].Value;
                }
            }
            lCurrentPage++;
            if (lCurrentPage + 1 == Convert.ToInt32(ViewState["PageCount"]))
            {
                btnDownPage.Enabled = false;
            }
            GA           Gadmin         = new GA();
            GAController gadmin         = new GAController();
            FirstClassDm firstClassName = new FirstClassDm();

            firstClassName.FirstClassDmName = "服装";
            string         lfirstClassDmID = Gadmin.FcNameGetID(firstClassName);
            List <ImgInfo> Furniture       = new List <ImgInfo>();

            Furniture = gadmin.HomeNextPage(Gadmin, lCurrentPage);
            cblistUpdate.DataSource     = Furniture;
            cblistUpdate.DataTextField  = "ImgTitle";
            cblistUpdate.DataValueField = "GoodID";
            cblistUpdate.DataBind();
            dlistPictureShow.DataSource = Furniture;
            dlistPictureShow.DataBind();
            btnUpPage.Enabled        = true;
            ViewState["CurrentPage"] = lCurrentPage;
            lbPage.Text = "第" + (lCurrentPage + 1) + "页/共 " + ViewState["PageCount"].ToString() + "页";
        }
コード例 #32
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            int lCurrentPage = Convert.ToInt32(ViewState["CurrentPage"]);

            for (int i = 0; i < cblistUpdate.Items.Count; i++)//读取CheckBoxList 选中的值,保存起来
            {
                if (cblistUpdate.Items[i].Selected)
                {
                    info[(lCurrentPage * 10) + i] = cblistUpdate.Items[i].Value;
                }
            }
            GA           Gadmin = new GA();
            GAController gadmin = new GAController();

            if (gadmin.UpdateInterface(Gadmin, info, 1))
            {
                lbPrompt.Text = "修改成功";
            }
            if (gadmin.UpdatePictureShow(Gadmin, 1).Count > 1)
            {
                drpdownlist.DataSource     = gadmin.UpdatePictureShow(Gadmin, 1);
                drpdownlist.DataTextField  = "ImgTitle";
                drpdownlist.DataValueField = "GoodID";
                drpdownlist.DataBind();
                drpdownlist.Items.Insert(0, new ListItem("请选择替换商品"));
            }
        }
コード例 #33
0
ファイル: Form1.cs プロジェクト: rustynoob/GA
        private void button2_Click(object sender, EventArgs e)
        {
            if (seed == null) return;
            int sampleSize = (int)SampSize.Value;
            int mutate = (int)MapDivrg.Value;
            List<List<List<Stat>>> stats = new List<List<List<Stat>>>();
            for (int j = 0; j < sampleSize; j++)
            {
                stats.Add(new List<List<Stat>>());
                for (int i = 0; i < mutate; i++)
                {
                    Population pop = new Population(seed);
                    landscape map = new landscape(seed.home);
                    map.mutate(i + 1);
                    pop.setLandscape(map);
                    GA tempGA = new GA(pop);
                    stats[j].Add(tempGA.evolve());
                }
            }
            string output = "";

            for (int i = 0; i < stats[0].Count; i++){

                for (int j = 0; j < sampleSize; j++)
                {
                    output += stats[j][i].Count + ",";
                }
                output += Environment.NewLine;
            }
            fit.Text = output;
        }
コード例 #34
0
 public LogicalXorFitness(GA ga, int maxIterationCount, string appendFunctions = null)
     : base(ga, maxIterationCount, appendFunctions)
 {
     if (_targetFitness == 0)
     {
         _targetFitness = _trainingResults.Length * 256;
     }
 }
コード例 #35
0
 public LogicalXorFitness(GA ga, int maxIterationCount, string appendFunctions = null)
     : base(ga, maxIterationCount, appendFunctions)
 {
     if (_targetFitness == 0)
     {
         _targetFitness = _trainingResults.Length * 256;
     }
 }
コード例 #36
0
ファイル: MultiplyFitness.cs プロジェクト: ejjy/AI-Programmer
 public MultiplyFitness(GA ga, int maxIterationCount, int maxTrainingCount = 4)
     : base(ga, maxIterationCount)
 {
     _trainingCount = maxTrainingCount;
     if (_targetFitness == 0)
     {
         _targetFitness = _trainingCount * 256;
     }
 }
コード例 #37
0
 public StringOptimizedFitness(GA ga, int maxIterationCount, string targetString)
     : base(ga, maxIterationCount)
 {
     _targetString = targetString;
     if (_targetFitness == 0)
     {
         _targetFitness = _targetString.Length * 256;
     }
 }
コード例 #38
0
 public LessThanEqualToFitness(GA ga, int maxIterationCount, int maxTrainingCount = 5)
     : base(ga, maxIterationCount)
 {
     _trainingCount = maxTrainingCount;
     if (_targetFitness == 0)
     {
         _targetFitness = _trainingCount * 256;
     }
 }
コード例 #39
0
 public AddToCharFitness(GA ga, int maxIterationCount, int maxTrainingCount = 5)
     : base(ga, maxIterationCount)
 {
     _trainingCount = maxTrainingCount;
     if (_targetFitness == 0)
     {
         _targetFitness = _trainingCount * 256;
     }
 }
コード例 #40
0
 public TimesThreeFitness(GA ga, int maxIterationCount, int maxTrainingCount = 3, string appendFunctions = null)
     : base(ga, maxIterationCount, appendFunctions)
 {
     _trainingCount = maxTrainingCount;
     if (_targetFitness == 0)
     {
         _targetFitness = _trainingCount * 256;
         _functionCount = CommonManager.GetFunctionCount(appendFunctions);
     }
 }
コード例 #41
0
	private void Test() {
		var e = new UserEvent ();
		var ga = new GA ();
		ga.GOID = "tank1";
		e.sponsorId = "0";
		e.targetIdList = World.GetInstance ().GetAllGOIds ();
		e.type = UserEvent.EventType.GA;
		e.rawContent = ga as object;
		base.BroadCastEvent (e);
	}
コード例 #42
0
        public StringStrictFitness(GA ga, int maxIterationCount, string targetString, string appendFunctions = null)
            : base(ga, maxIterationCount, appendFunctions)
        {
            _targetString = targetString;

            if (_targetFitness == 0)
            {
                _targetFitness = _targetString.Length * 256;
                _targetFitness += 10;
            }
        }
コード例 #43
0
ファイル: Driver.cs プロジェクト: windr00/TestClient
	void Test() {
		var e = new UserEvent ();
		var ga = new GA ();
		ga.AssetName = "cube";
		ga.GOID = "cube1";
		e.rawContent = ga as object;
		e.sponsorId = "0";
		e.targetIdList = World.GetInstance ().GetAllGOIds ();
		e.type = UserEvent.EventType.GA;
		EventCollection.OnEventTrigger (e);
	}
コード例 #44
0
 public ReverseStringFitness(GA ga, int maxIterationCount, int maxTrainingCount = 5)
     : base(ga, maxIterationCount)
 {
     _trainingCount = maxTrainingCount;
     if (_targetFitness == 0)
     {
         for (int i=0; i<_trainingCount; i++)
         {
             _targetFitness += (i + 1) * 256;
         }
     }
 }
コード例 #45
0
        public FibonacciFitness(GA ga, int maxIterationCount, int maxDigits = 4, int maxTrainingCount = 3, string appendFunctions = null)
            : base(ga, maxIterationCount, appendFunctions)
        {
            _maxDigits = maxDigits;
            _trainingCount = maxTrainingCount;

            if (_targetFitness == 0)
            {
                _targetFitness = _trainingCount * 256 * _maxDigits;
                _functionCount = CommonManager.GetFunctionCount(appendFunctions);
            }
        }
コード例 #46
0
 public BottlesOfBeerFitness(GA ga, int maxIterationCount, string appendFunctions = null)
     : base(ga, maxIterationCount, appendFunctions)
 {
     if (_targetFitness == 0)
     {
         // Number of numeric values in training example * 256 + number of characters in target string * 256 * number of numeric values (since string is next to each number).
         foreach (byte[] trainingExample in _trainingExamples)
         {
             _targetFitness += (trainingExample.Length * 256) + (_targetString.Length * 256 * trainingExample.Length);
         }
     }
 }
コード例 #47
0
ファイル: IfThenFitness.cs プロジェクト: ipepe/AI-Programmer
 public IfThenFitness(GA ga, int maxIterationCount, int maxTrainingCount = 3)
     : base(ga, maxIterationCount)
 {
     _trainingCount = maxTrainingCount;
     if (_targetFitness == 0)
     {
         for (int i = 0; i < maxTrainingCount; i++)
         {
             _targetFitness += 256 * _trainingStrings[i].Length;
         }
     }
 }
コード例 #48
0
 public HelloUserFitness(GA ga, int maxIterationCount, string targetString, int maxTrainingCount = 4)
     : base(ga, maxIterationCount)
 {
     _targetString = targetString;
     _trainingCount = maxTrainingCount;
     if (_targetFitness == 0)
     {
         for (int i=0; i<_trainingCount; i++)
         {
             _targetFitness += (_targetString.Length + (i + 1)) * 256;
         }
     }
 }
コード例 #49
0
 public CountDownFitness(GA ga, int maxIterationCount, int startingNumber)
     : base(ga, maxIterationCount)
 {
     _startingNumber = startingNumber;
     if (_targetFitness == 0)
     {
         for (int i = 1; i <= startingNumber; i++)
         {
             _targetFitness += 256 * (i.ToString().Length + 1); // +1 for newline
             _targetFitness += i.ToString().Length + 1; // match length
         }
     }
 }
コード例 #50
0
        public GuidingFunctionFitness(GA ga, int maxIterationCount, string appendFunctions = null)
            : base(ga, maxIterationCount, appendFunctions)
        {
            if (_targetFitness == 0)
            {
                for (int i = 0; i < _trainingExamples.Length; i++)
                {
                    _trainingResults[i] = _trainingExamples[i].Replace(">", "").Replace("<", "");

                    _targetFitness += _trainingResults[i].Length * 256;
                    _targetFitness += 10; // length fitness
                }
            }
        }
コード例 #51
0
        public CountdownFitness(GA ga, int maxIterationCount, int maxTrainingCount = 4)
            : base(ga, maxIterationCount)
        {
            _trainingCount = maxTrainingCount;

            if (_targetFitness == 0)
            {
                // A * 256 => A = Number of numeric values in training example, 256 = 256 characters per byte.
                _targetFitness += 6 * 256;
                _targetFitness += 4 * 256;
                _targetFitness += 3 * 256;
                _targetFitness += 7 * 256;
            }
        }
コード例 #52
0
ファイル: Form1.cs プロジェクト: rustynoob/GA
        private void run_Click_1(object sender, EventArgs e)
        {
            int time;

            landscape env = new landscape((int)CityCount.Value);
            Population pop = new Population((int)setPopSize.Value, env);
            ga = new GA(pop);

            ga.mutationFactor = (int)setMutFact.Value;

            seed = ga.pop;
            time = ga.evolve().Count;
            fit.Text = "" + time +'\n';
        }
コード例 #53
0
        public NumberGuessFitness(GA ga, int maxIterationCount, int maxTrainingCount = 1)
            : base(ga, maxIterationCount)
        {
            _trainingCount = maxTrainingCount;
            if (_targetFitness == 0)
            {
                for (int i = 0; i < maxTrainingCount; i++)
                {
                    _targetFitness += _trainingLength * 256;
                }

                //_targetFitness += 7 * 256; // ou Win! (minus the Y which is already accounted for in the above loop).
            }
        }
コード例 #54
0
        public XmlToJsonFitness(GA ga, int maxIterationCount, string appendFunctions = null)
            : base(ga, maxIterationCount, appendFunctions)
        {
            if (_targetFitness == 0)
            {
                for (int i = 0; i < _trainingExamples.Length; i++)
                {
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(_trainingExamples[i]);
                    string json = JsonConvert.SerializeXmlNode(doc);

                    _trainingResults[i] = json;
                    _targetFitness += json.Length * 256;
                }
            }
        }
コード例 #55
0
ファイル: Form1.cs プロジェクト: engaugusto/AG_ExercExtra
        private void button1_Click(object sender, EventArgs e)
        {
            lblStatus.Text = "Procurando melhor solução...";
            Application.DoEvents();

            // Instancianto GA
            GA ga = new GA(
                Convert.ToInt32(txtTipoA.Text),
                Convert.ToInt32(txtTipoB.Text),
                Convert.ToInt32(txtTipoC.Text)
                );

            // Chamando a função que desenha as cargas
            pictureBox1.Image = GUI.DesenhaCarga(ga.FindSolution());
            lblStatus.Text = "Melhor solução encontrada.";
        }
コード例 #56
0
        public CsvSplitFitness(GA ga, int maxIterationCount, int length, string appendFunctions = null)
            : base(ga, maxIterationCount, appendFunctions)
        {
            _length = length;

            if (_targetFitness == 0)
            {
                for (int i = 0; i < _trainingExamples.Length; i++)
                {
                    string csvString = string.Join(",", SplitInParts(_trainingExamples[i], _length));

                    _trainingResults[i] = csvString;
                    _targetFitness += csvString.Length * 256;
                }
            }
        }
コード例 #57
0
ファイル: World.cs プロジェクト: kylchien/Smart-Fish
        public World(ref Canvas aCanvas)
        {
            mCanvas = aCanvas;
            worldView = new WorldView();

            createFishes();
            createBaits();

            int numGenes = mFishes[0].Brain.GetWeights().Count;

            mGA= new GA(Config.NumFishes, numGenes,
                        Config.NumElites,
                        Config.MutationRate,Config.CrossoverRate, Config.Perturbation);

            //mCanvas.Children.Add(worldView);
            mCanvas.Children.Insert(0, worldView);
        }
コード例 #58
0
ファイル: Program.cs プロジェクト: ipepe/AI-Programmer
        /// <summary>
        /// Event handler that is called upon each generation. We use this opportunity to display some status info and save the current genetic algorithm in case of crashes etc.
        /// </summary>
        private static void OnGeneration(GA ga)
        {
            if (_bestStatus.Iteration++ > 1000)
            {
                _bestStatus.Iteration = 0;
                Console.WriteLine("Best Fitness: " + _bestStatus.TrueFitness + "/" + _targetParams.TargetFitness + " " + Math.Round(_bestStatus.TrueFitness / _targetParams.TargetFitness * 100, 2) + "%, Ticks: " + _bestStatus.Ticks + ", Running: " + Math.Round((DateTime.Now - _startTime).TotalMinutes) + "m, Size: " + _genomeSize + ", Best Output: " + _bestStatus.Output + ", Changed: " + _bestStatus.LastChangeDate.ToString() + ", Program: " + _bestStatus.Program);
                
                ga.Save("my-genetic-algorithm.dat");
            }

            if (_expandAmount > 0 && ga.GAParams.CurrentGeneration > 0 && ga.GAParams.CurrentGeneration % _expandRate == 0 && _genomeSize < _maxGenomeSize)
            {
                _genomeSize += _expandAmount;
                ga.GAParams.GenomeSize = _genomeSize;

                _bestStatus.Fitness = 0; // Update display of best program, since genome has changed and we have a better/worse new best fitness.
            }
        }
コード例 #59
0
ファイル: SimpleBinary.cs プロジェクト: mykwillis/genX
		static void Main()
		{
            //
            // Create the genetic algorithm component, and set the required 
            // properties.
            //
            GA ga = new GA();
         
            ga.EncodingType     = EncodingType.Binary;
            ga.ChromosomeLength = 10;
            ga.PopulationSize   = 50;
            ga.MaxGenerations   = 10;


            //
            // Set the objective function for the run, which provides feedback
            // to the algorithm as to the relative merit of candidate solutions.
            //
            ga.Objective = new ObjectiveDelegate( BinaryAlternateObjective );

            
            //
            // Set a "NewPopulation" event handler so that we get a callback on
            // each new generation.  During the callback, we print out the
            // generation's statistics and the best chromosome found so far.
            //
            ga.NewPopulation += new NewPopulationEventHandler( OnNewPopulation_ShowSummary );

            
            //
            // Run the algorithm.  It will stop after ga.MaxGenerations have elapsed.
            //
            ga.Run();


            //
            // Output the best individual that was found during the run.
            //
            Console.WriteLine("Best Individual:");
            PopulationSummary ps = new PopulationSummary( ga, ga.Population );
            Console.WriteLine(ps.BestChromosome);
            Console.WriteLine("Finished.  Hit return.");
            Console.ReadLine();
		}
コード例 #60
0
ファイル: IntegerMaximization.cs プロジェクト: mykwillis/genX
		static void Main()
		{
            //
            // Describe the coding of our problem as an array of 10 integers
            // in the range [-10,10].
            // 
            GA ga = new GA();

            ga.ChromosomeLength = 10;
            ga.PopulationSize   = 100;
            ga.MaxGenerations   = 100;

            ga.EncodingType     = EncodingType.Integer;
            ga.MinIntValue      = -10;
            ga.MaxIntValue      = 10;            

            ga.Objective        = new ObjectiveDelegate( IntegerMaximizationObjective );
            ga.MutationOperator = MutationOperator.GeneSpecific;
         
            //
            // Set a "NewPopulation" event handler so that we get a callback on
            // each new generation.  During the callback, we print out the
            // generation's statistics and the best chromosome found so far.
            //
            ga.NewPopulation += new NewPopulationEventHandler( OnNewPopulation_ShowSummary );

   
            //
            // Let it run until default termination criteria are met, or
            // MaxGenerations has elapsed.
            //
            ga.Run();


            //
            // Output the best individual that was found during the run.
            //
            Console.WriteLine("Best Individual:");
            PopulationSummary ps = new PopulationSummary( ga, ga.Population );
            Console.WriteLine( ps.BestChromosome );
            Console.WriteLine("Finished.  Hit return.");
            Console.ReadLine();
		}