forked from: avoidance function

TODO 端だと当たる問題