function get_player_text(player_O_or_X) { extra = "" if (player_O_or_X == "D") { return "DRAW!"; } if (player_O_or_X ~ "^W") { extra = "WON!" player_O_or_X = substr(player_O_or_X, 2) } return "Player " player_O_or_X " " extra } function draw_turn_line(pos_1, pos_2, pos_3) { return sprintf(" %-1s | %-1s | %-1s ", pos_1, pos_2, pos_3) } function draw_line_line() { return "---+---+---" } BEGIN { GAME_NUMBER = 0 } { print get_player_text($1) # " (" $0 ")" print "" print draw_turn_line($2, $3, $4) print draw_line_line() print draw_turn_line($5, $6, $7) print draw_line_line() print draw_turn_line($8, $9, $10) print "" fflush() }