1 / 7

AI 人工智慧期末報告 - 坦克遊戲

AI 人工智慧期末報告 - 坦克遊戲. 班級 : 資工四乙 學號 : 498G0054 姓名 : 莊凱向. 遊戲規則. 限時時間內看可以擊倒幾台坦克,擊倒一台會有 100 分,同時也要閃躲 AI 坦克的攻擊, 被擊中遊戲 結束。. AI 介紹. foreach (Tank t in eTanks ) { switch ( t.Direct )//0-- 上 , 1-- 下 , 2-- 左 ,3- - 右 { case 0: // 向上

Download Presentation

AI 人工智慧期末報告 - 坦克遊戲

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. AI人工智慧期末報告-坦克遊戲 班級:資工四乙 學號:498G0054 姓名:莊凱向

  2. 遊戲規則 • 限時時間內看可以擊倒幾台坦克,擊倒一台會有100分,同時也要閃躲AI坦克的攻擊, 被擊中遊戲結束。

  3. AI介紹 • foreach (Tank t in eTanks) • { • switch (t.Direct)//0--上,1--下,2--左,3--右 • { • case 0: //向上 • if (t.Top == 0 || Map[t.Left, t.Top - 1] == 1@ • ||Meet_Tank(t.Left, t.Top - 1))//遇到牆或坦克 • t.newDirect();//坦克轉向 • else • t.Top--; • break; • case 1://向下 • if (t.Top==9 ||Map[t.Left, t.Top + 1] == 1 • || Meet_Tank(t.Left, t.Top + 1))//遇到牆或坦克 • t.newDirect();//坦克轉向 • else • t.Top++; • break;

  4. case 2://向左 • if (t.Left == 0 || Map[t.Left-1, t.Top] == 1 • || Meet_Tank(t.Left-1, t.Top))//遇到牆或坦克 • t.newDirect();//坦克轉向 • else • t.Left--; • break; • case 3://向右 • if (t.Left == 9 || Map[t.Left+1, t.Top ] == 1 • || Meet_Tank(t.Left+1, t.Top))//遇到牆或坦克 • t.newDirect();//坦克轉向 • else • t.Left++; • break; • }

  5. for (inti = 0; i < eTanks.Count; i++)//敵方坦克爆破 • if (eTanks[i] != null) • { • Tank t = (Tank)eTanks[i]; • if (TMap[t.Left, t.Top] == -1) • { • t.Explore(e.Graphics); • eTanks.RemoveAt(i); i--; • TMap[t.Left, t.Top] = 0; • lblX.Text ="("+ t.Left + "," + t.Top + ")坦克被擊中"; • Score += 100; • lblScore.Text = Score.ToString(); • } • }

  6. if (TMap[MyTank.Left, MyTank.Top] == -1)//己方坦克爆破 • { • MyTank.Explore(e.Graphics); • TMap[MyTank.Left, MyTank.Top] = 0; • lblX.Text="遊戲者你被擊中遊戲結束"; • timer1.Enabled = false;//遊戲結束 • } • CheckWin();//檢查是否勝利 • }

  7. DEMO

More Related