Implementasi Metode Generate and Test Dalam Penyelesaian Puzzle 2048 Berbasis Mobile
LAMPIRAN A
using UnityEngine;
using System.Collections;
public class AI : MonoBehaviour
{
#region var
private string[] strRandSpawn5 = new string[5];
private int intCurSpawn5 = 0;
public struct Node
{
public string strNodeId;
public string strNodeIdParent;
public string strNodeIdChild;
public int intHighNum;
public int intSpaceLeft;
public int intSpawnPos;
public string OwnBoard;
public string strDirection;
public bool isIdle;
}
public Node[] myNode = new Node[1364];
public string strSaveDataAIArah = "";
public string strSaveDataAISpawn = "";
public controller_Gameplay myController_Gameplay;
public Module myModule;
#endregion
public void setNodeID()
{
int intCurArah = 1;
int intIdxParent = -1;
for (int i = 0; i < myNode.Length; i++)
{
if (i < 4)
{
myNode[i].strNodeIdParent = "";
myNode[i].strNodeId = intCurArah.ToString() +
"0000";
}
else
{
myNode[i].strNodeIdParent =
myNode[intIdxParent].strNodeId;
if (i < 20) myNode[i].strNodeId =
myNode[i].strNodeIdParent.Substring(0, 1) + intCurArah.ToString() +
"000"; // 16 + 4
else if (i < 84) myNode[i].strNodeId =
myNode[i].strNodeIdParent.Substring(0, 2) + intCurArah.ToString() + "00";
// 64 + 16 + 4
A- 1 -
Universitas Sumatera Utara
LAMPIRAN A
else if (i < 340) myNode[i].strNodeId =
myNode[i].strNodeIdParent.Substring(0, 3) + intCurArah.ToString() + "0";
// 256 + 64 + 16 + 4
else if (i < 1364) myNode[i].strNodeId =
myNode[i].strNodeIdParent.Substring(0, 4) + intCurArah.ToString(); //
1024 + 256 + 64 + 16 + 4
}
setNodeStrDirection(i, intCurArah);
intCurArah++;
if (intCurArah > 4)
{
intCurArah = 1;
intIdxParent++;
}
}
}
void setNodeStrDirection(int idx, int dir)
{
switch (dir)
{
case 1: myNode[idx].strDirection = "Up";
break;
case 2: myNode[idx].strDirection = "Down";
break;
case 3: myNode[idx].strDirection = "Left";
break;
case 4: myNode[idx].strDirection = "Right";
break;
}
}
public void resetNode()
{
for (int i = 0; i < myNode.Length; i++)
{
myNode[i].intHighNum = 0;
myNode[i].intSpaceLeft = 0;
myNode[i].intSpawnPos = -1;
myNode[i].OwnBoard = "";
myNode[i].isIdle = false;
}
strSaveDataAIArah = "";
strSaveDataAISpawn = "";
for (int j = 0; j < strRandSpawn5.Length; j++)
strRandSpawn5[j] =
myModule.RandomItemInString("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15");
ContinueAI();
}
void simulator4(int idxMyNode)
{
bool bAdd = false;
//declare the iBoard as template for move test
int[][] iBoard;
iBoard = new int[4][];
A- 2 -
Universitas Sumatera Utara
LAMPIRAN A
for (int i = 0; i < 4; i++)
{
iBoard[i] = new int[4];
}
int idxString = 1;
if (idxMyNode < 4)
{
idxString = 1;
for (int d = 0; d < 4; d++)
{
for (int e = 0; e < 4; e++)
{
int.TryParse(myModule.GetItemPos(myController_Gameplay.strMasterBoa
rd, idxString), out iBoard[e][d]);
idxString++;
}
}
}
else if (idxMyNode >= 4)
{
idxString = 1;
//find the parent Node
int idxParentGet = findIdxParent(idxMyNode);
for (int a = 0; a < myNode.Length; a++)
{
if (myNode[a].strNodeId ==
myNode[idxMyNode].strNodeIdParent)
{
idxParentGet = a;
break;
}
}
//pass the parent's OwnBoard to iBoard
for (int b = 0; b < 4; b++)
{
for (int c = 0; c < 4; c++)
{
int.TryParse(myModule.GetItemPos(myNode[idxParentGet].OwnBoard,
idxString), out iBoard[c][b]);
idxString++;
}
}
}
int idxPick = 1;
int intNextSpawn = -1;
bool bolSpawn = false;
//find appropriate spot to spawn next Number from
strRandSpawn5
while (!bolSpawn && idxPick = 0; i--)
{
for (int k = i - 1; k >= 0; k--)
{
if (iBoard[k][j] == 0)
{
continue;
}
else if (iBoard[k][j] ==
iBoard[i][j])
{
iBoard[i][j] *= 2;
iBoard[k][j] = 0;
bAdd = true;
break;
}
else
{
if (iBoard[i][j] == 0 &&
iBoard[k][j] != 0)
{
iBoard[i][j] =
iBoard[k][j];
iBoard[k][j] = 0;
i++;
bAdd = true;
break;
}
else if (iBoard[i][j] != 0)
{
break;
}
}
}
}
}
break;
case "Down":
for (int i = 0; i < 4; i++)
{
for (int j = 3; j >= 0; j--)
{
for (int k = j - 1; k >= 0; k--)
{
if (iBoard[i][k] == 0)
{
continue;
}
else if (iBoard[i][k] ==
iBoard[i][j])
{
A- 5 -
Universitas Sumatera Utara
LAMPIRAN A
iBoard[i][j] *= 2;
iBoard[i][k] = 0;
bAdd = true;
break;
}
else
{
if (iBoard[i][j] == 0 &&
iBoard[i][k] != 0)
{
iBoard[i][j] =
iBoard[i][k];
iBoard[i][k] = 0;
j++;
bAdd = true;
break;
}
else if (iBoard[i][j] != 0)
{
break;
}
}
}
}
}
break;
case "Left":
for (int j = 0; j < 4; j++)
{
for (int i = 0; i < 4; i++)
{
for (int k = i + 1; k < 4; k++)
{
if (iBoard[k][j] == 0)
{
continue;
}
else if (iBoard[k][j] ==
iBoard[i][j])
{
iBoard[i][j] *= 2;
iBoard[k][j] = 0;
bAdd = true;
break;
}
else
{
if (iBoard[i][j] == 0 &&
iBoard[k][j] != 0)
{
iBoard[i][j] =
iBoard[k][j];
iBoard[k][j] = 0;
i--;
bAdd = true;
break;
}
A- 6 -
Universitas Sumatera Utara
LAMPIRAN A
else if (iBoard[i][j] != 0)
{
break;
}
}
}
}
}
break;
}
// save spawnPos....ownBoard...highestPoint....
spaceLeft.....
// convert back to string
string strBoardResult = "";
int inthighNum = 0;
int intFreeSpots = 0;
for (int m = 0; m < 4; m++)
{
for (int n = 0; n < 4; n++)
{
strBoardResult =
myModule.AddItem(strBoardResult, iBoard[n][m].ToString());
if (iBoard[n][m] > inthighNum) inthighNum =
iBoard[n][m];
if (iBoard[n][m] == 0) intFreeSpots += 1;
}
}
myNode[idxMyNode].intSpawnPos = intNextSpawn;
myNode[idxMyNode].OwnBoard = strBoardResult;
myNode[idxMyNode].intHighNum = inthighNum;
myNode[idxMyNode].intSpaceLeft = intFreeSpots;
if (!bAdd) myNode[idxMyNode].isIdle = true;
else
{
if (idxMyNode < 4) myNode[idxMyNode].isIdle =
false;
else //follow the parent's idle stat
{
myNode[idxMyNode].isIdle =
myNode[findIdxParent(idxMyNode)].isIdle;
}
}
}
else print("GAMEOVER");
}
void ContinueAI()
{
//simulate result
for (int k = 0; k < myNode.Length; k++)
{
if (k == 0) intCurSpawn5 = 0;
else if (k == 4) intCurSpawn5 = 1;
else if (k == 20) intCurSpawn5 = 2;
A- 7 -
Universitas Sumatera Utara
LAMPIRAN A
else if (k == 84) intCurSpawn5 = 3;
else if (k == 340) intCurSpawn5 = 4;
simulator4(k);
}
//get bottom best value
int getTmpIdx = 340;
int intHighNum = 0;
int intSpaceLeft = 0;
for (int v = 340; v < myNode.Length; v++)
{
if (!myNode[v].isIdle && ((intHighNum <
myNode[v].intHighNum) || (intHighNum == myNode[v].intHighNum &&
intSpaceLeft < myNode[v].intSpaceLeft)))
{
getTmpIdx = v;
intHighNum = myNode[v].intHighNum;
intSpaceLeft = myNode[v].intSpaceLeft;
}
}
//trace up
for (int w = 5; w > 0; w--)
{
strSaveDataAIArah =
myModule.AddItemReversed(strSaveDataAIArah,
myNode[getTmpIdx].strDirection);
strSaveDataAISpawn =
myModule.AddItemReversed(strSaveDataAISpawn,
myNode[getTmpIdx].intSpawnPos.ToString());
for (int x = 0; x < myNode.Length; x++)
{
if (myNode[x].strNodeId ==
myNode[getTmpIdx].strNodeIdParent)
{
getTmpIdx = x;
}
}
}
myController_Gameplay.intUpdate = 10;
}
int findIdxParent(int idxChild)
{
int idxParentGet = -1;
for (int a = 0; a < myNode.Length; a++)
{
if (myNode[a].strNodeId ==
myNode[idxChild].strNodeIdParent)
{
idxParentGet = a;
break;
}
}
return idxParentGet;
}
A- 8 -
Universitas Sumatera Utara
LAMPIRAN A
}
A- 9 -
Universitas Sumatera Utara
LAMPIRAN B
using UnityEngine;
using System.Collections;
[System.Serializable]
public class Box2048
{
public int intIdx;
public int intKol;
public int intBrs;
public float posX;
public float posY;
public int FillNum;
}
[System.Serializable]
public class Number2048
{
public int intIdx;
public int intKol;
public int intBrs;
public float posX;
public float posY;
public int Number;
public GameObject GO;
}
public class controller_Gameplay : MonoBehaviour
{
#region var
public int intUpdate = -1;
public bool isInput = false;
public int intWaitMove;
public bool bolAllMove = false;
public Box2048[] myBox = new Box2048[16];
public Number2048[] myNumber = new Number2048[16];
public bool[] isNumberMove = new bool[16];
private int intCountMove = -1;
private int intCurSpawn = -1;
private string strCurMove = "";
public AI myAI;
public string strMasterBoard = "";
public Module myModule;
#endregion
// Use this for initialization
void Start () {
//print("void start");
for (int i = 0; i < myBox.Length; i++)
{
myBox[i].intIdx = i;
myBox[i].intKol = (i % 4);
myBox[i].intBrs = (i / 4);
myBox[i].posX = -4.0f + (2.0f * (i % 4));
myBox[i].posY = 3.0f - (2.0f * (i / 4));
B- 1 -
Universitas Sumatera Utara
LAMPIRAN B
myBox[i].FillNum = 0;
myNumber[i].intIdx
myNumber[i].intKol
myNumber[i].intBrs
myNumber[i].posX =
myNumber[i].posY =
myNumber[i].Number
= i;
= (i % 4);
= (i / 4);
-4.0f + (2.0f * (i % 4));
3.0f - (2.0f * (i / 4));
= 0;
}
myAI.setNodeID();
intUpdate = 5;
}
// Update is called once per frame
void Update()
{
switch (intUpdate)
{
case 0: break;
case 5: intUpdate = 0;
callAI();
break;
case 10: intUpdate = 0;
intCountMove = 0;
intUpdate = 15;
break;
case 15: intUpdate = 0;
intCountMove++;
if (intCountMove > 5) intUpdate = 5;
else
{
int.TryParse(myModule.GetItemPos(myAI.strSaveDataAISpawn,intCountMo
ve),out intCurSpawn);
strCurMove =
myModule.GetItemPos(myAI.strSaveDataAIArah, intCountMove);
intUpdate = 20;
}
break;
case 20: intUpdate = 0;
spawnNumber(intCurSpawn);
break;
case 25: intUpdate = 0;
moveNumber(strCurMove);
break;
case 30: intUpdate = 0;
checkGameOver();
break;
case 40: intUpdate = 0;
GameObject.Find("EventSystem").SendMessage("Finish");
GUI.Box(new Rect(0, 0, Screen.width, Screen.height),
"The game ends /n the time is "+ Time.time);
break;
case 500 : if (Input.GetKeyDown(KeyCode.Space))
{
intUpdate = 0;
B- 2 -
Universitas Sumatera Utara
LAMPIRAN B
afterMove();
}
break;
}
}
void callAI()
{
//print("void callAI");
//convert currentBoard to string
strMasterBoard = "";
for (int i = 0; i < myNumber.Length; i++) strMasterBoard =
myModule.AddItem(strMasterBoard, myNumber[i].Number.ToString());
//call AI to start
myAI.resetNode();
}
void spawnNumber(int intPosSpawn)
{
//print("void spawnNumber");
myBox[intPosSpawn].FillNum = 2;
myNumber[intPosSpawn].Number = 2;
myNumber[intPosSpawn].GO =
Instantiate(Resources.Load("Numbers/GO_2")) as GameObject;
myNumber[intPosSpawn].GO.transform.position = new
Vector3(myNumber[intPosSpawn].posX, myNumber[intPosSpawn].posY, 0.0f);
intUpdate = 25;
}
public void moveNumber(string direction)
{
//print("void moveNumber");
//set EndPos (order based on direction)
//#######################################//
#region RIGHT
if (direction == "Right")
{
for (int j = 0; j < 4; j++)
{
for (int i = 3; i >= 0; i--)
{
for (int k = i - 1; k >= 0; k--)
{
if (myBox[(4 * j) + k].FillNum == 0)
{
continue;
}
else if (myBox[(4 * j) + k].FillNum ==
myBox[(4 * j) + i].FillNum)
{
myNumber[(4 * j) +
k].GO.GetComponent().endPos = new
Vector3(myNumber[(4 * j) + i].posX, myNumber[(4 * j) + k].posY, 0.0f);
myNumber[(4 * j) +
k].GO.GetComponent().interval =
Mathf.Abs(myBox[(4 * j) + k].intKol - myBox[(4 * j) + i].intKol);
B- 3 -
Universitas Sumatera Utara
LAMPIRAN B
isNumberMove[(4 * j) + k] = true;
myBox[(4 * j) + i].FillNum *= 2;
myBox[(4 * j) + k].FillNum = 0;
break;
}
else
{
if (myBox[(4 * j) + i].FillNum ==
0 && myBox[(4 * j) + k].FillNum != 0)
{
myNumber[(4 * j) +
k].GO.GetComponent().endPos = new
Vector3(myNumber[(4 * j) + i].posX, myNumber[(4 * j) + k].posY, 0.0f);
myNumber[(4 * j) +
k].GO.GetComponent().interval =
Mathf.Abs(myBox[(4 * j) + k].intKol - myBox[(4 * j) + i].intKol);
isNumberMove[(4 * j) + k] =
true;
myBox[(4 * j) + i].FillNum
= myBox[(4 * j) + k].FillNum;
myBox[(4 * j) + k].FillNum
= 0;
i++;
break;
}
else if (myBox[(4 * j) +
i].FillNum != 0)
{
break;
}
}
}
}
}
}
#endregion
//#######################################//
#region LEFT
if (direction == "Left")
{
for (int j = 0; j < 4; j++)
{
for (int i = 0; i < 4; i++)
{
for (int k = i + 1; k < 4; k++)
{
if (myBox[(4*j)+k].FillNum == 0)
{
continue;
}
else if (myBox[(4 * j) + k].FillNum ==
myBox[(4 * j) + i].FillNum)
{
myNumber[(4 * j) +
k].GO.GetComponent().endPos = new
Vector3(myNumber[(4 * j) + i].posX, myNumber[(4 * j) + k].posY, 0.0f);
B- 4 -
Universitas Sumatera Utara
LAMPIRAN B
myNumber[(4 * j) +
k].GO.GetComponent().interval =
Mathf.Abs(myBox[(4 * j) + k].intKol - myBox[(4 * j) + i].intKol);
isNumberMove[(4 * j) + k] = true;
myBox[(4 * j) + i].FillNum *= 2;
myBox[(4*j)+k].FillNum = 0;
break;
}
else
{
if (myBox[(4 * j) + i].FillNum ==
0 && myBox[(4 * j) + k].FillNum != 0)
{
myNumber[(4 * j) +
k].GO.GetComponent().endPos = new
Vector3(myNumber[(4 * j) + i].posX, myNumber[(4 * j) + k].posY, 0.0f);
myNumber[(4 * j) +
k].GO.GetComponent().interval =
Mathf.Abs(myBox[(4 * j) + k].intKol - myBox[(4 * j) + i].intKol);
isNumberMove[(4 * j) + k] =
true;
myBox[(4 * j) + i].FillNum
= myBox[(4 * j) + k].FillNum;
myBox[(4 * j) + k].FillNum
= 0;
i--;
break;
}
else if (myBox[(4 * j) +
i].FillNum != 0)
{
break;
}
}
}
}
}
}
#endregion
//#######################################//
#region DOWN
if (direction == "Down")
{
for (int i = 0; i < 4; i++)
{
for (int j = 3; j >= 0; j--)
{
for (int k = j - 1; k >= 0; k--)
{
if (myBox[(4 * k) + i].FillNum == 0)
//kosong jd tidak ad yg perlu digeser
{
continue;
}
else if (myBox[(4 * k) + i].FillNum ==
myBox[(4 * j) + i].FillNum) //timpa... nilai sama.... jd tujuan x2...
asal jd nol krn digeser
B- 5 -
Universitas Sumatera Utara
LAMPIRAN B
{
myNumber[(4 * k) +
i].GO.GetComponent().endPos = new
Vector3(myNumber[(4 * k) + i].posX, myNumber[(4 * j) + i].posY, 0.0f);
myNumber[(4 * k) +
i].GO.GetComponent().interval =
Mathf.Abs(myBox[(4 * k) + i].intBrs - myBox[(4 * j) + i].intBrs);
isNumberMove[(4 * k) + i] = true;
myBox[(4 * j) + i].FillNum *= 2;
myBox[(4 * k) + i].FillNum = 0;
break;
}
else
{
if (myBox[(4 * j) + i].FillNum ==
0 && myBox[(4 * k) + i].FillNum != 0) //geser masuk.... tujuan jd ad
nilai.... asal jd nol krn digeser
{
myNumber[(4 * k) +
i].GO.GetComponent().endPos = new
Vector3(myNumber[(4 * k) + i].posX, myNumber[(4 * j) + i].posY, 0.0f);
myNumber[(4 * k) +
i].GO.GetComponent().interval =
Mathf.Abs(myBox[(4 * k) + i].intBrs - myBox[(4 * j) + i].intBrs);
isNumberMove[(4 * k) + i] =
true;
myBox[(4 * j) + i].FillNum
= myBox[(4 * k) + i].FillNum;
myBox[(4 * k) + i].FillNum
= 0;
j++;
break;
}
else if (myBox[(4 * j) +
i].FillNum != 0)//tdk bisa geser krn nilai beda
{
break;
}
}
}
}
}
}
#endregion
//#######################################//
#region UP
if (direction == "Up")
{
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
for (int k = j + 1; k < 4; k++)
{
if (myBox[(4 * k) + i].FillNum == 0)
//kosong jd tidak ad yg perlu digeser
{
B- 6 -
Universitas Sumatera Utara
LAMPIRAN B
continue;
}
else if (myBox[(4 * k) + i].FillNum ==
myBox[(4 * j) + i].FillNum) //timpa... nilai sama.... jd tujuan x2...
asal jd nol krn digeser
{
myNumber[(4 * k) +
i].GO.GetComponent().endPos = new
Vector3(myNumber[(4 * k) + i].posX, myNumber[(4 * j) + i].posY, 0.0f);
myNumber[(4 * k) +
i].GO.GetComponent().interval =
Mathf.Abs(myBox[(4 * k) + i].intBrs - myBox[(4 * j) + i].intBrs);
isNumberMove[(4 * k) + i] = true;
myBox[(4 * j) + i].FillNum *= 2;
myBox[(4 * k) + i].FillNum = 0;
break;
}
else
{
if (myBox[(4 * j) + i].FillNum ==
0 && myBox[(4 * k) + i].FillNum != 0) //geser masuk.... tujuan jd ad
nilai.... asal jd nol krn digeser
{
myNumber[(4 * k) +
i].GO.GetComponent().endPos = new
Vector3(myNumber[(4 * k) + i].posX, myNumber[(4 * j) + i].posY, 0.0f);
myNumber[(4 * k) +
i].GO.GetComponent().interval =
Mathf.Abs(myBox[(4 * k) + i].intBrs - myBox[(4 * j) + i].intBrs);
isNumberMove[(4 * k) + i] =
true;
myBox[(4 * j) + i].FillNum
= myBox[(4 * k) + i].FillNum;
myBox[(4 * k) + i].FillNum
= 0;
j--;
break;
}
else if (myBox[(4 * j) +
i].FillNum != 0)//tdk bisa geser krn nilai beda
{
break;
}
}
}
}
}
}
#endregion
intWaitMove = 0;
bool isSthMove = false;
for (int k = 0; k < myNumber.Length; k++)
{
if (isNumberMove[k])
{
intWaitMove++;
B- 7 -
Universitas Sumatera Utara
LAMPIRAN B
myNumber[k].GO.GetComponent().startPos =
new Vector3(myNumber[k].posX, myNumber[k].posY, 0.0f);
myNumber[k].GO.GetComponent().startTime =
Time.time;
myNumber[k].GO.GetComponent().journeyLength
=
Vector3.Distance(myNumber[k].GO.GetComponent().st
artPos, myNumber[k].GO.GetComponent().endPos);
myNumber[k].GO.GetComponent().isMoveable =
true;
isSthMove = true;
}
}
if (isSthMove) bolAllMove = true;
else decreaseIntWaitMove();
}
public void decreaseIntWaitMove()
{
//print("void decreaseIntWaitMove...");
intWaitMove--;
//print("hasil pengurangan..." + intWaitMove.ToString());
if (intWaitMove 0)
{
myNumber[i].GO.transform.position = new
Vector3(myNumber[i].posX, myNumber[i].posY, 0.0f);
GameObject.Destroy(myNumber[i].GO.gameObject);
}
myNumber[i].Number = myBox[i].FillNum;
if (myNumber[i].Number > 0)
{
myNumber[i].GO =
Instantiate(Resources.Load("Numbers/GO_" +
myNumber[i].Number.ToString())) as GameObject;
myNumber[i].GO.transform.position = new
Vector3(myNumber[i].posX, myNumber[i].posY, 0.0f);
}
B- 8 -
Universitas Sumatera Utara
LAMPIRAN B
if (myNumber[i].Number == 2048)
{
GameObject.Find("EventSystem").SendMessage("Finish");
}
if (myNumber[i].Number == 1024)
{
GameObject.Find("EventSystem").SendMessage("Catat");
}
isNumberMove[i] = false;
}
//can Spawn ???
bool canSpawn = false;
for (int j = 0; j < myBox.Length; j++)
{
if (myBox[j].FillNum == 0)
{
canSpawn = true;
break;
}
}
//print("void afterMove => cek Can Spawn???");
if (canSpawn)
intUpdate = 15;
else
intUpdate = 30;
}
void checkGameOver()
{
//print("void checkGameOver");
bool isPlayable = false;
for (int j = 0; j < myNumber.Length; j++)
{
//not mostLeft
if (j % 4 != 0)
{
if (myNumber[j].Number == myNumber[j - 1].Number)
{
isPlayable = true;
break;
}
}
//NOT mostRight
else if (j % 4 != 3)
{
if (myNumber[j].Number == myNumber[j + 1].Number)
{
isPlayable = true;
break;
}
}
//not mostTop
else if (j / 4 != 0)
B- 9 -
Universitas Sumatera Utara
LAMPIRAN B
{
if (myNumber[j].Number == myNumber[j - 4].Number)
{
isPlayable = true;
break;
}
}
//not mostBottom
else if (j / 4 != 3)
{
if (myNumber[j].Number == myNumber[j + 4].Number)
{
isPlayable = true;
break;
}
}
}
if (isPlayable) intUpdate = 10;
else intUpdate = 40;
}
}
B- 10 -
Universitas Sumatera Utara
LAMPIRAN C
using UnityEngine;
using System.Collections;
public class controller_moveAnimTes : MonoBehaviour {
//tes
public GameObject myGO_AnimTes;
public controller_Gameplay myGameplayScript;
public Vector3 startPos;
public Vector3 endPos;
public Vector4 startColor;
public Vector4 endColor;
public float speed = 1.0f;
public float interval = 1.0f;
public float startTime;
public float journeyLength;
private float colorLength;
public bool isMoveable;
// Use this for initialization
void Start () {
//tes
myGameplayScript =
GameObject.Find("Controller_Gameplay").GetComponent(
);
////print("GO found");
speed = 15.0f;
startTime = Time.time;
journeyLength = Vector3.Distance(startPos, endPos);
//startColor = new
Vector4(this.gameObject.GetComponent().color.r,
this.gameObject.GetComponent().color.r,
this.gameObject.GetComponent().color.r, 1.0f);
//endColor = new
Vector4(this.gameObject.GetComponent().color.r,
this.gameObject.GetComponent().color.r,
this.gameObject.GetComponent().color.r, 0.0f);
//colorLength = Vector4.Distance(startColor, endColor);
//----------------//
}
// Update is called once per frame
void Update()
{
if (isMoveable && myGameplayScript.bolAllMove)
{
//print("initial calculate ");
float distCovered = (Time.time - startTime) * speed *
interval;
float fracJourney = distCovered / journeyLength;
//print("about to transform");
myGO_AnimTes.transform.position = Vector3.Lerp(startPos,
endPos, fracJourney);
//print("transform is done ");
if (myGO_AnimTes.transform.position == endPos)
{
C-- 1 --
Universitas Sumatera Utara
LAMPIRAN C
isMoveable = false;
myGameplayScript.decreaseIntWaitMove();
}
//float fadeCovered = (Time.time - startTime) * speed;
//float fracFading = fadeCovered / colorLength;
//myGO_AnimTes.GetComponent().color =
Vector4.Lerp(startColor, endColor, fracFading);
}
}
}
C-- 2 --
Universitas Sumatera Utara
LAMPIRAN C
using UnityEngine;
using System.Collections;
public class Module : MonoBehaviour {
public string AddItem(string sourceString, string addString)
{
string temp = sourceString;
if (temp == "")
{
temp += addString;
}
else
{
temp += "," + addString;
}
return temp;
}
public string AddItemReversed(string sourceString, string
addString)
{
string temp = sourceString;
if (temp == "")
{
temp += addString;
}
else
{
temp = addString + "," + temp;
}
return temp;
}
public string RandomItemInString(string pstr)
{
int roundDirection;
string temp1 = pstr;
string temp2 = "";
int maxItem = GetItemCount(pstr);
int maxRound = Random.Range(5, 10);
int front = 1;
int last = maxItem;
for (int i = 1; i < maxRound; i++)
{
if (temp2 != "")
{
temp1 = temp2;
temp2 = "";
}
front = 1;
last = maxItem;
for (int j = 1; j = pos)
{
return temp;
}
temp = "";
count += 1;
}
else
{
temp += pstr.Substring(i, 1);
C-4-
Universitas Sumatera Utara
LAMPIRAN C
}
}
if ((count + 1) < pos) temp = "";
return temp;
}
}
C-5-
Universitas Sumatera Utara
LAMPIRAN D
using UnityEngine;
using System.Collections;
public class Module : MonoBehaviour {
public string AddItem(string sourceString, string addString)
{
string temp = sourceString;
if (temp == "")
{
temp += addString;
}
else
{
temp += "," + addString;
}
return temp;
}
public string AddItemReversed(string sourceString, string
addString)
{
string temp = sourceString;
if (temp == "")
{
temp += addString;
}
else
{
temp = addString + "," + temp;
}
return temp;
}
public string RandomItemInString(string pstr)
{
int roundDirection;
string temp1 = pstr;
string temp2 = "";
int maxItem = GetItemCount(pstr);
int maxRound = Random.Range(5, 10);
int front = 1;
int last = maxItem;
for (int i = 1; i < maxRound; i++)
{
if (temp2 != "")
{
temp1 = temp2;
temp2 = "";
}
front = 1;
last = maxItem;
for (int j = 1; j = pos)
{
return temp;
}
temp = "";
count += 1;
}
else
D-2-
Universitas Sumatera Utara
LAMPIRAN D
{
temp += pstr.Substring(i, 1);
}
}
if ((count + 1) < pos) temp = "";
return temp;
}
}
D-3-
Universitas Sumatera Utara
LAMPIRAN E
using UnityEngine;
using System.Collections;
public class tesKlik5 : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void OnMouseDown1()
{
Application.LoadLevel("Gameplay");
}
}
E-1-
Universitas Sumatera Utara
LAMPIRAN F
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Timer : MonoBehaviour {
// Use this for initialization
public Text timerText;
public Text timerText2;
private float startTime;
private bool finished = false;
private float t1024;
void Start () {
startTime = Time.time;
}
// Update is called once per frame
void Update () {
if (finished == true)
Time.timeScale=0;
else {
float t = Time.time - startTime;
string minutes = ((int)t / 60).ToString
();
string seconds = (t % 60).ToString
("f2");
timerText.text = minutes + ":" +
seconds;
}
}
public void Finish()
{
finished = true;
timerText.color = Color.red;
}
public void Catat()
{
if (t1024 == 0) {
float t = Time.time - startTime;
string minutes = ((int)t / 60).ToString
();
string seconds = (t % 60).ToString
("f2");
timerText2.text = minutes + ":" +
seconds;
t1024++;
}
}
}
F-1-
Universitas Sumatera Utara
DAFTAR RIWAYAT HIDUP
Data Pribadi
Nama
:
Devina Pratiwi Halim
Tempat, tanggal Lahir :
Medan, 16 Mei 1992
Jenis Kelamin
Umur
:
:
Perempuan
24 tahun
Tinggi, berat badan
:
158cm , 55 kg
Agama
:
Buddha
Alamat
: Jalan Brig. Jend. Katamso GG. Baru No. 16 Medan
Status
:
Belum Kawin
Telepon
:
085767658992
Email
:
devinapratiwihalim@gmail.com
Latarbelakang Pendidikan :
Formal
1998 – 2004
2004 – 2007
2007 – 2010
2012 – 2015
2012 – 2016
2014
2015
: Lulusan SD Methodist 2 Medan
: Lulusan SMP Methodist 2 Medan
: Lulusan SMA Methodist 2 Medan
: Bachelor Jurusan Administrasi dan Finansial di Net Academy
: S1 Jurusan Akuntansi di Professional Management College
Indonesia
: Associate Chartered Financial Practitioner(AChFP) di Asia
Pacific Financial Services Association
: Fellow Chartered Financial Practitioner (FChFP) di Asia
Pacific Financial Services Association
Universitas Sumatera Utara
Non Formal
2006 – 2007
: Bimbingan bahasa Inggris di The British Institute
2007 – 2008
: Bimbingan Matematika di AXIS
2009
: Bimbingan 1 Tahun Program Komputer di VISITEK
2010
: Workshop Teknik Dasar Fotografi di Ikatan Mahasiswa S1 Ilmu
Komputer USU
2010
: Workshop Teknik Hacking di Ikatan Mahasiswa S1 Ilmu
Komputer USU
2010
: Workshop Setting Cisco Router di WEBMEDIA Training
Center
2011
: Panitia Seminar Teknologi Informasi di Universitas Sumatera
Utara
2012
: Peserta Lomba Problem Solving IMILKOM Contest 2012
2013
: Partisipasi dalam Galang Dana Lions Club
2013
: Workshop Mengenal Kopi di Starbucks Medan
2013
: Partisipasi dalam Seminar Orang Yang Kaya Orang Yang
Kreatif dari Professional Management College Indonesia
2015
: Liasion Officer (LO) Kegiatan Forum Rektor Indonesia XVII di
Universitas Sumatera Utara
2016
: Volunteer dalam partisipasi Education Expo
Pengalaman Organisasi
• 2006 – 2007
• 2010 – 2012
• 2013 – 2014
• 2014 – 2015
: Anggota dari Klub Teater Methodist 2 Medan
: Anggota dari Keluarga Mahasiswa Buddhis di Universitas
Sumatera Utara
: Anggota dari Singing Club di Professional Management College
Indonesia
: Pengurus Badan Eksekutif Mahasiswa di Professional
Management College Indonesia dengan jabatan Hubungan
Masyarakat Eksternal
Universitas Sumatera Utara
Penghargaan
• 2002
• 2007
• 2008
• 2008
• 2008
•
2009
: Penghargaan sebagai Juara X Reading-A di Language School
Best
: Penghargaan sebagai Peserta dalam mengikuti Pekan Olimpiade
Sekolah
: Penghargaan sebagai Juara II Kelas XI
: Penghargaan sebagai peserta dalam mengikuti Lomba Sains
Plus Antar Pelajar SMA Se-Sumut
: Penghargaan sebagai Peserta dalam mengikuti Pekan Olimpiade
Sekolah
: Penghargaan sebagai Peserta dalam Pekan Olimpiade Sekolah
Pengalaman Kerja
•
2009-2010
: Bekerja di Leny English Private Classes sebagai asisten pengajar
bahasa Inggris
• Praktek Kerja Lapangan:
Praktek Kerja Lapangan di di Kantor Pelayanan Perbendaharaan Negara Medan
Periode
: Agustus 2013 – Oktober 2013
Tujugan
: Mata Kuliah Wajib
Posisi
: Konsultan IT dan Programmer
Rincian Pekerjaan:
•
Memasang jaringan pada satu ruangan
•
Memasukkan biografi pegawai secara online pada website yang baru
•
Mengorganisir data 10 tahun dan lebih dan menyusunnya sehingga dapat di
akses seluruh departemen
•
Membangun sebuah program dengan menggunakan Microsoft Excel untuk
menangani pembayaran gaji pada semua unit di dalam departemen.
• 2014
: Bekerja di Scholars Hub sebagai pengajar sampai sekarang
• 2015
: Bekerja sebagai Agen Asuransi untuk Asuransi Panin Life Dai-ichi
sampai sekarang
Universitas Sumatera Utara
Kemampuan
•
Kemampuan Komputer
Office
1. Microsoft Word
2. Microsoft Excel
3. Microsoft Power Point
4. Microsoft Access
Design & Video
1. Adobe Photoshop
2. Adobe Dreamweaver
Pemrograman
1.
2.
3.
4.
5.
6.
Visual Studio
Eclipse
Visual Basic
Unity
MatLab
FoxPro
Medan, 2 Nopember 2016
Hormat saya,
Devina Pratiwi Halim
Universitas Sumatera Utara
using UnityEngine;
using System.Collections;
public class AI : MonoBehaviour
{
#region var
private string[] strRandSpawn5 = new string[5];
private int intCurSpawn5 = 0;
public struct Node
{
public string strNodeId;
public string strNodeIdParent;
public string strNodeIdChild;
public int intHighNum;
public int intSpaceLeft;
public int intSpawnPos;
public string OwnBoard;
public string strDirection;
public bool isIdle;
}
public Node[] myNode = new Node[1364];
public string strSaveDataAIArah = "";
public string strSaveDataAISpawn = "";
public controller_Gameplay myController_Gameplay;
public Module myModule;
#endregion
public void setNodeID()
{
int intCurArah = 1;
int intIdxParent = -1;
for (int i = 0; i < myNode.Length; i++)
{
if (i < 4)
{
myNode[i].strNodeIdParent = "";
myNode[i].strNodeId = intCurArah.ToString() +
"0000";
}
else
{
myNode[i].strNodeIdParent =
myNode[intIdxParent].strNodeId;
if (i < 20) myNode[i].strNodeId =
myNode[i].strNodeIdParent.Substring(0, 1) + intCurArah.ToString() +
"000"; // 16 + 4
else if (i < 84) myNode[i].strNodeId =
myNode[i].strNodeIdParent.Substring(0, 2) + intCurArah.ToString() + "00";
// 64 + 16 + 4
A- 1 -
Universitas Sumatera Utara
LAMPIRAN A
else if (i < 340) myNode[i].strNodeId =
myNode[i].strNodeIdParent.Substring(0, 3) + intCurArah.ToString() + "0";
// 256 + 64 + 16 + 4
else if (i < 1364) myNode[i].strNodeId =
myNode[i].strNodeIdParent.Substring(0, 4) + intCurArah.ToString(); //
1024 + 256 + 64 + 16 + 4
}
setNodeStrDirection(i, intCurArah);
intCurArah++;
if (intCurArah > 4)
{
intCurArah = 1;
intIdxParent++;
}
}
}
void setNodeStrDirection(int idx, int dir)
{
switch (dir)
{
case 1: myNode[idx].strDirection = "Up";
break;
case 2: myNode[idx].strDirection = "Down";
break;
case 3: myNode[idx].strDirection = "Left";
break;
case 4: myNode[idx].strDirection = "Right";
break;
}
}
public void resetNode()
{
for (int i = 0; i < myNode.Length; i++)
{
myNode[i].intHighNum = 0;
myNode[i].intSpaceLeft = 0;
myNode[i].intSpawnPos = -1;
myNode[i].OwnBoard = "";
myNode[i].isIdle = false;
}
strSaveDataAIArah = "";
strSaveDataAISpawn = "";
for (int j = 0; j < strRandSpawn5.Length; j++)
strRandSpawn5[j] =
myModule.RandomItemInString("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15");
ContinueAI();
}
void simulator4(int idxMyNode)
{
bool bAdd = false;
//declare the iBoard as template for move test
int[][] iBoard;
iBoard = new int[4][];
A- 2 -
Universitas Sumatera Utara
LAMPIRAN A
for (int i = 0; i < 4; i++)
{
iBoard[i] = new int[4];
}
int idxString = 1;
if (idxMyNode < 4)
{
idxString = 1;
for (int d = 0; d < 4; d++)
{
for (int e = 0; e < 4; e++)
{
int.TryParse(myModule.GetItemPos(myController_Gameplay.strMasterBoa
rd, idxString), out iBoard[e][d]);
idxString++;
}
}
}
else if (idxMyNode >= 4)
{
idxString = 1;
//find the parent Node
int idxParentGet = findIdxParent(idxMyNode);
for (int a = 0; a < myNode.Length; a++)
{
if (myNode[a].strNodeId ==
myNode[idxMyNode].strNodeIdParent)
{
idxParentGet = a;
break;
}
}
//pass the parent's OwnBoard to iBoard
for (int b = 0; b < 4; b++)
{
for (int c = 0; c < 4; c++)
{
int.TryParse(myModule.GetItemPos(myNode[idxParentGet].OwnBoard,
idxString), out iBoard[c][b]);
idxString++;
}
}
}
int idxPick = 1;
int intNextSpawn = -1;
bool bolSpawn = false;
//find appropriate spot to spawn next Number from
strRandSpawn5
while (!bolSpawn && idxPick = 0; i--)
{
for (int k = i - 1; k >= 0; k--)
{
if (iBoard[k][j] == 0)
{
continue;
}
else if (iBoard[k][j] ==
iBoard[i][j])
{
iBoard[i][j] *= 2;
iBoard[k][j] = 0;
bAdd = true;
break;
}
else
{
if (iBoard[i][j] == 0 &&
iBoard[k][j] != 0)
{
iBoard[i][j] =
iBoard[k][j];
iBoard[k][j] = 0;
i++;
bAdd = true;
break;
}
else if (iBoard[i][j] != 0)
{
break;
}
}
}
}
}
break;
case "Down":
for (int i = 0; i < 4; i++)
{
for (int j = 3; j >= 0; j--)
{
for (int k = j - 1; k >= 0; k--)
{
if (iBoard[i][k] == 0)
{
continue;
}
else if (iBoard[i][k] ==
iBoard[i][j])
{
A- 5 -
Universitas Sumatera Utara
LAMPIRAN A
iBoard[i][j] *= 2;
iBoard[i][k] = 0;
bAdd = true;
break;
}
else
{
if (iBoard[i][j] == 0 &&
iBoard[i][k] != 0)
{
iBoard[i][j] =
iBoard[i][k];
iBoard[i][k] = 0;
j++;
bAdd = true;
break;
}
else if (iBoard[i][j] != 0)
{
break;
}
}
}
}
}
break;
case "Left":
for (int j = 0; j < 4; j++)
{
for (int i = 0; i < 4; i++)
{
for (int k = i + 1; k < 4; k++)
{
if (iBoard[k][j] == 0)
{
continue;
}
else if (iBoard[k][j] ==
iBoard[i][j])
{
iBoard[i][j] *= 2;
iBoard[k][j] = 0;
bAdd = true;
break;
}
else
{
if (iBoard[i][j] == 0 &&
iBoard[k][j] != 0)
{
iBoard[i][j] =
iBoard[k][j];
iBoard[k][j] = 0;
i--;
bAdd = true;
break;
}
A- 6 -
Universitas Sumatera Utara
LAMPIRAN A
else if (iBoard[i][j] != 0)
{
break;
}
}
}
}
}
break;
}
// save spawnPos....ownBoard...highestPoint....
spaceLeft.....
// convert back to string
string strBoardResult = "";
int inthighNum = 0;
int intFreeSpots = 0;
for (int m = 0; m < 4; m++)
{
for (int n = 0; n < 4; n++)
{
strBoardResult =
myModule.AddItem(strBoardResult, iBoard[n][m].ToString());
if (iBoard[n][m] > inthighNum) inthighNum =
iBoard[n][m];
if (iBoard[n][m] == 0) intFreeSpots += 1;
}
}
myNode[idxMyNode].intSpawnPos = intNextSpawn;
myNode[idxMyNode].OwnBoard = strBoardResult;
myNode[idxMyNode].intHighNum = inthighNum;
myNode[idxMyNode].intSpaceLeft = intFreeSpots;
if (!bAdd) myNode[idxMyNode].isIdle = true;
else
{
if (idxMyNode < 4) myNode[idxMyNode].isIdle =
false;
else //follow the parent's idle stat
{
myNode[idxMyNode].isIdle =
myNode[findIdxParent(idxMyNode)].isIdle;
}
}
}
else print("GAMEOVER");
}
void ContinueAI()
{
//simulate result
for (int k = 0; k < myNode.Length; k++)
{
if (k == 0) intCurSpawn5 = 0;
else if (k == 4) intCurSpawn5 = 1;
else if (k == 20) intCurSpawn5 = 2;
A- 7 -
Universitas Sumatera Utara
LAMPIRAN A
else if (k == 84) intCurSpawn5 = 3;
else if (k == 340) intCurSpawn5 = 4;
simulator4(k);
}
//get bottom best value
int getTmpIdx = 340;
int intHighNum = 0;
int intSpaceLeft = 0;
for (int v = 340; v < myNode.Length; v++)
{
if (!myNode[v].isIdle && ((intHighNum <
myNode[v].intHighNum) || (intHighNum == myNode[v].intHighNum &&
intSpaceLeft < myNode[v].intSpaceLeft)))
{
getTmpIdx = v;
intHighNum = myNode[v].intHighNum;
intSpaceLeft = myNode[v].intSpaceLeft;
}
}
//trace up
for (int w = 5; w > 0; w--)
{
strSaveDataAIArah =
myModule.AddItemReversed(strSaveDataAIArah,
myNode[getTmpIdx].strDirection);
strSaveDataAISpawn =
myModule.AddItemReversed(strSaveDataAISpawn,
myNode[getTmpIdx].intSpawnPos.ToString());
for (int x = 0; x < myNode.Length; x++)
{
if (myNode[x].strNodeId ==
myNode[getTmpIdx].strNodeIdParent)
{
getTmpIdx = x;
}
}
}
myController_Gameplay.intUpdate = 10;
}
int findIdxParent(int idxChild)
{
int idxParentGet = -1;
for (int a = 0; a < myNode.Length; a++)
{
if (myNode[a].strNodeId ==
myNode[idxChild].strNodeIdParent)
{
idxParentGet = a;
break;
}
}
return idxParentGet;
}
A- 8 -
Universitas Sumatera Utara
LAMPIRAN A
}
A- 9 -
Universitas Sumatera Utara
LAMPIRAN B
using UnityEngine;
using System.Collections;
[System.Serializable]
public class Box2048
{
public int intIdx;
public int intKol;
public int intBrs;
public float posX;
public float posY;
public int FillNum;
}
[System.Serializable]
public class Number2048
{
public int intIdx;
public int intKol;
public int intBrs;
public float posX;
public float posY;
public int Number;
public GameObject GO;
}
public class controller_Gameplay : MonoBehaviour
{
#region var
public int intUpdate = -1;
public bool isInput = false;
public int intWaitMove;
public bool bolAllMove = false;
public Box2048[] myBox = new Box2048[16];
public Number2048[] myNumber = new Number2048[16];
public bool[] isNumberMove = new bool[16];
private int intCountMove = -1;
private int intCurSpawn = -1;
private string strCurMove = "";
public AI myAI;
public string strMasterBoard = "";
public Module myModule;
#endregion
// Use this for initialization
void Start () {
//print("void start");
for (int i = 0; i < myBox.Length; i++)
{
myBox[i].intIdx = i;
myBox[i].intKol = (i % 4);
myBox[i].intBrs = (i / 4);
myBox[i].posX = -4.0f + (2.0f * (i % 4));
myBox[i].posY = 3.0f - (2.0f * (i / 4));
B- 1 -
Universitas Sumatera Utara
LAMPIRAN B
myBox[i].FillNum = 0;
myNumber[i].intIdx
myNumber[i].intKol
myNumber[i].intBrs
myNumber[i].posX =
myNumber[i].posY =
myNumber[i].Number
= i;
= (i % 4);
= (i / 4);
-4.0f + (2.0f * (i % 4));
3.0f - (2.0f * (i / 4));
= 0;
}
myAI.setNodeID();
intUpdate = 5;
}
// Update is called once per frame
void Update()
{
switch (intUpdate)
{
case 0: break;
case 5: intUpdate = 0;
callAI();
break;
case 10: intUpdate = 0;
intCountMove = 0;
intUpdate = 15;
break;
case 15: intUpdate = 0;
intCountMove++;
if (intCountMove > 5) intUpdate = 5;
else
{
int.TryParse(myModule.GetItemPos(myAI.strSaveDataAISpawn,intCountMo
ve),out intCurSpawn);
strCurMove =
myModule.GetItemPos(myAI.strSaveDataAIArah, intCountMove);
intUpdate = 20;
}
break;
case 20: intUpdate = 0;
spawnNumber(intCurSpawn);
break;
case 25: intUpdate = 0;
moveNumber(strCurMove);
break;
case 30: intUpdate = 0;
checkGameOver();
break;
case 40: intUpdate = 0;
GameObject.Find("EventSystem").SendMessage("Finish");
GUI.Box(new Rect(0, 0, Screen.width, Screen.height),
"The game ends /n the time is "+ Time.time);
break;
case 500 : if (Input.GetKeyDown(KeyCode.Space))
{
intUpdate = 0;
B- 2 -
Universitas Sumatera Utara
LAMPIRAN B
afterMove();
}
break;
}
}
void callAI()
{
//print("void callAI");
//convert currentBoard to string
strMasterBoard = "";
for (int i = 0; i < myNumber.Length; i++) strMasterBoard =
myModule.AddItem(strMasterBoard, myNumber[i].Number.ToString());
//call AI to start
myAI.resetNode();
}
void spawnNumber(int intPosSpawn)
{
//print("void spawnNumber");
myBox[intPosSpawn].FillNum = 2;
myNumber[intPosSpawn].Number = 2;
myNumber[intPosSpawn].GO =
Instantiate(Resources.Load("Numbers/GO_2")) as GameObject;
myNumber[intPosSpawn].GO.transform.position = new
Vector3(myNumber[intPosSpawn].posX, myNumber[intPosSpawn].posY, 0.0f);
intUpdate = 25;
}
public void moveNumber(string direction)
{
//print("void moveNumber");
//set EndPos (order based on direction)
//#######################################//
#region RIGHT
if (direction == "Right")
{
for (int j = 0; j < 4; j++)
{
for (int i = 3; i >= 0; i--)
{
for (int k = i - 1; k >= 0; k--)
{
if (myBox[(4 * j) + k].FillNum == 0)
{
continue;
}
else if (myBox[(4 * j) + k].FillNum ==
myBox[(4 * j) + i].FillNum)
{
myNumber[(4 * j) +
k].GO.GetComponent().endPos = new
Vector3(myNumber[(4 * j) + i].posX, myNumber[(4 * j) + k].posY, 0.0f);
myNumber[(4 * j) +
k].GO.GetComponent().interval =
Mathf.Abs(myBox[(4 * j) + k].intKol - myBox[(4 * j) + i].intKol);
B- 3 -
Universitas Sumatera Utara
LAMPIRAN B
isNumberMove[(4 * j) + k] = true;
myBox[(4 * j) + i].FillNum *= 2;
myBox[(4 * j) + k].FillNum = 0;
break;
}
else
{
if (myBox[(4 * j) + i].FillNum ==
0 && myBox[(4 * j) + k].FillNum != 0)
{
myNumber[(4 * j) +
k].GO.GetComponent().endPos = new
Vector3(myNumber[(4 * j) + i].posX, myNumber[(4 * j) + k].posY, 0.0f);
myNumber[(4 * j) +
k].GO.GetComponent().interval =
Mathf.Abs(myBox[(4 * j) + k].intKol - myBox[(4 * j) + i].intKol);
isNumberMove[(4 * j) + k] =
true;
myBox[(4 * j) + i].FillNum
= myBox[(4 * j) + k].FillNum;
myBox[(4 * j) + k].FillNum
= 0;
i++;
break;
}
else if (myBox[(4 * j) +
i].FillNum != 0)
{
break;
}
}
}
}
}
}
#endregion
//#######################################//
#region LEFT
if (direction == "Left")
{
for (int j = 0; j < 4; j++)
{
for (int i = 0; i < 4; i++)
{
for (int k = i + 1; k < 4; k++)
{
if (myBox[(4*j)+k].FillNum == 0)
{
continue;
}
else if (myBox[(4 * j) + k].FillNum ==
myBox[(4 * j) + i].FillNum)
{
myNumber[(4 * j) +
k].GO.GetComponent().endPos = new
Vector3(myNumber[(4 * j) + i].posX, myNumber[(4 * j) + k].posY, 0.0f);
B- 4 -
Universitas Sumatera Utara
LAMPIRAN B
myNumber[(4 * j) +
k].GO.GetComponent().interval =
Mathf.Abs(myBox[(4 * j) + k].intKol - myBox[(4 * j) + i].intKol);
isNumberMove[(4 * j) + k] = true;
myBox[(4 * j) + i].FillNum *= 2;
myBox[(4*j)+k].FillNum = 0;
break;
}
else
{
if (myBox[(4 * j) + i].FillNum ==
0 && myBox[(4 * j) + k].FillNum != 0)
{
myNumber[(4 * j) +
k].GO.GetComponent().endPos = new
Vector3(myNumber[(4 * j) + i].posX, myNumber[(4 * j) + k].posY, 0.0f);
myNumber[(4 * j) +
k].GO.GetComponent().interval =
Mathf.Abs(myBox[(4 * j) + k].intKol - myBox[(4 * j) + i].intKol);
isNumberMove[(4 * j) + k] =
true;
myBox[(4 * j) + i].FillNum
= myBox[(4 * j) + k].FillNum;
myBox[(4 * j) + k].FillNum
= 0;
i--;
break;
}
else if (myBox[(4 * j) +
i].FillNum != 0)
{
break;
}
}
}
}
}
}
#endregion
//#######################################//
#region DOWN
if (direction == "Down")
{
for (int i = 0; i < 4; i++)
{
for (int j = 3; j >= 0; j--)
{
for (int k = j - 1; k >= 0; k--)
{
if (myBox[(4 * k) + i].FillNum == 0)
//kosong jd tidak ad yg perlu digeser
{
continue;
}
else if (myBox[(4 * k) + i].FillNum ==
myBox[(4 * j) + i].FillNum) //timpa... nilai sama.... jd tujuan x2...
asal jd nol krn digeser
B- 5 -
Universitas Sumatera Utara
LAMPIRAN B
{
myNumber[(4 * k) +
i].GO.GetComponent().endPos = new
Vector3(myNumber[(4 * k) + i].posX, myNumber[(4 * j) + i].posY, 0.0f);
myNumber[(4 * k) +
i].GO.GetComponent().interval =
Mathf.Abs(myBox[(4 * k) + i].intBrs - myBox[(4 * j) + i].intBrs);
isNumberMove[(4 * k) + i] = true;
myBox[(4 * j) + i].FillNum *= 2;
myBox[(4 * k) + i].FillNum = 0;
break;
}
else
{
if (myBox[(4 * j) + i].FillNum ==
0 && myBox[(4 * k) + i].FillNum != 0) //geser masuk.... tujuan jd ad
nilai.... asal jd nol krn digeser
{
myNumber[(4 * k) +
i].GO.GetComponent().endPos = new
Vector3(myNumber[(4 * k) + i].posX, myNumber[(4 * j) + i].posY, 0.0f);
myNumber[(4 * k) +
i].GO.GetComponent().interval =
Mathf.Abs(myBox[(4 * k) + i].intBrs - myBox[(4 * j) + i].intBrs);
isNumberMove[(4 * k) + i] =
true;
myBox[(4 * j) + i].FillNum
= myBox[(4 * k) + i].FillNum;
myBox[(4 * k) + i].FillNum
= 0;
j++;
break;
}
else if (myBox[(4 * j) +
i].FillNum != 0)//tdk bisa geser krn nilai beda
{
break;
}
}
}
}
}
}
#endregion
//#######################################//
#region UP
if (direction == "Up")
{
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
for (int k = j + 1; k < 4; k++)
{
if (myBox[(4 * k) + i].FillNum == 0)
//kosong jd tidak ad yg perlu digeser
{
B- 6 -
Universitas Sumatera Utara
LAMPIRAN B
continue;
}
else if (myBox[(4 * k) + i].FillNum ==
myBox[(4 * j) + i].FillNum) //timpa... nilai sama.... jd tujuan x2...
asal jd nol krn digeser
{
myNumber[(4 * k) +
i].GO.GetComponent().endPos = new
Vector3(myNumber[(4 * k) + i].posX, myNumber[(4 * j) + i].posY, 0.0f);
myNumber[(4 * k) +
i].GO.GetComponent().interval =
Mathf.Abs(myBox[(4 * k) + i].intBrs - myBox[(4 * j) + i].intBrs);
isNumberMove[(4 * k) + i] = true;
myBox[(4 * j) + i].FillNum *= 2;
myBox[(4 * k) + i].FillNum = 0;
break;
}
else
{
if (myBox[(4 * j) + i].FillNum ==
0 && myBox[(4 * k) + i].FillNum != 0) //geser masuk.... tujuan jd ad
nilai.... asal jd nol krn digeser
{
myNumber[(4 * k) +
i].GO.GetComponent().endPos = new
Vector3(myNumber[(4 * k) + i].posX, myNumber[(4 * j) + i].posY, 0.0f);
myNumber[(4 * k) +
i].GO.GetComponent().interval =
Mathf.Abs(myBox[(4 * k) + i].intBrs - myBox[(4 * j) + i].intBrs);
isNumberMove[(4 * k) + i] =
true;
myBox[(4 * j) + i].FillNum
= myBox[(4 * k) + i].FillNum;
myBox[(4 * k) + i].FillNum
= 0;
j--;
break;
}
else if (myBox[(4 * j) +
i].FillNum != 0)//tdk bisa geser krn nilai beda
{
break;
}
}
}
}
}
}
#endregion
intWaitMove = 0;
bool isSthMove = false;
for (int k = 0; k < myNumber.Length; k++)
{
if (isNumberMove[k])
{
intWaitMove++;
B- 7 -
Universitas Sumatera Utara
LAMPIRAN B
myNumber[k].GO.GetComponent().startPos =
new Vector3(myNumber[k].posX, myNumber[k].posY, 0.0f);
myNumber[k].GO.GetComponent().startTime =
Time.time;
myNumber[k].GO.GetComponent().journeyLength
=
Vector3.Distance(myNumber[k].GO.GetComponent().st
artPos, myNumber[k].GO.GetComponent().endPos);
myNumber[k].GO.GetComponent().isMoveable =
true;
isSthMove = true;
}
}
if (isSthMove) bolAllMove = true;
else decreaseIntWaitMove();
}
public void decreaseIntWaitMove()
{
//print("void decreaseIntWaitMove...");
intWaitMove--;
//print("hasil pengurangan..." + intWaitMove.ToString());
if (intWaitMove 0)
{
myNumber[i].GO.transform.position = new
Vector3(myNumber[i].posX, myNumber[i].posY, 0.0f);
GameObject.Destroy(myNumber[i].GO.gameObject);
}
myNumber[i].Number = myBox[i].FillNum;
if (myNumber[i].Number > 0)
{
myNumber[i].GO =
Instantiate(Resources.Load("Numbers/GO_" +
myNumber[i].Number.ToString())) as GameObject;
myNumber[i].GO.transform.position = new
Vector3(myNumber[i].posX, myNumber[i].posY, 0.0f);
}
B- 8 -
Universitas Sumatera Utara
LAMPIRAN B
if (myNumber[i].Number == 2048)
{
GameObject.Find("EventSystem").SendMessage("Finish");
}
if (myNumber[i].Number == 1024)
{
GameObject.Find("EventSystem").SendMessage("Catat");
}
isNumberMove[i] = false;
}
//can Spawn ???
bool canSpawn = false;
for (int j = 0; j < myBox.Length; j++)
{
if (myBox[j].FillNum == 0)
{
canSpawn = true;
break;
}
}
//print("void afterMove => cek Can Spawn???");
if (canSpawn)
intUpdate = 15;
else
intUpdate = 30;
}
void checkGameOver()
{
//print("void checkGameOver");
bool isPlayable = false;
for (int j = 0; j < myNumber.Length; j++)
{
//not mostLeft
if (j % 4 != 0)
{
if (myNumber[j].Number == myNumber[j - 1].Number)
{
isPlayable = true;
break;
}
}
//NOT mostRight
else if (j % 4 != 3)
{
if (myNumber[j].Number == myNumber[j + 1].Number)
{
isPlayable = true;
break;
}
}
//not mostTop
else if (j / 4 != 0)
B- 9 -
Universitas Sumatera Utara
LAMPIRAN B
{
if (myNumber[j].Number == myNumber[j - 4].Number)
{
isPlayable = true;
break;
}
}
//not mostBottom
else if (j / 4 != 3)
{
if (myNumber[j].Number == myNumber[j + 4].Number)
{
isPlayable = true;
break;
}
}
}
if (isPlayable) intUpdate = 10;
else intUpdate = 40;
}
}
B- 10 -
Universitas Sumatera Utara
LAMPIRAN C
using UnityEngine;
using System.Collections;
public class controller_moveAnimTes : MonoBehaviour {
//tes
public GameObject myGO_AnimTes;
public controller_Gameplay myGameplayScript;
public Vector3 startPos;
public Vector3 endPos;
public Vector4 startColor;
public Vector4 endColor;
public float speed = 1.0f;
public float interval = 1.0f;
public float startTime;
public float journeyLength;
private float colorLength;
public bool isMoveable;
// Use this for initialization
void Start () {
//tes
myGameplayScript =
GameObject.Find("Controller_Gameplay").GetComponent(
);
////print("GO found");
speed = 15.0f;
startTime = Time.time;
journeyLength = Vector3.Distance(startPos, endPos);
//startColor = new
Vector4(this.gameObject.GetComponent().color.r,
this.gameObject.GetComponent().color.r,
this.gameObject.GetComponent().color.r, 1.0f);
//endColor = new
Vector4(this.gameObject.GetComponent().color.r,
this.gameObject.GetComponent().color.r,
this.gameObject.GetComponent().color.r, 0.0f);
//colorLength = Vector4.Distance(startColor, endColor);
//----------------//
}
// Update is called once per frame
void Update()
{
if (isMoveable && myGameplayScript.bolAllMove)
{
//print("initial calculate ");
float distCovered = (Time.time - startTime) * speed *
interval;
float fracJourney = distCovered / journeyLength;
//print("about to transform");
myGO_AnimTes.transform.position = Vector3.Lerp(startPos,
endPos, fracJourney);
//print("transform is done ");
if (myGO_AnimTes.transform.position == endPos)
{
C-- 1 --
Universitas Sumatera Utara
LAMPIRAN C
isMoveable = false;
myGameplayScript.decreaseIntWaitMove();
}
//float fadeCovered = (Time.time - startTime) * speed;
//float fracFading = fadeCovered / colorLength;
//myGO_AnimTes.GetComponent().color =
Vector4.Lerp(startColor, endColor, fracFading);
}
}
}
C-- 2 --
Universitas Sumatera Utara
LAMPIRAN C
using UnityEngine;
using System.Collections;
public class Module : MonoBehaviour {
public string AddItem(string sourceString, string addString)
{
string temp = sourceString;
if (temp == "")
{
temp += addString;
}
else
{
temp += "," + addString;
}
return temp;
}
public string AddItemReversed(string sourceString, string
addString)
{
string temp = sourceString;
if (temp == "")
{
temp += addString;
}
else
{
temp = addString + "," + temp;
}
return temp;
}
public string RandomItemInString(string pstr)
{
int roundDirection;
string temp1 = pstr;
string temp2 = "";
int maxItem = GetItemCount(pstr);
int maxRound = Random.Range(5, 10);
int front = 1;
int last = maxItem;
for (int i = 1; i < maxRound; i++)
{
if (temp2 != "")
{
temp1 = temp2;
temp2 = "";
}
front = 1;
last = maxItem;
for (int j = 1; j = pos)
{
return temp;
}
temp = "";
count += 1;
}
else
{
temp += pstr.Substring(i, 1);
C-4-
Universitas Sumatera Utara
LAMPIRAN C
}
}
if ((count + 1) < pos) temp = "";
return temp;
}
}
C-5-
Universitas Sumatera Utara
LAMPIRAN D
using UnityEngine;
using System.Collections;
public class Module : MonoBehaviour {
public string AddItem(string sourceString, string addString)
{
string temp = sourceString;
if (temp == "")
{
temp += addString;
}
else
{
temp += "," + addString;
}
return temp;
}
public string AddItemReversed(string sourceString, string
addString)
{
string temp = sourceString;
if (temp == "")
{
temp += addString;
}
else
{
temp = addString + "," + temp;
}
return temp;
}
public string RandomItemInString(string pstr)
{
int roundDirection;
string temp1 = pstr;
string temp2 = "";
int maxItem = GetItemCount(pstr);
int maxRound = Random.Range(5, 10);
int front = 1;
int last = maxItem;
for (int i = 1; i < maxRound; i++)
{
if (temp2 != "")
{
temp1 = temp2;
temp2 = "";
}
front = 1;
last = maxItem;
for (int j = 1; j = pos)
{
return temp;
}
temp = "";
count += 1;
}
else
D-2-
Universitas Sumatera Utara
LAMPIRAN D
{
temp += pstr.Substring(i, 1);
}
}
if ((count + 1) < pos) temp = "";
return temp;
}
}
D-3-
Universitas Sumatera Utara
LAMPIRAN E
using UnityEngine;
using System.Collections;
public class tesKlik5 : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void OnMouseDown1()
{
Application.LoadLevel("Gameplay");
}
}
E-1-
Universitas Sumatera Utara
LAMPIRAN F
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Timer : MonoBehaviour {
// Use this for initialization
public Text timerText;
public Text timerText2;
private float startTime;
private bool finished = false;
private float t1024;
void Start () {
startTime = Time.time;
}
// Update is called once per frame
void Update () {
if (finished == true)
Time.timeScale=0;
else {
float t = Time.time - startTime;
string minutes = ((int)t / 60).ToString
();
string seconds = (t % 60).ToString
("f2");
timerText.text = minutes + ":" +
seconds;
}
}
public void Finish()
{
finished = true;
timerText.color = Color.red;
}
public void Catat()
{
if (t1024 == 0) {
float t = Time.time - startTime;
string minutes = ((int)t / 60).ToString
();
string seconds = (t % 60).ToString
("f2");
timerText2.text = minutes + ":" +
seconds;
t1024++;
}
}
}
F-1-
Universitas Sumatera Utara
DAFTAR RIWAYAT HIDUP
Data Pribadi
Nama
:
Devina Pratiwi Halim
Tempat, tanggal Lahir :
Medan, 16 Mei 1992
Jenis Kelamin
Umur
:
:
Perempuan
24 tahun
Tinggi, berat badan
:
158cm , 55 kg
Agama
:
Buddha
Alamat
: Jalan Brig. Jend. Katamso GG. Baru No. 16 Medan
Status
:
Belum Kawin
Telepon
:
085767658992
:
devinapratiwihalim@gmail.com
Latarbelakang Pendidikan :
Formal
1998 – 2004
2004 – 2007
2007 – 2010
2012 – 2015
2012 – 2016
2014
2015
: Lulusan SD Methodist 2 Medan
: Lulusan SMP Methodist 2 Medan
: Lulusan SMA Methodist 2 Medan
: Bachelor Jurusan Administrasi dan Finansial di Net Academy
: S1 Jurusan Akuntansi di Professional Management College
Indonesia
: Associate Chartered Financial Practitioner(AChFP) di Asia
Pacific Financial Services Association
: Fellow Chartered Financial Practitioner (FChFP) di Asia
Pacific Financial Services Association
Universitas Sumatera Utara
Non Formal
2006 – 2007
: Bimbingan bahasa Inggris di The British Institute
2007 – 2008
: Bimbingan Matematika di AXIS
2009
: Bimbingan 1 Tahun Program Komputer di VISITEK
2010
: Workshop Teknik Dasar Fotografi di Ikatan Mahasiswa S1 Ilmu
Komputer USU
2010
: Workshop Teknik Hacking di Ikatan Mahasiswa S1 Ilmu
Komputer USU
2010
: Workshop Setting Cisco Router di WEBMEDIA Training
Center
2011
: Panitia Seminar Teknologi Informasi di Universitas Sumatera
Utara
2012
: Peserta Lomba Problem Solving IMILKOM Contest 2012
2013
: Partisipasi dalam Galang Dana Lions Club
2013
: Workshop Mengenal Kopi di Starbucks Medan
2013
: Partisipasi dalam Seminar Orang Yang Kaya Orang Yang
Kreatif dari Professional Management College Indonesia
2015
: Liasion Officer (LO) Kegiatan Forum Rektor Indonesia XVII di
Universitas Sumatera Utara
2016
: Volunteer dalam partisipasi Education Expo
Pengalaman Organisasi
• 2006 – 2007
• 2010 – 2012
• 2013 – 2014
• 2014 – 2015
: Anggota dari Klub Teater Methodist 2 Medan
: Anggota dari Keluarga Mahasiswa Buddhis di Universitas
Sumatera Utara
: Anggota dari Singing Club di Professional Management College
Indonesia
: Pengurus Badan Eksekutif Mahasiswa di Professional
Management College Indonesia dengan jabatan Hubungan
Masyarakat Eksternal
Universitas Sumatera Utara
Penghargaan
• 2002
• 2007
• 2008
• 2008
• 2008
•
2009
: Penghargaan sebagai Juara X Reading-A di Language School
Best
: Penghargaan sebagai Peserta dalam mengikuti Pekan Olimpiade
Sekolah
: Penghargaan sebagai Juara II Kelas XI
: Penghargaan sebagai peserta dalam mengikuti Lomba Sains
Plus Antar Pelajar SMA Se-Sumut
: Penghargaan sebagai Peserta dalam mengikuti Pekan Olimpiade
Sekolah
: Penghargaan sebagai Peserta dalam Pekan Olimpiade Sekolah
Pengalaman Kerja
•
2009-2010
: Bekerja di Leny English Private Classes sebagai asisten pengajar
bahasa Inggris
• Praktek Kerja Lapangan:
Praktek Kerja Lapangan di di Kantor Pelayanan Perbendaharaan Negara Medan
Periode
: Agustus 2013 – Oktober 2013
Tujugan
: Mata Kuliah Wajib
Posisi
: Konsultan IT dan Programmer
Rincian Pekerjaan:
•
Memasang jaringan pada satu ruangan
•
Memasukkan biografi pegawai secara online pada website yang baru
•
Mengorganisir data 10 tahun dan lebih dan menyusunnya sehingga dapat di
akses seluruh departemen
•
Membangun sebuah program dengan menggunakan Microsoft Excel untuk
menangani pembayaran gaji pada semua unit di dalam departemen.
• 2014
: Bekerja di Scholars Hub sebagai pengajar sampai sekarang
• 2015
: Bekerja sebagai Agen Asuransi untuk Asuransi Panin Life Dai-ichi
sampai sekarang
Universitas Sumatera Utara
Kemampuan
•
Kemampuan Komputer
Office
1. Microsoft Word
2. Microsoft Excel
3. Microsoft Power Point
4. Microsoft Access
Design & Video
1. Adobe Photoshop
2. Adobe Dreamweaver
Pemrograman
1.
2.
3.
4.
5.
6.
Visual Studio
Eclipse
Visual Basic
Unity
MatLab
FoxPro
Medan, 2 Nopember 2016
Hormat saya,
Devina Pratiwi Halim
Universitas Sumatera Utara