資源簡介
學習委托過程中寫的小程序。利用了多線程和鼠標鉤子。
模擬重力等。隨機產生小球會不斷的攻擊你的鼠標。 每個小球會思考并決定下一步動作,有一定智能性。
模擬重力等。隨機產生小球會不斷的攻擊你的鼠標。 每個小球會思考并決定下一步動作,有一定智能性。
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Threading;
using?System.Windows.Forms;
namespace?Replicator
{
????public?partial?class?frmResult?:?Form
????{
????????private?string?mstrState?=?““;
????????public?frmResult()
????????{
????????????InitializeComponent();
????????????this.lblLife.Text?=?string.Empty.PadLeft(10?fullLife);
????????????this.lblScore.Text?=?“0“;
????????????//this.lblStatus.Text?=?““;
????????}
????????private?const?int?fullLifeValue?=?10;
????????private?const?char?fullLife?=?‘◆‘;
????????private?const?char?emptyLife?=?‘◇‘;
????????private?const?float?score_01?=?2f;
????????private?const?float?score_02?=?5f;
????????private?const?float?score_03?=?10f;
????????public?void?SetResult(string?strState)
????????{
????????????mstrState?=?strState;
????????????switch?(strState)
????????????{
????????????????//case?“Idle“:
????????????????//????this.lblStatus.Text?=?“休息會,zzz~~~“;
????????????????//????break;
????????????????//case?“FollowingA“:
????????????????//????this.lblStatus.Text?=?“這樣可不得分的噢?!?
????????????????//????break;
????????????????//case?“FollowingB“:
????????????????//????this.lblStatus.Text?=?“嘿嘿,看到你咯!“;
????????????????//????break;
????????????????//case?“Attacking“:
????????????????//????this.lblStatus.Text?=?“來追你了噢~被逮著你就死定啦!“;
????????????????//????break;
????????????????//case?“CursorCatched“:
????????????????//????this.lblStatus.Text?=?“真可憐,你被逮住了,快甩掉它!“;
????????????????//????break;
????????????????//case?“Wait“:
????????????????//????break;
????????????????//default:
????????????????//????break;
????????????}
????????}
????????///?
????????///?Called?when?the?form?is?shown
????????///?Starts?the?robot?thread
????????///?
????????///?-
????????///?
????????private?void?frmResult_Shown(object?sender?EventArgs?e)
????????{
????????????//Start?our?acting?thread
????????????Thread?a?=?new?Thread(Loop);
????????????a.Start();
????????}
????????///?
????????///?The?Mainloop?of?the?robot
????????///?Calls?Act()?and?Think()
????????///?
????????public?void?Loop()
????????{
????????????Thread.Sleep(20);
????????}
????????private?void?frmResult_Load(object?sender?EventArgs?e)
????????{
????????????this.TimeClock.Interval?=?1000;
????????????this.TimeClock.Start();
????????}
????????private?void?TimeClock_Tick(object?sender?EventArgs?e)
????????{
????????????switch?(mstrState?)
????????????{
????????????????case?“Idle“:
????????????????????//this.lblBBB.Text?=?“太遠啦,膽小鬼,扣你?“?+?score_02.ToString()?+?“分“;
????????????????????this.lblScore.Text?=?Math.Round((float.Parse(this.lblScore.Text)?-?score_02)?2).ToString();
????????????????????break;
????????????????case?“FollowingA“:
????????????????????//this.lblBBB.Text?=?“膽小鬼,扣你?“?+?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????113??2008-09-02?13:21??obj\AutoBall.csproj.FileList.txt
?????文件???????5612??2008-09-01?11:21??Properties\Resources.resx
?????文件????????249??2008-09-01?11:21??Properties\Settings.settings
?????文件???????1182??2008-09-01?11:21??Properties\AssemblyInfo.cs
?????文件???????2870??2008-09-01?11:21??Properties\Resources.Designer.cs
?????文件???????1091??2008-09-01?11:21??Properties\Settings.Designer.cs
?????文件????????655??2008-09-01?11:37??Properties\app.manifest
?????文件???????4851??2008-09-02?13:20??AutoBall.csproj
?????文件????????617??2008-09-01?15:11??AutoBall.csproj.user
?????文件???????4564??2008-09-02?13:08??frmResult.cs
?????文件???????5597??2008-09-02?13:08??frmResult.Designer.cs
?????文件???????6011??2008-09-02?13:08??frmResult.resx
?????文件???????1279??2008-09-01?16:38??Program.cs
?????文件??????12169??2008-09-01?11:22??Robot.cs
?????文件???????2522??2008-09-01?11:22??Robot.Designer.cs
?????目錄??????????0??2008-09-01?11:21??obj\Debug\TempPE
?????目錄??????????0??2008-09-01?11:22??obj\Debug\Refactor
?????目錄??????????0??2008-09-01?11:21??obj\Debug
?????目錄??????????0??2008-09-01?11:21??bin\Debug
?????目錄??????????0??2008-09-01?11:21??obj
?????目錄??????????0??2008-09-01?11:21??Properties
?????目錄??????????0??2008-09-01?11:21??bin
-----------?---------??----------?-----??----
????????????????49382????????????????????22
- 上一篇:馬爾可夫模型源碼
- 下一篇:CAN Linux驅動代碼
評論
共有 條評論