SlideShare a Scribd company logo
1 of 9
Download to read offline
PROGRAM IMPLEMENTATION AND TESTING - COMMENTED CODE 
#To import the tkinter GUI and methods 
From Tkinter import * 
Import time 
Import random 
#To set up the GUI called window 
window = Tk() 
window.title("Robot Arena") 
#To set up the arena for the robot 
canvas = Canvas(window, width= 500,height= 400,bg='white') 
canvas.pack() 
#To define the light colour 
def lightcolour(): 
canvas.itemconfig(traffic_light, fill="red", outline="red") 
canvas.update() 
time.sleep(2) 
canvas.itemconfig(traffic_light,fill="green",outline="green") 
canvas.update() 
def left(): 
x1,y1,x2,y2=canvas.coords(robot1) 
canvas.coords(robot1,x1‐vx,y1,x2‐vx,y2) 
canvas.update() 
time.sleep(.1) 
def right(): 
x1,y1,x2,y2=canvas.coords(robot1) 
canvas.coords(robot1,x1+vx,y1,x2+vx,y2) 
canvas.update() 
time.sleep(.1) 
def down(): 
x1,y1,x2,y2=canvas.coords(robot1) 
canvas.coords(robot1,x1,y1+vy,x2,y2+vy)
canvas.update() 
time.sleep(.1) 
def up(): 
x1,y1,x2,y2=canvas.coords(robot1) 
canvas.coords(robot1,x1,y1‐vy,x2,y2‐vy) 
canvas.update() 
time.sleep(.1) 
def downleft(): 
x1,y1,x2,y2=canvas.coords(robot1) 
canvas.coords(robot1,x1‐vx,y1+vy,x2‐vx,y2+vy) 
canvas.update() 
time.sleep(.1) 
def downright(): 
x1,y1,x2,y2=canvas.coords(robot1) 
canvas.coords(robot1,x1+vx,y1+vy,x2+vx,y2+vy) 
canvas.update() 
time.sleep(.1) 
def upleft(): 
x1,y1,x2,y2=canvas.coords(robot1) 
canvas.coords(robot1,x1‐vx,y1‐vy,x2‐vx,y2‐vy) 
canvas.update() 
time.sleep(.1) 
def upright(): 
x1,y1,x2,y2=canvas.coords(robot1) 
canvas.coords(robot1,x1+vx,y1‐vy,x2+vx,y2‐vy) 
canvas.update() 
time.sleep(.1) 
#The obstacle course with all the shapes 
rectangle1 = canvas.create_rectangle(275,30,335,95,fill= "cyan",outline="cyan") 
rectangle2 = canvas.create_rectangle(115,290,200,380,fill= "cyan",outline="cyan")
diamond1 = canvas.create_polygon(120,185,155,150,190,185,155,225,fill= "cyan",outline="cyan") 
triangle1 = canvas.create_polygon(225,335,285,275,305,360,fill="cyan",outline="cyan") 
triangle2 = 
canvas.create_polygon(40,70,115,25,110,120,fill="cyan",outline="cyan") 
triangle3 = 
canvas.create_polygon(425,65,470,50,460,100,fill="cyan",outline="cyan") 
hexagon1 = 
canvas.create_polygon(430,250,415,225,430,200,450,200,465,225,450,250,fill="cyan",outline="cyan") 
hexagon2 = 
canvas.create_polygon(200,120,175,110,170,80,190,60,215,70,220,100,fill="cyan",outline="cyan") 
pentagon1 = 
canvas.create_polygon(365,225,315,200,315,140,370,120,400,170,fill="cyan",outline="cyan") 
circle1=canvas.create_oval(‐20,205,60,290, fill="cyan", outline="cyan") 
circle2=canvas.create_oval(370,275,600,500,fill="cyan", 
outline="cyan") 
circle3=canvas.create_oval(250,25,140,‐50,fill="cyan", outline="cyan") 
# Traffic Light 
traffic_light=canvas.create_oval(220,200,270,250,fill="cyan",outline="cyan") 
vx= 7.0 # x velocity 
vy= 7.0 # y velocity
# Robot 
robot1=canvas.create_oval(10,385,25,370, fill='purple', outline='purple') 
x=random.randrange(1,4) # Generates a random number to determine a route 
if x==1: 
# Start of loop for Route 1 
lightcolour() 
for t in range(1,5): 
for t in range(1,3): 
downright() 
for t in range(1,46): 
right() 
for t in range(1,20): 
up() 
lightcolour() 
for t in range(1,20): 
upleft() 
for t in range(1,5): 
downleft() 
for t in range(1,8): 
upleft() 
for t in range(1,3): 
down() 
for t in range(1,10): 
downleft()
for t in range(1,8): 
downright() 
lightcolour() 
for t in range(1,8): 
downleft() 
for t in range(1,8): 
down() 
lightcolour() 
for t in range(1,9): 
downleft() 
for t in range(1,2): 
x1,y1,x2,y2=canvas.coords(robot1) 
canvas.coords(robot1,10,385,25,370) 
canvas.update() 
time.sleep(.1) 
# End of loop for Route 1 
If x==2: 
lightcolour() 
# Start of loop for Route 2 
for t in range(1,5): 
for t in range(1,12): 
up() 
for t in range(1,10): 
right()
for t in range(1,10): 
upright() 
lightcolour() 
for t in range(1,5): 
right() 
for t in range(1,20): 
upright() 
for t in range(1,22): 
down() 
lightcolour() 
for t in range(1,8): 
right() 
for t in range(1,20): 
down() 
for t in range(1,21): 
left() 
for t in range(1,18): 
up() 
lightcolour() 
for t in range(1,18): 
left() 
for t in range(1,12): 
downleft() 
for t in range(1,6):
down() 
lightcolour() 
for t in range(1,2): 
x1,y1,x2,y2=canvas.coords(robot1) 
canvas.coords(robot1,10,385,25,370) 
canvas.update() 
time.sleep(.1) 
# End of loop for Route 2 
If x==3: 
lightcolour() 
# Start of loop for Route 3 
for t in range(1,5): 
for t in range(1,10): 
upright() 
for t in range(1,20): 
up() 
for t in range(1,10): 
upright() 
for t in range(1,12): 
downright() 
for t in range(1,12): 
downleft() 
lightcolour() 
for t in range(1,16):
right() 
for t in range(1,8): 
upright() 
for t in range(1,12): 
upleft() 
for t in range(1,6): 
down() 
lightcolour() 
for t in range(1,8): 
downleft() 
for t in range(1,10): 
downright() 
for t in range(1,10): 
upright() 
for t in range(1,12): 
downright() 
lightcolour() 
for t in range(1,13): 
downleft() 
for t in range(1,38): 
left() 
for t in range(1,3): 
upleft() 
for t in range(1,2): 
x1,y1,x2,y2=canvas.coords(robot1)
canvas.coords(robot1,10,385,25,370) 
canvas.update() 
time.sleep(.1) 
# End of loop for Route 3 
#To complete the GUI 
window.mainloop() 
SCREENSHOT OF OUTPUT

More Related Content

What's hot

Convolutional Neural Network
Convolutional Neural NetworkConvolutional Neural Network
Convolutional Neural NetworkJun Young Park
 
Fractal Rendering in Developer C++ - 2012-11-06
Fractal Rendering in Developer C++ - 2012-11-06Fractal Rendering in Developer C++ - 2012-11-06
Fractal Rendering in Developer C++ - 2012-11-06Aritra Sarkar
 
The Uncertain Enterprise
The Uncertain EnterpriseThe Uncertain Enterprise
The Uncertain EnterpriseClarkTony
 
Explanation on Tensorflow example -Deep mnist for expert
Explanation on Tensorflow example -Deep mnist for expertExplanation on Tensorflow example -Deep mnist for expert
Explanation on Tensorflow example -Deep mnist for expert홍배 김
 
Graphing day 1 worked
Graphing day 1 workedGraphing day 1 worked
Graphing day 1 workedJonna Ramsey
 
Circular convolution Using DFT Matlab Code
Circular convolution Using DFT Matlab CodeCircular convolution Using DFT Matlab Code
Circular convolution Using DFT Matlab CodeBharti Airtel Ltd.
 
Yampa AFRP Introduction
Yampa AFRP IntroductionYampa AFRP Introduction
Yampa AFRP IntroductionChengHui Weng
 
Making of-the-logistic-map-bifurcation-diagram
Making of-the-logistic-map-bifurcation-diagramMaking of-the-logistic-map-bifurcation-diagram
Making of-the-logistic-map-bifurcation-diagrammartsberger
 
딥러닝 교육 자료 #2
딥러닝 교육 자료 #2딥러닝 교육 자료 #2
딥러닝 교육 자료 #2Ashal aka JOKER
 
NTU ML TENSORFLOW
NTU ML TENSORFLOWNTU ML TENSORFLOW
NTU ML TENSORFLOWMark Chang
 
Presentation 2(power point presentation) dis2016
Presentation 2(power point presentation) dis2016Presentation 2(power point presentation) dis2016
Presentation 2(power point presentation) dis2016Daniel Omunting
 
Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.UA Mobile
 
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価Kota Abe
 
[112] 모바일 환경에서 실시간 Portrait Segmentation 구현하기
[112] 모바일 환경에서 실시간 Portrait Segmentation 구현하기[112] 모바일 환경에서 실시간 Portrait Segmentation 구현하기
[112] 모바일 환경에서 실시간 Portrait Segmentation 구현하기NAVER D2
 
Computational Linguistics week 10
 Computational Linguistics week 10 Computational Linguistics week 10
Computational Linguistics week 10Mark Chang
 

What's hot (20)

Convolutional Neural Network
Convolutional Neural NetworkConvolutional Neural Network
Convolutional Neural Network
 
Fractal Rendering in Developer C++ - 2012-11-06
Fractal Rendering in Developer C++ - 2012-11-06Fractal Rendering in Developer C++ - 2012-11-06
Fractal Rendering in Developer C++ - 2012-11-06
 
The Uncertain Enterprise
The Uncertain EnterpriseThe Uncertain Enterprise
The Uncertain Enterprise
 
Explanation on Tensorflow example -Deep mnist for expert
Explanation on Tensorflow example -Deep mnist for expertExplanation on Tensorflow example -Deep mnist for expert
Explanation on Tensorflow example -Deep mnist for expert
 
Graphing day 1 worked
Graphing day 1 workedGraphing day 1 worked
Graphing day 1 worked
 
Circular convolution Using DFT Matlab Code
Circular convolution Using DFT Matlab CodeCircular convolution Using DFT Matlab Code
Circular convolution Using DFT Matlab Code
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
 
Yampa AFRP Introduction
Yampa AFRP IntroductionYampa AFRP Introduction
Yampa AFRP Introduction
 
Making of-the-logistic-map-bifurcation-diagram
Making of-the-logistic-map-bifurcation-diagramMaking of-the-logistic-map-bifurcation-diagram
Making of-the-logistic-map-bifurcation-diagram
 
딥러닝 교육 자료 #2
딥러닝 교육 자료 #2딥러닝 교육 자료 #2
딥러닝 교육 자료 #2
 
Julia Set
Julia SetJulia Set
Julia Set
 
NTU ML TENSORFLOW
NTU ML TENSORFLOWNTU ML TENSORFLOW
NTU ML TENSORFLOW
 
CLIM Undergraduate Workshop: Tutorial on R Software - Huang Huang, Oct 23, 2017
CLIM Undergraduate Workshop: Tutorial on R Software - Huang Huang, Oct 23, 2017CLIM Undergraduate Workshop: Tutorial on R Software - Huang Huang, Oct 23, 2017
CLIM Undergraduate Workshop: Tutorial on R Software - Huang Huang, Oct 23, 2017
 
Lec 3-mcgregor
Lec 3-mcgregorLec 3-mcgregor
Lec 3-mcgregor
 
Presentation 2(power point presentation) dis2016
Presentation 2(power point presentation) dis2016Presentation 2(power point presentation) dis2016
Presentation 2(power point presentation) dis2016
 
Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.
 
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価
 
[112] 모바일 환경에서 실시간 Portrait Segmentation 구현하기
[112] 모바일 환경에서 실시간 Portrait Segmentation 구현하기[112] 모바일 환경에서 실시간 Portrait Segmentation 구현하기
[112] 모바일 환경에서 실시간 Portrait Segmentation 구현하기
 
Jan 2012 HUG: RHadoop
Jan 2012 HUG: RHadoopJan 2012 HUG: RHadoop
Jan 2012 HUG: RHadoop
 
Computational Linguistics week 10
 Computational Linguistics week 10 Computational Linguistics week 10
Computational Linguistics week 10
 

Viewers also liked

Soalan kt tahun 5 pksr 2 1 2013
Soalan kt tahun 5 pksr 2 1 2013Soalan kt tahun 5 pksr 2 1 2013
Soalan kt tahun 5 pksr 2 1 2013pang5gabanz
 
Evaluation question 6
Evaluation question 6Evaluation question 6
Evaluation question 6emmalouise01
 
Best Fit Awesome Web Apps for Highly Creative Kids
Best Fit Awesome Web Apps for Highly Creative KidsBest Fit Awesome Web Apps for Highly Creative Kids
Best Fit Awesome Web Apps for Highly Creative Kidswillia1r
 
Kt tahun 5 pksr 2
Kt tahun 5 pksr 2Kt tahun 5 pksr 2
Kt tahun 5 pksr 2pang5gabanz
 
Project management
Project management Project management
Project management abukky52
 
Il difficile "mestiere" dell'avvocato. Lawyers tough job.
Il difficile "mestiere" dell'avvocato. Lawyers tough job. Il difficile "mestiere" dell'avvocato. Lawyers tough job.
Il difficile "mestiere" dell'avvocato. Lawyers tough job. Nicola Canestrini
 
PPt- October 16
PPt- October 16PPt- October 16
PPt- October 16bphskc
 
Algae resume
Algae resumeAlgae resume
Algae resumeadnavi
 
De sportvereniging als wijkpartner: samenwerking tussen zorg en sport
De sportvereniging als wijkpartner: samenwerking tussen zorg en sportDe sportvereniging als wijkpartner: samenwerking tussen zorg en sport
De sportvereniging als wijkpartner: samenwerking tussen zorg en sportRotterdam Sportsupport
 
Organización tradicional vs organización actual
Organización tradicional vs organización actualOrganización tradicional vs organización actual
Organización tradicional vs organización actualKaren Riaño
 
Presentatie is terugloop van leden te stoppen
Presentatie   is terugloop van leden te stoppenPresentatie   is terugloop van leden te stoppen
Presentatie is terugloop van leden te stoppenRotterdam Sportsupport
 
Cinematographic Research
Cinematographic ResearchCinematographic Research
Cinematographic ResearchJessica Wade
 
0testmateii
0testmateii0testmateii
0testmateiiella2003
 
Cкинхеды, как субкультура
Cкинхеды, как субкультураCкинхеды, как субкультура
Cкинхеды, как субкультураainurjik_abulhaeva
 
Flipped Out - Introduction to the philosophy and process of flipping or blend...
Flipped Out - Introduction to the philosophy and process of flipping or blend...Flipped Out - Introduction to the philosophy and process of flipping or blend...
Flipped Out - Introduction to the philosophy and process of flipping or blend...willia1r
 
Atti introduttivi al dibattimento - Pretrial decisions under italian criminal...
Atti introduttivi al dibattimento - Pretrial decisions under italian criminal...Atti introduttivi al dibattimento - Pretrial decisions under italian criminal...
Atti introduttivi al dibattimento - Pretrial decisions under italian criminal...Nicola Canestrini
 

Viewers also liked (18)

Soalan kt tahun 5 pksr 2 1 2013
Soalan kt tahun 5 pksr 2 1 2013Soalan kt tahun 5 pksr 2 1 2013
Soalan kt tahun 5 pksr 2 1 2013
 
Evaluation question 6
Evaluation question 6Evaluation question 6
Evaluation question 6
 
Best Fit Awesome Web Apps for Highly Creative Kids
Best Fit Awesome Web Apps for Highly Creative KidsBest Fit Awesome Web Apps for Highly Creative Kids
Best Fit Awesome Web Apps for Highly Creative Kids
 
Kt tahun 5 pksr 2
Kt tahun 5 pksr 2Kt tahun 5 pksr 2
Kt tahun 5 pksr 2
 
PEACEAPP
PEACEAPPPEACEAPP
PEACEAPP
 
Project management
Project management Project management
Project management
 
Il difficile "mestiere" dell'avvocato. Lawyers tough job.
Il difficile "mestiere" dell'avvocato. Lawyers tough job. Il difficile "mestiere" dell'avvocato. Lawyers tough job.
Il difficile "mestiere" dell'avvocato. Lawyers tough job.
 
Concerning Jessica
Concerning JessicaConcerning Jessica
Concerning Jessica
 
PPt- October 16
PPt- October 16PPt- October 16
PPt- October 16
 
Algae resume
Algae resumeAlgae resume
Algae resume
 
De sportvereniging als wijkpartner: samenwerking tussen zorg en sport
De sportvereniging als wijkpartner: samenwerking tussen zorg en sportDe sportvereniging als wijkpartner: samenwerking tussen zorg en sport
De sportvereniging als wijkpartner: samenwerking tussen zorg en sport
 
Organización tradicional vs organización actual
Organización tradicional vs organización actualOrganización tradicional vs organización actual
Organización tradicional vs organización actual
 
Presentatie is terugloop van leden te stoppen
Presentatie   is terugloop van leden te stoppenPresentatie   is terugloop van leden te stoppen
Presentatie is terugloop van leden te stoppen
 
Cinematographic Research
Cinematographic ResearchCinematographic Research
Cinematographic Research
 
0testmateii
0testmateii0testmateii
0testmateii
 
Cкинхеды, как субкультура
Cкинхеды, как субкультураCкинхеды, как субкультура
Cкинхеды, как субкультура
 
Flipped Out - Introduction to the philosophy and process of flipping or blend...
Flipped Out - Introduction to the philosophy and process of flipping or blend...Flipped Out - Introduction to the philosophy and process of flipping or blend...
Flipped Out - Introduction to the philosophy and process of flipping or blend...
 
Atti introduttivi al dibattimento - Pretrial decisions under italian criminal...
Atti introduttivi al dibattimento - Pretrial decisions under italian criminal...Atti introduttivi al dibattimento - Pretrial decisions under italian criminal...
Atti introduttivi al dibattimento - Pretrial decisions under italian criminal...
 

Similar to Program implementation and testing

Digital signal Processing all matlab code with Lab report
Digital signal Processing all matlab code with Lab report Digital signal Processing all matlab code with Lab report
Digital signal Processing all matlab code with Lab report Alamgir Hossain
 
Introduction to Neural Networks and Deep Learning from Scratch
Introduction to Neural Networks and Deep Learning from ScratchIntroduction to Neural Networks and Deep Learning from Scratch
Introduction to Neural Networks and Deep Learning from ScratchAhmed BESBES
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manualUma mohan
 
Fourier series example
Fourier series exampleFourier series example
Fourier series exampleAbi finni
 
Intro to Python (High School) Unit #3
Intro to Python (High School) Unit #3Intro to Python (High School) Unit #3
Intro to Python (High School) Unit #3Jay Coskey
 
06 Recursion in C.pptx
06 Recursion in C.pptx06 Recursion in C.pptx
06 Recursion in C.pptxMouDhara1
 
17, r) -,r I -l19.t... 121.2t-314 23. ^t -rr - .docx
17, r) -,r I  -l19.t... 121.2t-314 23. ^t -rr - .docx17, r) -,r I  -l19.t... 121.2t-314 23. ^t -rr - .docx
17, r) -,r I -l19.t... 121.2t-314 23. ^t -rr - .docxhyacinthshackley2629
 
Computer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1bComputer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1bPhilip Schwarz
 
Trident International Graphics Workshop 2014 4/5
Trident International Graphics Workshop 2014 4/5Trident International Graphics Workshop 2014 4/5
Trident International Graphics Workshop 2014 4/5Takao Wada
 
DSP LAB COMPLETE CODES.docx
DSP LAB COMPLETE CODES.docxDSP LAB COMPLETE CODES.docx
DSP LAB COMPLETE CODES.docxMUMAR57
 
Programs in array using SWIFT
Programs in array using SWIFTPrograms in array using SWIFT
Programs in array using SWIFTvikram mahendra
 
The Ring programming language version 1.6 book - Part 62 of 189
The Ring programming language version 1.6 book - Part 62 of 189The Ring programming language version 1.6 book - Part 62 of 189
The Ring programming language version 1.6 book - Part 62 of 189Mahmoud Samir Fayed
 

Similar to Program implementation and testing (20)

Digital signal Processing all matlab code with Lab report
Digital signal Processing all matlab code with Lab report Digital signal Processing all matlab code with Lab report
Digital signal Processing all matlab code with Lab report
 
Dsp manual
Dsp manualDsp manual
Dsp manual
 
Introduction to Neural Networks and Deep Learning from Scratch
Introduction to Neural Networks and Deep Learning from ScratchIntroduction to Neural Networks and Deep Learning from Scratch
Introduction to Neural Networks and Deep Learning from Scratch
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
matlab.docx
matlab.docxmatlab.docx
matlab.docx
 
Fourier series example
Fourier series exampleFourier series example
Fourier series example
 
Intro to Python (High School) Unit #3
Intro to Python (High School) Unit #3Intro to Python (High School) Unit #3
Intro to Python (High School) Unit #3
 
06 Recursion in C.pptx
06 Recursion in C.pptx06 Recursion in C.pptx
06 Recursion in C.pptx
 
17, r) -,r I -l19.t... 121.2t-314 23. ^t -rr - .docx
17, r) -,r I  -l19.t... 121.2t-314 23. ^t -rr - .docx17, r) -,r I  -l19.t... 121.2t-314 23. ^t -rr - .docx
17, r) -,r I -l19.t... 121.2t-314 23. ^t -rr - .docx
 
Computer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1bComputer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1b
 
Trident International Graphics Workshop 2014 4/5
Trident International Graphics Workshop 2014 4/5Trident International Graphics Workshop 2014 4/5
Trident International Graphics Workshop 2014 4/5
 
Dsp manual
Dsp manualDsp manual
Dsp manual
 
DSP LAB COMPLETE CODES.docx
DSP LAB COMPLETE CODES.docxDSP LAB COMPLETE CODES.docx
DSP LAB COMPLETE CODES.docx
 
Programs in array using SWIFT
Programs in array using SWIFTPrograms in array using SWIFT
Programs in array using SWIFT
 
深層学習後半
深層学習後半深層学習後半
深層学習後半
 
Computer graphics
Computer graphics   Computer graphics
Computer graphics
 
Computer graphics
Computer graphics   Computer graphics
Computer graphics
 
alexnet.pdf
alexnet.pdfalexnet.pdf
alexnet.pdf
 
Dsp lab manual
Dsp lab manualDsp lab manual
Dsp lab manual
 
The Ring programming language version 1.6 book - Part 62 of 189
The Ring programming language version 1.6 book - Part 62 of 189The Ring programming language version 1.6 book - Part 62 of 189
The Ring programming language version 1.6 book - Part 62 of 189
 

More from abukky52

Pseudo code
Pseudo codePseudo code
Pseudo codeabukky52
 
Prototype solution
Prototype solutionPrototype solution
Prototype solutionabukky52
 
Story board design
Story board designStory board design
Story board designabukky52
 
Virtual networking computing via raspberry pi and nexus installation and conf...
Virtual networking computing via raspberry pi and nexus installation and conf...Virtual networking computing via raspberry pi and nexus installation and conf...
Virtual networking computing via raspberry pi and nexus installation and conf...abukky52
 
Prototype solution2
Prototype solution2Prototype solution2
Prototype solution2abukky52
 
Project management
Project managementProject management
Project managementabukky52
 
106CR DESIGN FOR USABILITY
106CR DESIGN FOR USABILITY106CR DESIGN FOR USABILITY
106CR DESIGN FOR USABILITYabukky52
 

More from abukky52 (7)

Pseudo code
Pseudo codePseudo code
Pseudo code
 
Prototype solution
Prototype solutionPrototype solution
Prototype solution
 
Story board design
Story board designStory board design
Story board design
 
Virtual networking computing via raspberry pi and nexus installation and conf...
Virtual networking computing via raspberry pi and nexus installation and conf...Virtual networking computing via raspberry pi and nexus installation and conf...
Virtual networking computing via raspberry pi and nexus installation and conf...
 
Prototype solution2
Prototype solution2Prototype solution2
Prototype solution2
 
Project management
Project managementProject management
Project management
 
106CR DESIGN FOR USABILITY
106CR DESIGN FOR USABILITY106CR DESIGN FOR USABILITY
106CR DESIGN FOR USABILITY
 

Recently uploaded

Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 

Recently uploaded (20)

Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 

Program implementation and testing

  • 1. PROGRAM IMPLEMENTATION AND TESTING - COMMENTED CODE #To import the tkinter GUI and methods From Tkinter import * Import time Import random #To set up the GUI called window window = Tk() window.title("Robot Arena") #To set up the arena for the robot canvas = Canvas(window, width= 500,height= 400,bg='white') canvas.pack() #To define the light colour def lightcolour(): canvas.itemconfig(traffic_light, fill="red", outline="red") canvas.update() time.sleep(2) canvas.itemconfig(traffic_light,fill="green",outline="green") canvas.update() def left(): x1,y1,x2,y2=canvas.coords(robot1) canvas.coords(robot1,x1‐vx,y1,x2‐vx,y2) canvas.update() time.sleep(.1) def right(): x1,y1,x2,y2=canvas.coords(robot1) canvas.coords(robot1,x1+vx,y1,x2+vx,y2) canvas.update() time.sleep(.1) def down(): x1,y1,x2,y2=canvas.coords(robot1) canvas.coords(robot1,x1,y1+vy,x2,y2+vy)
  • 2. canvas.update() time.sleep(.1) def up(): x1,y1,x2,y2=canvas.coords(robot1) canvas.coords(robot1,x1,y1‐vy,x2,y2‐vy) canvas.update() time.sleep(.1) def downleft(): x1,y1,x2,y2=canvas.coords(robot1) canvas.coords(robot1,x1‐vx,y1+vy,x2‐vx,y2+vy) canvas.update() time.sleep(.1) def downright(): x1,y1,x2,y2=canvas.coords(robot1) canvas.coords(robot1,x1+vx,y1+vy,x2+vx,y2+vy) canvas.update() time.sleep(.1) def upleft(): x1,y1,x2,y2=canvas.coords(robot1) canvas.coords(robot1,x1‐vx,y1‐vy,x2‐vx,y2‐vy) canvas.update() time.sleep(.1) def upright(): x1,y1,x2,y2=canvas.coords(robot1) canvas.coords(robot1,x1+vx,y1‐vy,x2+vx,y2‐vy) canvas.update() time.sleep(.1) #The obstacle course with all the shapes rectangle1 = canvas.create_rectangle(275,30,335,95,fill= "cyan",outline="cyan") rectangle2 = canvas.create_rectangle(115,290,200,380,fill= "cyan",outline="cyan")
  • 3. diamond1 = canvas.create_polygon(120,185,155,150,190,185,155,225,fill= "cyan",outline="cyan") triangle1 = canvas.create_polygon(225,335,285,275,305,360,fill="cyan",outline="cyan") triangle2 = canvas.create_polygon(40,70,115,25,110,120,fill="cyan",outline="cyan") triangle3 = canvas.create_polygon(425,65,470,50,460,100,fill="cyan",outline="cyan") hexagon1 = canvas.create_polygon(430,250,415,225,430,200,450,200,465,225,450,250,fill="cyan",outline="cyan") hexagon2 = canvas.create_polygon(200,120,175,110,170,80,190,60,215,70,220,100,fill="cyan",outline="cyan") pentagon1 = canvas.create_polygon(365,225,315,200,315,140,370,120,400,170,fill="cyan",outline="cyan") circle1=canvas.create_oval(‐20,205,60,290, fill="cyan", outline="cyan") circle2=canvas.create_oval(370,275,600,500,fill="cyan", outline="cyan") circle3=canvas.create_oval(250,25,140,‐50,fill="cyan", outline="cyan") # Traffic Light traffic_light=canvas.create_oval(220,200,270,250,fill="cyan",outline="cyan") vx= 7.0 # x velocity vy= 7.0 # y velocity
  • 4. # Robot robot1=canvas.create_oval(10,385,25,370, fill='purple', outline='purple') x=random.randrange(1,4) # Generates a random number to determine a route if x==1: # Start of loop for Route 1 lightcolour() for t in range(1,5): for t in range(1,3): downright() for t in range(1,46): right() for t in range(1,20): up() lightcolour() for t in range(1,20): upleft() for t in range(1,5): downleft() for t in range(1,8): upleft() for t in range(1,3): down() for t in range(1,10): downleft()
  • 5. for t in range(1,8): downright() lightcolour() for t in range(1,8): downleft() for t in range(1,8): down() lightcolour() for t in range(1,9): downleft() for t in range(1,2): x1,y1,x2,y2=canvas.coords(robot1) canvas.coords(robot1,10,385,25,370) canvas.update() time.sleep(.1) # End of loop for Route 1 If x==2: lightcolour() # Start of loop for Route 2 for t in range(1,5): for t in range(1,12): up() for t in range(1,10): right()
  • 6. for t in range(1,10): upright() lightcolour() for t in range(1,5): right() for t in range(1,20): upright() for t in range(1,22): down() lightcolour() for t in range(1,8): right() for t in range(1,20): down() for t in range(1,21): left() for t in range(1,18): up() lightcolour() for t in range(1,18): left() for t in range(1,12): downleft() for t in range(1,6):
  • 7. down() lightcolour() for t in range(1,2): x1,y1,x2,y2=canvas.coords(robot1) canvas.coords(robot1,10,385,25,370) canvas.update() time.sleep(.1) # End of loop for Route 2 If x==3: lightcolour() # Start of loop for Route 3 for t in range(1,5): for t in range(1,10): upright() for t in range(1,20): up() for t in range(1,10): upright() for t in range(1,12): downright() for t in range(1,12): downleft() lightcolour() for t in range(1,16):
  • 8. right() for t in range(1,8): upright() for t in range(1,12): upleft() for t in range(1,6): down() lightcolour() for t in range(1,8): downleft() for t in range(1,10): downright() for t in range(1,10): upright() for t in range(1,12): downright() lightcolour() for t in range(1,13): downleft() for t in range(1,38): left() for t in range(1,3): upleft() for t in range(1,2): x1,y1,x2,y2=canvas.coords(robot1)
  • 9. canvas.coords(robot1,10,385,25,370) canvas.update() time.sleep(.1) # End of loop for Route 3 #To complete the GUI window.mainloop() SCREENSHOT OF OUTPUT