Consider a town with consumers represented by a closed interval $[0,2]$ with the consumers spread continuously and uniformly. There are two stores, $A$ and $B$ who sell the same product at $p_A$ and $p_B$ at no cost.
A consumer has a gross utility of 4 from having the product which is reduced by price paid and travel costs, which is determined as distance traveled. Each consumer only buys 1 unit of the product, and if the consumer does not buy from either store, he has a utility of 0. For example, if a consumer is located at $x=1.5$ and buys from store B at $p_B=1$ which is located at $x_B=2$, then his utility is $4-1-|2-1.5| = 2.5$.
Suppose that $A$ is located at $x_A=0$ and $B$ is located at $x_B=2$. Also, suppose stores much charge at $p \le 4$.
Suppose stores are profit maximizers. What are the equilibrium prices, quantities, and profits for both stores?
My initial thoughts are that, in this scenario, the profit functions for each store is denoted as:
$$ \pi_A=p_A+p_A(\frac{p_B-p_A}{2}) $$
$$ \pi_B=p_B-p_B(\frac{p_B-p_A}{2}) $$
We can take the first order condition for each, to get the maximizing profit.
$$ \frac{\partial \pi_A}{p_A} = 1 + \frac{p_B}{2} - p_A = 0 \implies p_A = \frac{p_B}{2} + 1 $$
$$ \frac{\partial \pi_B}{p_B} = 1 - p_B + \frac{p_A}{2} = 0 \implies p_B = 1 + \frac{p_A}{2} $$
By substituting one into the other, we have that $p_A=p_B=2$, $q_A=q_B=1$ and $\pi_A=\pi_B=2$.
I'm not very sure about this solution or the direction I took to solve it. Any advice here would be appreciated on what other direction I should try.