- 6
- 0
- 约2.14万字
- 约 10页
- 2023-06-09 发布于河南
- 举报
人工智能实验代码整理--第1页
⼈⼯智能实验代码整理
⼈⼯智能实验代码整理
⽂章⽬录
状态空间表⽰——猴⼦摘⾹蕉
# -*- coding: utf-8 -*-
# State类,记录当前状态
class State :
def __init__ (self, monkey =-1, box=0,banana=1, monbox =-1):
self .monkey = monkey # -1:Monkey at A 0: Monkey at B 1:Monkey at C
self .box = box # -1:box at A 0:box at B 1:box at C
self .banana = banana # Banana at C,Banana=1
self .monbox = monbox # -1: monkey not on the box 1: monkey on the box
# 复制前⼀个状态情况给当前状态,注意不是将对象直接复制,⽽是创建新的对象复制原状态的数据
def copyState (state_i):
state_iplus1 = State ()
state_iplus1 .monkey = state_i .monkey
state_iplus1 .box = state_i .box
state_iplus1 .banana = state_i .banana
state_iplus1 .monbox = state_i .monbox
return state_iplus1
# function monkeygoto,it makes the monkey goto the other place
def monkeygoto (b,i):
a =b
if (a==-1):
States [i+1]=copyState (States[i])
States [i+1].monkey=-1
routesave .insert(i,Monkey go to A )
elif(a==0):
States [i+1]=copyState (States[i])
States [i+1].monkey=0
routesave .insert(i,Monkey go to B )
elif(a==1):
States [i+1]=copyState (States[i])
States [i+1].monkey=1
routesave .insert(i,Monkey go to C )
else :
print(parameter is wrong )
# function movebox,the monkey move the box to the other place
def movebox(a,i):
B = a
if(B==-1):
routesave .insert(i,Monkey move box to A )
States [i+1]=copyState (States[i])
States [i+1].monkey=-1
States [i+1].box=-1
elif(B==0):
routesave .insert(i,Monkey move box to B )
States [i+1]=copyState (States[i])
States [i+1].monkey=0
States [i+1].box=0
elif(B==1):
routesave .insert(i,Monkey move box to C )
States [i+1]=copyState (States[i])
States [i+1].monkey=1
人工智能实验代码整理--第1页
您可能关注的文档
最近下载
- 2026国企领导个人述职述廉报告.docx VIP
- 安全第一车间工作小品剧本《周扒皮》.docx VIP
- 2025年山东省烟台市单招语文测试题库及完整答案1套.docx VIP
- 铁路桥梁施工方案.doc VIP
- 体育社会学第四版卢元镇完整版全套PPT电子课件教案.pptx
- ISO14067-2024:温室气体产品碳足迹量化要求和指南(中文版).pptx VIP
- DLT 5700-2014 城市居住区供配电设施建设规范.docx VIP
- 七年级上册综合实践活动计划及教案七年级综合实践活动教案.docx
- 2025至2030年中国清洁服务行业竞争格局分析及投资战略咨询报告.docx
- 孤独症谱系障碍.ppt VIP
原创力文档

文档评论(0)