Julialangを使用して簡単なロック紙はさみゲームビルド


皆さんこんにちは👋, この記事で📃 私は、ミニプロジェクトを構築することによってどのように私がM .
Julialangを使用してロック紙ハサミゲームを構築を開始します.
しかし、最初にJulialangコードを実行するためのIDEまたはテキストエディタが必要です.
私たちはJulialangコードを実行するために必要な拡張子を持つvscodeを使うことができます、しかし、私がちょうどJulialangrepl.it ここでコーディングし、ジュリアス(その素晴らしいオンラインIDEを試してみる)を探る.

Motivation behind getting started with Learning JuliaLang:

  1. Best part about JuliaLang is that it is easy to learn just like Python.
  2. The execution speed of JuliaLang is similar to C/C++. That means it's fast.
  3. And it is widely used for Data Science , Machine Learning , Deep Learning and even Web Development(And more lot stuff).
  4. And JuliaLang Community is wide & inclusive,if you stuck somewhere while creating any project using JuliaLang. There are many amazing folks to help you. And if are mathematics, bioinformatics or something related to Statistics and Maths or even you are just a Tech Enthusiast join JuliaLang slack channel. You will find many awesome peers who are enthusiast from of the above fields.
  5. Around 200+ JuliaLang packages are present to make your development work more easy.

コンプリートコード
# learning julialang basics by creating classical stone paper scissors game


function play_game()
    moves = ["rock","paper","scissor"]
    computer_move = moves[rand(1:3)]

    human_move = Base.prompt("Please enter stone, paper, or scissor")

    print("Rock...")
    sleep(1.0)

    print("Paper...")
    sleep(1.0)

    print("Scissors...")
    sleep(1.0)

    print("Shoot!\n")

    if computer_move == human_move
        print("You tied, please try again")
    elseif computer_move == "rock" && human_move == "scissor"
        print("You lose, the computer won with rock, please try again")
    elseif computer_move == "paper" && human_move == "rock"
        print("You lose, the computer won with paper, please try again")
    elseif computer_move == "scissor" && human_move == "paper"
        print("You lose, the computer won with scissor, please try again")
    else
        print("You won, the computer lost with $computer_move, nice work!")
    end

end


このミニプロジェクトの構築から学んだこと
1)julialangでコメントを書く方法.
# This is how we write JuliaLang comments
# hashtag followed with text you wanted to commented
2 )テキストを印刷する方法を学んだ.
print("Your text here inside double quotes")
3 )関数の生成方法(パラメータなし)
function fun_name()
.
your code here
.
end
JulialangでENDキーワードを使用して停止する場所をコンパイラに伝えるのに必要な関数を作成するたびに.
4 )条件付きループ( ELSE if elseループ)を使う方法.
function test(x, y)
           if x < y
               println("x is less than y")
           elseif x > y
               println("x is greater than y")
           else
               println("x is equal to y")
           end
       end
他の条件を使用している場合や、else条件文の後に他の条件ループを使用した場合は、endキーワードを使用して条件付きループを終了するコンパイラを指定する必要があります.
5 )組み込まれていない関数について学んだ.
  • sleep () : Julialangの作り付けの方法で、ベースクラスの下に来てパッケージをインポートする必要はありません.これは基本的に指定された時間のコードの実行を停止します.最小睡眠時間は1ミリ秒です.
  • sleep(seconds)
    
  • array ()または要素のリストからランダムな要素を選択します.また、Sleepメソッドと同様に、基本クラスの下にある作り付けのメソッドです.
  • rand(1:3)
    
    ここでランダムにコレクション内の3つの要素から1要素を選択します.

    ソース
  • JuliaLang Docs

  • Julialangを使っているミニプロジェクトのためのギタブリポジトリ
    (素晴らしいミニプロジェクトリポジトリを提供してくれてありがとう

    logankilpatrick / Julia-Projects-for-Beginners
    初心者のためのジュリアプロジェクト-ジュリアでコーディングを始める簡単な考え