Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
M
mangala-pardusacikhack
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Tuğba Fıçıcı
mangala-pardusacikhack
Commits
23dba29f
Kaydet (Commit)
23dba29f
authored
May 05, 2021
tarafından
Muaz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Medium seviye robot eklendi.
Robota karşı oynama modu için yeni seviye eklendi.
üst
2226de01
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
115 additions
and
14 deletions
+115
-14
robotGameArea.js
pages/robotGameArea.js
+115
-14
No files found.
pages/robotGameArea.js
Dosyayı görüntüle @
23dba29f
const
zorlukDerecesi
=
2
;
class
Hole
{
constructor
(
value
,
id
)
{
this
.
id
=
id
;
this
.
value
=
value
;
this
.
addedDotcount
=
0
;
}
getID
(){
return
this
.
id
.
toString
();
}
getValue
(){
return
Number
(
this
.
value
);
}
}
async
function
wait
(
ms
)
{
async
function
wait
(
x
)
{
setTimeout
(()
=>
{
console
.
log
(
"Done waiting"
);
robotEasy
();
if
(
zorlukDerecesi
==
1
){
robotEasy
();
}
if
(
player
==
1
){
wait
(
2000
);
wait
(
x
);
}
},
ms
)
},
x
)
}
...
...
@@ -48,14 +59,24 @@ function tikla(id){
boncukCiz
();
}
}
else
if
(
Number
(
id
[
4
])
==
2
&&
player
==
Number
(
id
[
4
])){
}
else
if
(
Number
(
id
[
4
])
==
2
&&
player
==
Number
(
id
[
4
])){
//kullanici tikladiginda
if
(
user2hole
[
Number
(
id
[
9
])
-
1
].
value
!=
0
){
player
=
1
;
//bu burada kalmali
dagit
(
Number
(
id
[
4
]),
Number
(
id
[
9
]));
boncukCiz
();
wait
(
2000
);
if
(
zorlukDerecesi
==
2
){
while
(
player
==
1
){
robotMedium
();
}
}
else
{
if
(
player
==
1
){
wait
(
2000
);
}
}
...
...
@@ -109,7 +130,7 @@ function dagit(user,hole){
///##################
//player 1 (ustteki) icin oynu kurallari
sonHole
=
holeID
-
1
;
let
sonHole
=
holeID
-
1
;
console
.
log
(
sonHole
,
".....sonhole"
);
console
.
log
(
sira
,
".....sira"
);
if
(
sonHole
==
6
){
// son tas kendi hazinendeyse sira tekrar sende
...
...
@@ -273,13 +294,7 @@ function boncukCiz(){
function
robotEasy
(){
// player 1 i kontrol eden robot
let
x
=
0
;
let
array
=
[];
for
(
let
k
=
0
;
k
<
6
;
k
++
){
if
(
user1hole
[
k
].
value
!=
0
){
array
.
push
(
k
);
}
}
let
array
=
doluHoleler
();
let
len
=
array
.
length
;
if
(
len
>
0
){
let
holeID
=
Math
.
floor
(
Math
.
random
()
*
100000
)
%
len
;
...
...
@@ -287,6 +302,92 @@ function robotEasy(){
}
}
function
robotMedium
(){
let
array
=
doluHoleler
();
let
len
=
array
.
length
;
let
score_ar
=
[];
// dolu hucrelerle ayni indisle
if
(
len
>
0
){
var
temp1
=
[];
var
temp2
=
[];
for
(
let
i
=
0
;
i
<
7
;
i
++
)
{
temp1
.
push
(
new
Hole
(
user1hole
[
i
].
getValue
(),
user1hole
[
i
].
getID
()));
temp2
.
push
(
new
Hole
(
user2hole
[
i
].
getValue
(),
user2hole
[
i
].
getID
()));
};
bosalt
();
console
.
log
(
"ilk bosalt sonrasi user1hoel uzunnlugu: "
,
user1hole
.
length
);
console
.
log
(
"ilk bosalt sonrasi user2hole uzunnlugu: "
,
user2hole
.
length
);
/*
console.log("robotMedium hesaplama basliyor..");
console.log("temp1[0].value: ", temp1[0].value);
console.log("user1hole[0].value: ", user1hole[0].value);
console.log("atamar yapiliyor..");
temp1[0].value = 100;
user1hole[0].value = 999;
console.log("temp1[0].value: ", temp1[0].getValue());
console.log("user1hole[0].value: ", user1hole[0].getValue());
player = 2;
*/
for
(
let
k
=
0
;
k
<
array
.
length
;
k
++
){
// dolu hocre sayisi kadar don
let
denenecek_hole_indis
=
array
[
k
];
// dolu hucresinin indisini al
console
.
log
(
"hole ,"
,
denenecek_hole_indis
,
", deneniyor."
);
bosalt
();
for
(
let
i
=
0
;
i
<
7
;
i
++
)
{
user1hole
.
push
(
new
Hole
(
temp1
[
i
].
getValue
(),
temp1
[
i
].
getID
()));
user2hole
.
push
(
new
Hole
(
temp2
[
i
].
getValue
(),
temp2
[
i
].
getID
()));
};
console
.
log
(
"dagitim sonrasi user1hole uzunnlugu: "
,
user1hole
.
length
);
console
.
log
(
"dagitim öncesi hazine: "
,
user1hole
[
6
].
value
);
//tikla("user1hole"+(denenecek_hole_indis+1).toString()+"x"); // dolu hucreyi dagittini dusun
dagit
(
1
,
denenecek_hole_indis
+
1
);
console
.
log
(
"dagitim sonrasi hazine: "
,
user1hole
[
6
].
value
);
score_ar
[
k
]
=
user1hole
[
6
].
getValue
();
// dolu hucre dagilitdiktan sonra hazinenin degerini al ve score ar.ine ata
}
// her dolu kutu denendikten sonra hazineyi encok arttıran adimi sec
bosalt
();
for
(
let
i
=
0
;
i
<
7
;
i
++
)
{
user1hole
.
push
(
new
Hole
(
temp1
[
i
].
getValue
(),
temp1
[
i
].
getID
()));
user2hole
.
push
(
new
Hole
(
temp2
[
i
].
getValue
(),
temp2
[
i
].
getID
()));
};
let
max
=
0
;
let
max_indis
=
0
;
for
(
let
a
=
0
;
a
<
score_ar
.
length
;
a
++
){
// en yuksek hazine degerini bul
if
(
score_ar
[
a
]
>=
max
){
max
=
score_ar
[
a
];
max_indis
=
a
;
}
}
player
=
1
;
console
.
log
(
"en yuksek insdis########### "
,
array
[
max_indis
],
", tiklaniyor."
);
tikla
(
"user1hole"
+
(
array
[
max_indis
]
+
1
).
toString
()
+
"x"
);
}
}
function
bosalt
(){
while
(
user1hole
.
length
>
0
){
user1hole
.
pop
();
}
while
(
user2hole
.
length
>
0
){
user2hole
.
pop
();
}
}
function
doluHoleler
(){
// robotun oynacagi hole'u secmek icin, dolu olanlari bulan fonk.
let
x
=
0
;
let
array
=
[];
for
(
let
k
=
0
;
k
<
6
;
k
++
){
if
(
user1hole
[
k
].
getValue
()
!=
0
){
array
.
push
(
k
);
}
}
return
array
;
}
var
clicks
=
0
;
function
counterUp
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment