المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : كود code لعبة × O اعلى او اسفل منتداك ( وسع صدر اعضائك )



romaissa
10-30-2013, بتوقيت غرينيتش 11:40 PM
http://www.dzbatna.com/images/icons/iconrote.gif ظƒظˆط¯ ظ„ط¹ط¨ط© أ— O ط§ط¹ظ„ظ‰ ط§ظˆ ط§ط³ظپظ„ ظ…ظ†طھط¯ط§ظƒ ( ظˆط³ط¹ طµط¯ط± ط§ط¹ط¶ط§ط¦ظƒ ) (http://www.dzbatna.com/t1169047/)



بسم الله الرحمن الرحيم

اقدم لكم كود code لعبة ( إكس × اوO ) الشهيره

كل ماعليك وضع الكود code بالهدر او الفوتر

تستطيع وضع الكود code باي مكان بمنتداك

الكود code ليس بمجاني free الثمن ( دعوه لي ولوالدي بالدنيا و الاخره )

ولا اسمح ولا احلل ولا ابيح من يزيل الحقوق من الكود code
رمز PHP:

<code style="white-space:nowrap"> <code> <!--
لا اسمح ولا ابيح ولا احلل من يزيل الحقوق
جميع الحقوق محفوظة لـ زووم بي اتش بي
(zoom-php)
للتواصل وطلب الاكواد و البرمجيات
zoom-php@hotmail.com
-->
<html>
<head>
<title>tic tac toe</title>




<script>
function create_tic_tac_toe_ai_array()
{
ai_array = new Array(9);

for(var index = 0; index < ai_array.length; index++)
{
ai_array&#91;index&#93; = new Array(ai_array.length - index);
for(var index2 = 0; index2 < ai_array&#91;index&#93;.length; index2++)
ai_array&#91;index&#93;&#91;index2&#93; = index2;
}

return(ai_array);
}

function randomise_ai_array(tic_tac_toe_ai_array)
{
for(var index = 0; index < tic_tac_toe_ai_array.length; index++)
for(var index2 = 0; index2 < tic_tac_toe_ai_array&#91;index&#93;.length; index2++)
{
temp = tic_tac_toe_ai_array&#91;index&#93;&#91;index2&#93;;
rand = parseInt(Math.random() * tic_tac_toe_ai_array&#91;index&#93;.length);
tic_tac_toe_ai_array&#91;index&#93;&#91;index2&#93; = tic_tac_toe_ai_array&#91;index&#93;&#91;rand&#93;;
tic_tac_toe_ai_array&#91;index&#93;&#91;rand&#93; = temp;
}
}

function create_tic_tac_toe()
{
this.Letter = '';
this.Play = -1;
}

function create_tic_tac_toe_array()
{
game_array = new Array(9);

for(var index = 0; index < ai_array.length; index++)
game_array&#91;index&#93; = new create_tic_tac_toe();

return(game_array);
}

function next_available_square(tic_tac_toe_array, square)
{
available_square = 0;

for(index = 0; index <= square; index++)
{
while(tic_tac_toe_array&#91;available_square&#93;.Letter != '')
{
available_square++;
}

if(index < square)
available_square++;
}

if(available_square < 0 || available_square > 8)
alert('oh my god available_square = ' + available_square);

return(available_square);
}

function ai_play(tic_tac_toe_array, tic_tac_toe_ai_array, turn_number, trial_number)
{
for(var index = turn_number + trial_number; index < tic_tac_toe_ai_array.length; index++)
{
//Each increment in this loop is a possible move.
for(var index2 = 0; index2 < tic_tac_toe_ai_array&#91;index&#93;.length; index2++)
{
take_back_moves(tic_tac_toe_array, turn_number + trial_number);

index3 = next_available_square(tic_tac_toe_array, tic_tac_toe_ai_array&#91;index&#93;&#91;index2&#93;);

trial_move(tic_tac_toe_array, index3, next_letter(tic_tac_toe_array));

if(win(tic_tac_toe_array, Player_Letter()) == true)
{
return(1);
}

if(turn_number + trial_number + 1 == tic_tac_toe_array.length)
{
return(0);
}

if(trial_number < 2)
{
return_value = ai_play(tic_tac_toe_array, tic_tac_toe_ai_array, turn_number, trial_number + 1);

take_back_moves(tic_tac_toe_array, turn_number + trial_number + 1);

if((return_value != 1 && next_letter(tic_tac_toe_array) == Player_Letter()) ||
(index2 == tic_tac_toe_ai_array&#91;index&#93;.length - 1))
return(return_value);
}
}
}
}

function Computer_Letter()
{
return(computer_letter);
}

function Player_Letter()
{
return(player_letter);
}

function play()
{
if(turn == Computer_Letter())
document.tic_tac_toe.message.value = 'دور الكمبيوتر (' + Computer_Letter() + ')';
else
document.tic_tac_toe.message.value = 'دورك الآن (' + Player_Letter() + ')';

if(win(tic_tac_toe, Computer_Letter()) == false &&
win(tic_tac_toe, Player_Letter()) == false &&
tied(tic_tac_toe) == false)
{
if(turn == Computer_Letter())
{
ai_play(tic_tac_toe, ai_array, move_number(tic_tac_toe), 0);
turn = Player_Letter();
}

setTimeout('play();', 1000);
}

if(win(tic_tac_toe, Computer_Letter()))
{
document.tic_tac_toe.message.value = 'الفائز الكمبيوتر';
}

if(win(tic_tac_toe, Player_Letter()))
{
document.tic_tac_toe.message.value = 'لقد فزت';
}

if(tied(tic_tac_toe))
{
document.tic_tac_toe.message.value = 'النتيجه تعادل';
}
}

function move_number(tic_tac_toe_array)
{
latest_move = 0;
for(var index = 0; index < tic_tac_toe_array.length; index++)
{
if(tic_tac_toe_array&#91;index&#93;.Play >= latest_move)
latest_move = tic_tac_toe_array&#91;index&#93;.Play + 1;
}

return(latest_move);
}

function next_letter(tic_tac_toe_array)
{
last_position = 0;
for(var index = 0; index < tic_tac_toe_array.length; index++)
{
if(tic_tac_toe_array&#91;index&#93;.Play > tic_tac_toe_array&#91;last_position&#93;.Play)
last_position = index;
}

if(tic_tac_toe_array&#91;last_position&#93;.Letter == Computer_Letter())
return(Player_Letter());
else
return(Computer_Letter());
}

function user_move(square, Letter)
{
if(tic_tac_toe&#91;square&#93;.Letter == '' && turn == Player_Letter())
{
move(tic_tac_toe, square, Letter);
turn = Computer_Letter();
document.tic_tac_toe.message.value = '... (' + Computer_Letter() + ')';
}
}

function move(tic_tac_toe_array, square, Letter)
{
tic_tac_toe_array&#91;square&#93;.Letter = Letter;
tic_tac_toe_array&#91;square&#93;.Play = move_number(tic_tac_toe_array);
eval('document.tic_tac_toe.square' + square + '.value = \'' + Letter + '\'');
}

function trial_move(tic_tac_toe_array, square, Letter)
{
if(square < tic_tac_toe_array.length)
{
tic_tac_toe_array&#91;square&#93;.Letter = Letter;
tic_tac_toe_array&#91;square&#93;.Play = move_number(tic_tac_toe_array);
eval('document.tic_tac_toe.square' + square + '.value = \'' + Letter + '\'');
}
}

function take_back_moves(tic_tac_toe_array, Play)
{
for(var index = 0; index < tic_tac_toe_array.length; index++)
{
if(tic_tac_toe_array&#91;index&#93;.Play >= Play)
{
tic_tac_toe_array&#91;index&#93;.Letter = '';
tic_tac_toe_array&#91;index&#93;.Play = -1;
eval('document.tic_tac_toe.square' + index + '.value = \'\'');
}
}
}

var ai_array;
var tic_tac_toe;
var turn;
var computer_letter;
var player_letter;

function new_game()
{
if(Math.random() < 0.5)
{
computer_letter = 'x';
player_letter = 'o';
}
else
{
computer_letter = 'o';
player_letter = 'x';
}

if(Math.random() < 0.5)
turn = Computer_Letter();
else
turn = Player_Letter();

randomise_ai_array(ai_array);

take_back_moves(tic_tac_toe, 0);
}

function init()
{
ai_array = create_tic_tac_toe_ai_array();
tic_tac_toe = create_tic_tac_toe_array();

new_game();

play();
}

function win(tic_tac_toe_array, Letter)
{
//First row, first column, and diagonal.
if(tic_tac_toe_array&#91;0&#93;.Letter == Letter)
{
if(tic_tac_toe_array&#91;1&#93;.Letter == Letter && tic_tac_toe_array&#91;2&#93;.Letter == Letter)
return(true);
if(tic_tac_toe_array&#91;3&#93;.Letter == Letter && tic_tac_toe_array&#91;6&#93;.Letter == Letter)
return(true);
if(tic_tac_toe_array&#91;4&#93;.Letter == Letter && tic_tac_toe_array&#91;8&#93;.Letter == Letter)
return(true);
}

//Second row, second column, and other diagonal.
if(tic_tac_toe_array&#91;4&#93;.Letter == Letter)
{
if(tic_tac_toe_array&#91;3&#93;.Letter == Letter && tic_tac_toe_array&#91;5&#93;.Letter == Letter)
return(true);
if(tic_tac_toe_array&#91;1&#93;.Letter == Letter && tic_tac_toe_array&#91;7&#93;.Letter == Letter)
return(true);
if(tic_tac_toe_array&#91;2&#93;.Letter == Letter && tic_tac_toe_array&#91;6&#93;.Letter == Letter)
return(true);
}

//Third row and third column.
if(tic_tac_toe_array&#91;8&#93;.Letter == Letter)
{
if(tic_tac_toe_array&#91;6&#93;.Letter == Letter && tic_tac_toe_array&#91;7&#93;.Letter == Letter)
return(true);
if(tic_tac_toe_array&#91;2&#93;.Letter == Letter && tic_tac_toe_array&#91;5&#93;.Letter == Letter)
return(true);
}

return(false);
}

function tied(tic_tac_toe_array)
{
if(win(tic_tac_toe_array, Player_Letter()) == false &&
win(tic_tac_toe_array, Computer_Letter()) == false)
{
for(var index = 0; index < tic_tac_toe_array.length; index++)
if(tic_tac_toe_array&#91;index&#93;.Letter == '')
return(false);

return(true);
}

return(false);
}
</script>
</head>

<body onload="init();">

<form name="tic_tac_toe" style="text-align: center">
<table>
<tr>
<td colspan="3" align="center">
<input type="text" size="9" name="message" style="border:none; text-align:center;" /></td>
</tr>

<tr>
<td>
<input type="text" size="1" name="square0" readonly
onclick="user_move(0, Player_Letter());" /></td>
<td align="center">
<input type="text" size="1" name="square1" readonly
onclick="user_move(1, Player_Letter());" /></td>
<td align="right">
<input type="text" size="1" name="square2" readonly
onclick="user_move(2, Player_Letter());" /></td>
</tr>

<tr>
<td>
<input type="text" size="1" name="square3" readonly
onclick="user_move(3, Player_Letter());" /></td>
<td align="center">
<input type="text" size="1" name="square4" readonly
onclick="user_move(4, Player_Letter());" /></td>
<td align="right">
<input type="text" size="1" name="square5" readonly
onclick="user_move(5, Player_Letter());" /></td>
</tr>

<tr>
<td>
<input type="text" size="1" name="square6" readonly
onclick="user_move(6, Player_Letter());" /></td>
<td align="center">
<input type="text" size="1" name="square7" readonly
onclick="user_move(7, Player_Letter());" /></td>
<td align="right">
<input type="text" size="1" name="square8" readonly
onclick="user_move(8, Player_Letter());" /></td>
</tr>

<tr>
<td colspan="3">
<p align="center">
<input type="button" value="لعبة جديده"
onclick="new_game();
play();" /></td>
</tr>

</table>
</form>
</body>
</html>
<!--
لا اسمح ولا ابيح ولا احلل من يزيل الحقوق
جميع الحقوق محفوظة لـ زووم بي اتش بي
(zoom-php)
للتواصل وطلب الاكواد و البرمجيات
[email protected] (http://www.cloudflare.com/email-protection)
-->
</code> </code>


والشكر موصول للاخ محمد صاحب العضوية لاعارته عضويته الخاصه لي .

وتحياتي
ZooM-PHP






ألعاب الأندرويد مجانا و حصريا (http://www.apotox.info/forum)



https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-ash4/482113_236967293114455_1193518507_n.png (http://www.dzbatna.com)
©المشاركات المنشورة تعبر عن وجهة نظر صاحبها فقط، ولا تُعبّر بأي شكل من الأشكال عن وجهة نظر إدارة المنتدى (http://www.dzbatna.com)©

استعمل مربع البحث في الاسفل لمزيد من المواضيع


سريع للبحث عن مواضيع في المنتدى