The Eyes are Following You

This is inspired by the excellent Visualize Visual Eyes challenge. It is posted with permission from and credit to @Jordan

We are going to create an ASCII art approximation of the Xeyes challenge but without worrying about the actual mouse movements. Just the positions.

EDIT

I thought about whether this could be seen as a duplicate but I don't believe it is.

• The previous question required detecting mouse movement. This does not and so is open to many more languages.This is simple interactive ASCII art which can be attempted in any language.

• While the algorithm for the eye movement may be similar, this is in many ways simpler to achieve.

• I'm not convinced that any answer given so far to the previous question could be trivially ported to this.

• I don't think I am good enough at languages that could answer the previous question to attempt it. I would have a try at this one.

If consensus is that I am wrong then I am happy to delete the question.

I have removed the comment about "interesting answer" as this is intended to be code golf.

Overview

In all cases the mouse position will be represented by an X.

Here are the eyes with no mouse position (cursor is off screen):

/---\ /---\
|   | |   |
| O | | O |
|   | |   |
\---/ \---/

Now let's say your mouse is to the right of the eyes:

/---\ /---\
|   | |   |
|  O| |  O|X
|   | |   |
\---/ \---/

and now at the bottom left:

/---\ /---\
|   | |   |
|   | |   |
|O  | |O  |
\---/ \---/
X

and now at the top:

X
/---\ /---\
| O | | O |
|   | |   |
|   | |   |
\---/ \---/

From this we can see that (in it's simplest case - we could make it a lot more complicated but let's not do that for now) there are 9 different positions for the eyes and nine different positions for the cursor as shown below:

1     2     3
/---\ /---\
|123| |123|
4|456| |456|6
|789| |789|
\---/ \---/
7     8     9

Position 5 represents no cursor (off screen). The eyes are both looking forward.

The Challenge

Take an integer (or any representation of an integer) between 1 and 9 inclusive and output the eyes if the cursor was in the position of that integer. You must include the X as the position of the cursor (except when it is off screen i.e. the eyes are looking forward - no X).

Rules

• Input format is your own choice.

• Program or function.

• Any amount of leading or trailing whitespace is allowed.

• Output must consist only of the characters /\-| and either upper or
lowercase x and o.

• Assume that the input will always be valid, i.e. an integer between 1 and 9 inclusive.

• Feel free to change the order of the integers if it helps i.e. 2 does not have to be top and 5 does not have to be no cursor.

• Standard loopholes prohibited as usual.

• This is code golf. Shortest answer wins.

Test Cases

Note: All test cases use the numbering sequence detailed in the explanation. As stated in the rules, you do not have to use the same number sequence.

Input = 5

/---\ /---\
|   | |   |
| O | | O |
|   | |   |
\---/ \---/

Input = 6

/---\ /---\
|   | |   |
|  O| |  O|X
|   | |   |
\---/ \---/

Input = 2

X
/---\ /---\
| O | | O |
|   | |   |
|   | |   |
\---/ \---/

Input = 7

/---\ /---\
|   | |   |
|   | |   |
|O  | |O  |
\---/ \---/
X

This challenge has been in the sandbox for the last week.

• "Shortest answer wins for each language however I reserve the right to accept what I think is the most interesting answer." so a popularity contest? – Unihedron Jan 19 '18 at 1:06
• I'm tempted to vote to close, as this is really just the other challenge with a section removed, and answers from there are easily portable here. – Rɪᴋᴇʀ Jan 19 '18 at 1:35
• I don’t think this is a duplicate at all. – Jordan Jan 19 '18 at 2:57
• Even if a solution from the other one could be trivially ported, it would still have to be competitive for this to qualify as a duplicate which is not the case. – ბიმო Jan 19 '18 at 7:34
• Indeed, in Visualize Visual Eyes, you had to calculate for arbitrary mouse positions, so code for comparing deltas is needed. Simply removing this code often won't make a competitive solution here. – Felix Palmen Jan 19 '18 at 8:16

Clean, 253 bytes

import StdEnv
?n=flatlines[[if([(0,0),(6,0),(12,0),(0,3),(0,9),(12,3),(0,6),(6,6),(12,6)]!!(n-1)==(v,u))'X'b\\b<-[' ':a++a]&v<-[0..]]\\a<-[spaces 6,['/---\\ ']]++[['|':[if(n==i)'0'' '\\i<-[j..j+2]]]++['| ']\\j<-[1,4,7]]++[['\\---/ '],spaces 6]&u<-[0..]]

Try it online!

This is mostly a port from my answer to the other question.

• I am a bit disappointed that someone would post an answer, accept the upvotes (including mine simply because it works) and then vote to close as a dupe. No personal attack intended. It just surprises me that members of this community think it is fair to enhance their own rep while denying other members who may want to try the challenge the chance to do so. No problem if you think it is a bad challenge or a duplicate. Just vote to close but don't answer first and then vote to close. Just vote to close if you feel that strongly or post and don't vote to close. You can't have it both ways. – ElPedro Jan 19 '18 at 18:30
• @ElPedro I admit I hadn't thought about the double standard my actions have created, I only considered each separately. I will not do it again. Additionally, I will delete my answer if you desire. – Οurous Jan 19 '18 at 21:07
• Please do not delete. I accept your comments and you are still winning ☺ – ElPedro Jan 19 '18 at 23:08

J, 119 112 bytes

d=.y-1
a=.'O'(d{,{;~2+i.3)}7 6$42$'       /---\ |   | |   | |   | \---/'
' '(<3 6)}'X'(d{,{(;+:)3*i.3)}a,.a,.' '

Try it online!

• The eyes are good but I don't see the X representing the mouse position. Guess it doesn't really matter as it has been closed as a dupe anyway. – ElPedro Jan 19 '18 at 15:27
• @ElPedro - I'm sorry, apparently I've missed this part of the challenge after looking the other two (then) solutions. I don't think it's a duplicate. – Galen Ivanov Jan 19 '18 at 18:22
• No prob and thanks. Get the "X" (or "x") in there then +1 (if it gets reopened) :) – ElPedro Jan 19 '18 at 18:44
• Ok, it is reopened – ElPedro Jan 19 '18 at 20:46
• Then you get +1 ☺ – ElPedro Jan 19 '18 at 23:14

Perl 5, 150 140 bytes

$x=shift;$_='9     8     7
/---\ /---\
09870 09870
606540';$t=reverse;y/98764/12346/;$_.=" $t";s/(\d)$x(.)/\1O\2/g;s/$x/X/;y/0-9/| /;say Try it online! Explanation$x = shift;  # Shift the first value off the input argument array.
# Assign template string to default pattern-search variable.
# Only use first half of output. Use 0 instead of |.
$_ = '9 8 7 /---\ /---\ 09870 09870 606540';$t = reverse;  # $t is the reverse of$_.
y/98764/12346/;  # Correct digits in first half of template string $_, # so 9 becomes 1, 8 becomes 2 etc.$_ .= " $t"; # Append the two halves of the template. s/(\d)$x(.)/\1O\2/g;  # Regexp replace all occurrences of $x, preceded by # a digit and followed by any non-newline character, # by "O" and the original surrounding characters. s/$x/X/;  # Replace last remaining occurrence of $x by "X". y/0-9/| /; # Replace 0 by |, and all other remaining digits by a space. say # Print$_ followed by a newline.