91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 11KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-10
  • 語言: 其他
  • 標簽: python語言??

資源簡介

使用A*,a-b剪枝等搜索算法,求解吃豆人的一些簡單問題。

資源截圖

代碼片段和文件信息

#?multiAgents.py
#?--------------
#?Licensing?Information:??You?are?free?to?use?or?extend?these?projects?for
#?educational?purposes?provided?that?(1)?you?do?not?distribute?or?publish
#?solutions?(2)?you?retain?this?notice?and?(3)?you?provide?clear
#?attribution?to?UC?Berkeley?including?a?link?to?http://ai.berkeley.edu.
#?
#?Attribution?Information:?The?Pacman?AI?projects?were?developed?at?UC?Berkeley.
#?The?core?projects?and?autograders?were?primarily?created?by?John?DeNero
#?(denero@cs.berkeley.edu)?and?Dan?Klein?(klein@cs.berkeley.edu).
#?Student?side?autograding?was?added?by?Brad?Miller?Nick?Hay?and
#?Pieter?Abbeel?(pabbeel@cs.berkeley.edu).


from?util?import?manhattanDistance
from?game?import?Directions
import?random?util

from?game?import?Agent

class?ReflexAgent(Agent):
????“““
??????A?reflex?agent?chooses?an?action?at?each?choice?point?by?examining
??????its?alternatives?via?a?state?evaluation?function.

??????The?code?below?is?provided?as?a?guide.??You?are?welcome?to?change
??????it?in?any?way?you?see?fit?so?long?as?you?don‘t?touch?our?method
??????headers.
????“““


????def?getAction(self?gameState):
????????“““
????????You?do?not?need?to?change?this?method?but?you‘re?welcome?to.

????????getAction?chooses?among?the?best?options?according?to?the?evaluation?function.

????????Just?like?in?the?previous?project?getAction?takes?a?GameState?and?returns
????????some?Directions.X?for?some?X?in?the?set?{North?South?West?East?Stop}
????????“““
????????#?Collect?legal?moves?and?successor?states
????????legalMoves?=?gameState.getLegalActions()

????????#?Choose?one?of?the?best?actions
????????scores?=?[self.evaluationFunction(gameState?action)?for?action?in?legalMoves]
????????bestScore?=?max(scores)
????????bestIndices?=?[index?for?index?in?range(len(scores))?if?scores[index]?==?bestScore]
????????chosenIndex?=?random.choice(bestIndices)?#?Pick?randomly?among?the?best

????????“Add?more?of?your?code?here?if?you?want?to“

????????return?legalMoves[chosenIndex]

????def?evaluationFunction(self?currentGameState?action):
????????“““
????????Design?a?better?evaluation?function?here.

????????The?evaluation?function?takes?in?the?current?and?proposed?successor
????????GameStates?(pacman.py)?and?returns?a?number?where?higher?numbers?are?better.

????????The?code?below?extracts?some?useful?information?from?the?state?like?the
????????remaining?food?(newFood)?and?Pacman?position?after?moving?(newPos).
????????newScaredTimes?holds?the?number?of?moves?that?each?ghost?will?remain
????????scared?because?of?Pacman?having?eaten?a?power?pellet.

????????Print?out?these?variables?to?see?what?you‘re?getting?then?combine?them
????????to?create?a?masterful?evaluation?function.
????????“““
????????#?Useful?information?you?can?extract?from?a?GameState?(pacman.py)
????????successorGameState?=?currentGameState.generatePacmanSuccessor(action)
????????newPos?=?successorGameState.getPacmanPosition()
????????newFood?=?successorGameState.getFood()
????????n

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????22973??2017-10-22?13:12??searchAgents.py

?????文件??????12043??2017-10-22?13:13??multiAgents.py

?????文件???????5320??2017-10-22?13:12??search.py

-----------?---------??----------?-----??----

????????????????40336????????????????????3


評論

共有 條評論