Your SlideShare is downloading. ×
Week8
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Week8

285
views

Published on

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
285
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. A I P ro g ra m m ing Week Eight Errors & Debugging Richard Price rmp@ cs.bham.ac.uk www.cs.bham.ac.uk/~rmp/ www.cs.bham.ac.uk/internal/courses/ai-prog-a/
  • 2. R ec a p • Program design: – Simple. – Plan. – Dynamic. – Flexible. • Algorithms. 2
  • 3. T ypes o f E rro r • Three types of error: – Syntax errors. – Run-time errors. – Semantic errors. 3
  • 4. S ynta x E rro rs define printItemThree(list) -> output list(3) -> output; enddefine; printItemThree([1 2 3]) => ;;; MISHAP ids: INCORRECT DEFINE SYNTAX (missing ; after header) ;;; (At or before line 2 column 10) • Type help ids (Incorrect Define Syntax) for further information. 4
  • 5. R un T im e E rro rs : • The program compiles. • But crashes when ran. define printItemThree(list) -> output; list(3) -> output; enddefine; printItemThree([1 2]) => ;;; MISHAP - BAD ARGUMENTS FOR INDEXED LIST ACCESS ;;; INVOLVING: 3 [1 2] ;;; FILE : /home/pg/mer/week8-lecture.p LINE NUMBER: 2 ;;; DOING : runproc 5
  • 6. S em a ntic E rro rs • Program compiles. • Doesn’t crash. • Does not work as intended. – Incorrect output. – Infinite loops. • Hardest problems to find and resolve. 6
  • 7. E rro r P reventio n • Make mistakes and learn from them. • Follow your design. • Modules – Break down code into procedures. – Ensure each procedure works. – Test cases. • Layout of code. • Test your code. 7
  • 8. E rro r detec tion • Know your code. • Print out your variables. • Change one thing at a time. • Use trace. 8
  • 9. T ra c e Define squareIt( input)- result. > input *input - result; > Enddefine; Define squareList( inputList)- result; > Lvars element; [% for element in inputList do squareIt( element) ; endfor % ] - result; > Enddefine; Trace squareIt; squareList( 6 2 8 99])=> [4 9
  • 10. T ra c e > squareIt 4 < squareIt 16 > squareIt 6 < squareIt 36 > squareIt 2 < squareIt 4 > squareIt 8 < squareIt 64 > squareIt 99 < squareIt 9801 **[16 36 4 64 9801] 10
  • 11. B uilt in H elp • Three main levels of built- help. in • TEACH files – Tutorial style information. – TEACH Teachfiles • Help files – more concise information often with code examples. – HELP Helpfiles • REF files – Contain reference only information. – REF Reffiles. 11
  • 12. M ini P ro jec ts • After this week you will be working on mini-projects. • Worth 50% of your overall mark for AI programming A. • We’ll be using the lab sessions to discuss and program your projects. • Plan Deadline: Monday 1 st December 5pm. • More details in the following lectures. • Aim is to develop a large program in Pop- 1 . 1 • There is another mini-project next semester. – Focuses on applying Artificial Intelligence. 12
  • 13. M ini P ro jec ts • Encourage you to pick your own. • Suggestions: – Intelligent System interface. – Expert system. • Medical diagnosis problem. • Fault diagnosis problem. • Football ( any sport)game predictor. or • Puzzle solvers – Sudoku – Crosswords. • Board games – Connect 4. – Draughts • ASCII games: – You wake up in a dark room, in front of you is a piece of cheese… 13

×