user1315: As we know, we usually doing castle to move king to (assumed) safe place.
But when we play short castle or long castle since my chess engine (Houdini) seems to prefer short castle when I play against a strong player and long castle when I play against a weak player.

user70: The side selected for castling is generally related to the openings chosen by the player.  Long castling has the following attributes:

lands a rook on a center file where short castling does not.
takes more time since an additional piece must be moved (the queen).
leaves the pawn on the a-file undefended.

Finally, when the players castle on opposite wings, the game is less likely to be a draw - the opposing pawns can become purely offensive weapons. 
Since Houdini is rated probably close to 1800 points higher than I am and because we don't have any specifics, I can't tell you why it's making its castling choice.  But it does not move based upon the weakness of its opponent, per se - it is making moves based upon board position.
You'll might see Houdini castling long if it has time to get the queen off the back row. Or perhaps if it can gain a tempo by castling long and hitting an opponent's piece in the center. 

1315: <p>As we know, we usually doing castle to move king to (assumed) safe place.</p>

<p>But when we play short castle or long castle since my chess engine (Houdini) seems to prefer short castle when I play against a strong player and long castle when I play against a weak player.</p>
 70: <p>The side selected for castling is generally related to the openings chosen by the player.  Long castling has the following attributes:</p>

<ol>
<li>lands a rook on a center file where short castling does not.</li>
<li>takes more time since an additional piece must be moved (the queen).</li>
<li>leaves the pawn on the a-file undefended.</li>
</ol>

<p>Finally, when the players castle on opposite wings, the game is less likely to be a draw - the opposing pawns can become purely offensive weapons. </p>

<p>Since Houdini is rated probably close to 1800 points higher than I am and because we don't have any specifics, I can't tell you why it's making its castling choice.  But it does not move based upon the weakness of its opponent, per se - it is making moves based upon board position.</p>

<p>You'll might see Houdini castling long if it has time to get the queen off the back row. Or perhaps if it can gain a tempo by castling long and hitting an opponent's piece in the center. </p>
