Article
· Dec 9, 2017 1m read

Simple Game Code(21 sticks Game)

sample
    w "Total No.Of Sticks:21"_!
    s sticks=21
    r "enter machine name: ",a
    r "enter dev name: ",b
    w "Display 1 to 21 sticks"_!
    s i=""
    f i=1:1:21{
        w " "_i_" "
    }
user(sticks)
    w !_"User select 1 or 2 or 3 or 4 sticks:"_!
    r "User enter sticks: ",us
    if us>4 {
        w "please select upto 4 Sticks"
        r "User enter sticks: ",us
    }
    s cnt=sticks-us
    s sticks=cnt
    f i=1:1:sticks {
        w " "_i_" "
    }
    s dev=1
    s machine=0
    d:sticks=0 lost(dev,machine)
    d machine(.sticks,us)
    q
machine(sticks,us)    
    w !_"Machine select 1 or 2 or 3 or 4 sticks: "_!
    s ms=5-us
    w "machine Pick the Sticks:"_ms
    hang 1
    s cnt=sticks-ms
    s sticks=cnt
    f i=1:1:sticks {
        w " "_i_" "
    }
    s dev=0
    s machine=1
    d:sticks=0 lost(dev,machine)
    q:sticks=0
    d user(.sticks)
    q
lost(dev,machine)
    if dev=1 {
        w "User Lost"_!
    }else { 
        w "machine Lost"_!
    }
    r "restart your game Yes(Y) or No(N)",res
    if res="Y" {
        d sample
    }else{
        q
    }
Discussion (0)0
Log in or sign up to continue