Artificial Intelligence and Robotics - PowerPoint PPT Presentation

About This Presentation
Title:

Artificial Intelligence and Robotics

Description:

Artificial Intelligence and Robotics By Keith Bright & John DeBovis Progress Switched from ELIZA chat program to Tic Tac Toe program Spent time developing Tic Tac Toe ... – PowerPoint PPT presentation

Number of Views:431
Avg rating:3.0/5.0
Slides: 9
Provided by: WidenerUn8
Learn more at: https://cs.widener.edu
Category:

less

Transcript and Presenter's Notes

Title: Artificial Intelligence and Robotics


1
Artificial Intelligence and Robotics
  • ByKeith Bright John DeBovis

2
Progress
  • Switched from ELIZA chat program to TicTac Toe
    program
  • Spent time developing Tic Tac Toe program
  • Two dimensional array
  • Human vs. Computer
  • Use test to decide what is the smartest decision
    for the computer to makebecoming an example of
    weak intelligence

3
Main
  • define ROW 3
  • define COL 3
  • define SPACE '
  • void get_computer_move(char ticCOL)
  • void get_player_move(char ticCOL)
  • void disp_tic(char ticCOL)
  • int check(char ticCOL)
  • int main()
  • char ticROWCOL' '
  • char done SPACE
  • while(doneSPACE)
  • disp_tic(tic)
  • get_player_move(tic)
  • donecheck(tic)
  • get_computer_move(tic)
  • donecheck(tic)
  • if(done'X')
  • printf("You Win!.\n")
  • else
  • printf("I Won!!!!!\n")
  • disp_tic(tic)

4
Get Players Move
  • /Input Players move/
  • void get_player_move(char ticROWCOL
  • int i0,j0
  • printf("Enter coordinates for your X, with the
    index starting at 0 ")
  • scanf("d d", i ,j
  • if(ticij!SPACE)
  • printf("Invalid move, try again. \n")
  • get_player_move(tic)
  • else
  • ticij'X'

5
Get Computer Move
  • /Get the computer's move/
  • void get_computer_move(char ticCOL)
  • Problems
  • We had trouble figuring out where to insert the
    computers next move
  • In order to do so, the computer must test to see
    where the smartest move would be

6
Display Game
  • /Display the game board/
  • void disp_tic(char ticCOL)
  • int t
  • for(t0 tlt3t)
  • printf("c c c", tict0, tict1,
    tict2)
  • if(t!2)
  • printf("\n---------\n")
  • printf("/n")

7
Test for Winner
  • for(j0 jlt3 answerSPACEj)
  • if(tic0jtic1j tic1jtic2j)
  • answertic0j
  • return answer
  • /See if there is a winner/
  • int check(char ticCOL)
  • int j
  • char answer SPACE
  • int k0
  • int i2
  • for(j0jlt3 answerSPACEj)
  • if(ticj0ticj1 ticj1ticj2)
  • answerticj0
  • return (answer)

8
Test for Winner (cont.)
  • /test diagonal/
  • if(tickktick1k1 tick1k1tic
    k2k2)
  • return (ticjj)
  • else if(tickitick1i-1
    tick1i-1ticik)
  • return (ticij)
  • return SPACE
Write a Comment
User Comments (0)
About PowerShow.com