ট্রন: গেম এআই অ্যালগরিদম?


11

লাইটসাইকেল বা যা যা বলা হত এটি।


গেমের মানচিত্রের প্রতিনিধিত্বকারী একটি 2 ডি অ্যারে দেওয়া হয়েছে, যেখানে প্রতিটি উপাদান 0 বা 1 হতে পারে (ফাঁকা স্থান এবং 1 ভরাট স্থান উপস্থাপন করে), ট্রন শত্রু এআই এর জন্য ব্যবহৃত অ্যালগরিদম কী?

উত্তর:


7

আমি তাদের কোডটি খনন করার সুযোগ পাইনি, তবে আরমাজেট্রন অ্যাডভান্সড হ'ল একটি উন্মুক্ত উত্স তুলনামূলকভাবে পরিপক্ক লাইটসাইচিং যুদ্ধের খেলা।

আপনি উত্সটি (এবং এক্সিকিউটেবল) এখানে পাবেন: http://armagetronad.net/downloads.php


8

এটি গুগল আই প্রতিযোগিতার একটি বিষয় ছিল

এই পৃষ্ঠা থেকে কিছু দুর্দান্ত সংস্থান রয়েছে:


1
গুগল এআই প্রতিযোগিতা আছে ?!
ডিভে

ওয়াটারলু কম্পিউটার সায়েন্স ক্লাবের লিঙ্কগুলি নীচে নেমে আসছে বলে মনে হচ্ছে, এখানে ইন্টারনেট ওয়েব্যাক মেশিনের আর্কাইভ কপিগুলি রয়েছে: গুগল এআই প্রতিযোগিতা এবং রবার্ট জিয়াওর ট্রোন স্ট্র্যাটেজি গাইড
রোডিয়া

1

আমি কোনও অ্যালগরিদম জানি না তবে আমি জাভাতে একটি সাধারণ "অ্যালগরিদম" তৈরি করতে পারি

//2D boolean (true/false) array
boolean map[][] = new boolean[20][20];
//this represents the position of the AI on the map
int x = 10, y = 10;
//this int will be 1 - 4 and will represent a direction
//1 - up
//2 - right
//3 - down
//4 - left
int direction = 1;

void init(int startX, int startY){
    //set the x and y to a starting position
    x = startX;
    y = startY;
    //this will set the entire array to false
    int i = 0, j = 0;
    while (i<20){
        while(j<20){
            map[i][j] = false;
            j++;
        }
        j = 0;
        i++;
    }

    //and this will set the starting position to true
    map[x][y] = true;
}

void tick(){
    try{
        //try to go straight and will error if 
        //it cannot because it would be out of bounds
        switch(direction){
        case 1: //up
            if(!map[x][y-1]){ //will error out here if the block in front is out of bounds
                map[x][y-1] = true;
                y--;
            }
            return;
        case 2: //right
            if(!map[x+1][y]){ //will error out here if the block in front is out of bounds
                map[x+1][y] = true;
                x++;
            }
            return;
        case 3: //down
            if(!map[x][y+1]){ //will error out here if the block in front is out of bounds
                map[x][y+1] = true;
                y++;
            }
            return;
        case 4: //left
            if(!map[x-1][y]){ //will error out here if the block in front is out of bounds
                map[x-1][y] = true;
                x--;
            }
            return;
        }
    }catch(Exception e){

    }
    //this next bit will only be  triggered if the AI could not go straight

    //define two temporary variables, fairly self explanatory.
    boolean canGoLeft = false, canGoRight = false;

    //defines whether it is safe to go left
    //turn left respectively
    //test if straight is safe
    direction--;
    try{
        //try to go straight and will error if 
        //it cannot because it would be out of bounds
        switch(direction){
        case 1: //up
            if(!map[x][y-1]){ //will error out here if the block in front is out of bounds
                canGoLeft = true;
            }else canGoLeft = false;
            break;
        case 2: //right
            if(!map[x+1][y]){ //will error out here if the block in front is out of bounds
                canGoLeft = true;
            }else canGoLeft = false;
            break;
        case 3: //down
            if(!map[x][y+1]){ //will error out here if the block in front is out of bounds
                canGoLeft = true;
            }else canGoLeft = false;
            break;
        case 4: //left
            if(!map[x-1][y]){ //will error out here if the block in front is out of bounds
                canGoLeft = true;
            }else canGoLeft = false;
            break;
        }
    }catch(Exception e){
        canGoLeft = false;
    }
    //return to original direction before test
    direction++;

    //now perform the same test but with turning right
    //turn right respectively
    direction++;
    try{
        //try to go straight and will error if 
        //it cannot because it would be out of bounds
        switch(direction){
        case 1: //up
            if(!map[x][y-1]){ //will error out here if the block in front is out of bounds
                canGoRight = true;
            }else canGoRight = false;
            break;
        case 2: //right
            if(!map[x+1][y]){ //will error out here if the block in front is out of bounds
                canGoRight = true;
            }else canGoRight = false;
            break;
        case 3: //down
            if(!map[x][y+1]){ //will error out here if the block in front is out of bounds
                canGoRight = true;
            }else canGoRight = false;
            break;
        case 4: //left
            if(!map[x-1][y]){ //will error out here if the block in front is out of bounds
                canGoRight = true;
            }else canGoRight = false;
            break;
        }
    }catch(Exception e){
        canGoRight = false;
    }
    direction--;

    if(canGoLeft&&!canGoRight){//can only go left
        direction--;
        try{
            //try to go straight and will error if 
            //it cannot because it would be out of bounds
            switch(direction){
            case 1: //up
                if(!map[x][y-1]){ //will error out here if the block in front is out of bounds
                    map[x][y-1] = true;
                    y--;
                }
                return;
            case 2: //right
                if(!map[x+1][y]){ //will error out here if the block in front is out of bounds
                    map[x+1][y] = true;
                    x++;
                }
                return;
            case 3: //down
                if(!map[x][y+1]){ //will error out here if the block in front is out of bounds
                    map[x][y+1] = true;
                    y++;
                }
                return;
            case 4: //left
                if(!map[x-1][y]){ //will error out here if the block in front is out of bounds
                    map[x-1][y] = true;
                    x--;
                }
                return;
            }
        }catch(Exception e){

        }
    }else if(!canGoLeft&&canGoRight){//can only go right
        direction++;
        try{
            //try to go straight and will error if 
            //it cannot because it would be out of bounds
            switch(direction){
            case 1: //up
                if(!map[x][y-1]){ //will error out here if the block in front is out of bounds
                    map[x][y-1] = true;
                    y--;
                }
                return;
            case 2: //right
                if(!map[x+1][y]){ //will error out here if the block in front is out of bounds
                    map[x+1][y] = true;
                    x++;
                }
                return;
            case 3: //down
                if(!map[x][y+1]){ //will error out here if the block in front is out of bounds
                    map[x][y+1] = true;
                    y++;
                }
                return;
            case 4: //left
                if(!map[x-1][y]){ //will error out here if the block in front is out of bounds
                    map[x-1][y] = true;
                    x--;
                }
                return;
            }
        }catch(Exception e){

        }
    }else if(canGoLeft&&canGoRight){//can go either way so it will pick randomly
        if(System.currentTimeMillis()%2==0){//random, will be true half of the time and false the other half
            //change direction one anticlockwise
            direction--;
            try{
                //try to go straight and will error if 
                //it cannot because it would be out of bounds
                switch(direction){
                case 1: //up
                    if(!map[x][y-1]){ //will error out here if the block in front is out of bounds
                        map[x][y-1] = true;
                        y--;
                    }
                    return;
                case 2: //right
                    if(!map[x+1][y]){ //will error out here if the block in front is out of bounds
                        map[x+1][y] = true;
                        x++;
                    }
                    return;
                case 3: //down
                    if(!map[x][y+1]){ //will error out here if the block in front is out of bounds
                        map[x][y+1] = true;
                        y++;
                    }
                    return;
                case 4: //left
                    if(!map[x-1][y]){ //will error out here if the block in front is out of bounds
                        map[x-1][y] = true;
                        x--;
                    }
                    return;
                }
            }catch(Exception e){

            }
        }else{
            //change direction one clockwise
            direction++;
            try{
                //try to go straight and will error if 
                //it cannot because it would be out of bounds
                switch(direction){
                case 1: //up
                    if(!map[x][y-1]){ //will error out here if the block in front is out of bounds
                        map[x][y-1] = true;
                        y--;
                    }
                    return;
                case 2: //right
                    if(!map[x+1][y]){ //will error out here if the block in front is out of bounds
                        map[x+1][y] = true;
                        x++;
                    }
                    return;
                case 3: //down
                    if(!map[x][y+1]){ //will error out here if the block in front is out of bounds
                        map[x][y+1] = true;
                        y++;
                    }
                    return;
                case 4: //left
                    if(!map[x-1][y]){ //will error out here if the block in front is out of bounds
                        map[x-1][y] = true;
                        x--;
                    }
                    return;
                }
            }catch(Exception e){

            }
        }
    }
}
আমাদের সাইট ব্যবহার করে, আপনি স্বীকার করেছেন যে আপনি আমাদের কুকি নীতি এবং গোপনীয়তা নীতিটি পড়েছেন এবং বুঝতে পেরেছেন ।
Licensed under cc by-sa 3.0 with attribution required.