Skip to content

Overview

Summary

Connect 4 application is an interactive example application to play Connect 4 game against a robot.

Function Blocks

Connect4 - Full Game

This is the main program which has to be run to play. The program contains the following FBs as well as standard drag&bot FBs such as Human Display to allow interactive human target column selection.

Pick Human

This function block:

  • moves the robot from a safe upper position to the pick position on the left side of the connect-4 board
  • approaches to the pick position
  • closes the gripper to pick the chip
  • departs back to the side position
  • moves back to the safe position on top of the board.

Inputs: None Outputs: None

Pick Robot

This function block is very similar to Pick Human but moves the robot to the opposite side:

  • moves the robot from a safe upper position to the pick position on the right side of the connect-4 board
  • approaches to the pick position
  • closes the gripper to pick the chip
  • departs back to the side position
  • moves back to the safe position on top of the board.

Inputs: None Outputs: None

Put in column

This function block moves the robot from a safe position to the top of the column position, opens the gripper to drop the chip and moves the robot back to the safe position.

Inputs: Pose (Cartesian position and orientation) corresponding to the top of the desired position Outputs: None

Connect4 logic

This is a basic function block containing the game logic. It keeps the current state of the board, detects end game and calculates the next target column for the robot provided the human selected column. It also handles basic errors such as selecting a full column.

Inputs:

  • Pose corresponding to the column on the left
  • Pose corresponding to the column on the right
  • Human column selected: this is a string representing the position 1 to 7. It is normally linked with the output of a Human Display function block

Outputs:

  • Human column pose: Cartesian target pose to place the human chip
  • Robot column pose: Cartesian target pose to place the robot chip
  • Incorrect selection: boolean to inform if the provided human column selection was incorrect
  • Game continues: boolean informing if the game continues or ends
  • Winner: returns the game winner as string (Robot or Human)
  • Human wins: true if human wins
  • Robot wins: true if robot wins
  • Draft: true if no one wins but no further play is possible. Draft is a misspelling of word Draw.