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

Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 

Recently uploaded (20)

Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 

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