Code Monkey home page Code Monkey logo

hashkunzgame's Introduction

Can Be Contacted At 

Gmail    | [email protected]
Facebook | Ana Afdon Selamae
ID Line  | afdan-00

-Blowing-smiley-games- สวัสดีครับนี้เกมเป่ายิ้งฉุบที่ผมทำขึ้นมาด้วยตัวเอง ยังแก้ไม่หมดครับมันติดตรงที่การใช้ if elif ให้ถูกต้องผมยังเรียนรู้ไม่ค่อยเยอะ 
และโค้ดมันยาวไป ซึ่งผมรู้ว่าการที่โค้ดยาวมันไม่ดี แต่ว่าผมจะพยายามฝึกฝนให้มากกว่านี้ครับ โค้ดตัวนี้สามารถเอาไปเล่น และศึกษาได้ สำหรับคนที่กำลังฝึกเขียนเหมือนผม 
และผมหวังว่ามันจะเป็นประโยชน์ด้วยครับ

การทำงาน คือ ให้ bot ramdom คำ 3 คำ นั้นคือ paper / scissors / hammer โดยที่ paper = 3 / scissors = 2 / hammer = 6 
แล้วให้ person input ค่าจากแป้นพิมพ์มา 1 ค่า โดยมีตัวเลือก 3 ตัวเลือก 1,2,3 1 คือ paper 2 คือ scissors 3 คือ hammer
จากนั้น เอาค่าของ bot+person มีความเป็นไปได้ที่จะออก 6 ค่าด้วยกัน นั้นคือ 5,9,8 ( 3 ค่านี้จะมีฝ่าย ชนะกับแพ้ ) ซึ่งค่านี้จะมีความเป็นไปได้สองแบบนั้นคือ bot=3 + person=2 หรือ bot=2 + person=3 จะได้ 5 เหมือนกัน 
และ 6,4,12 ( 3 ค่านี้จะมีผลคือ เสมอกัน) จากนั้นจะไปแยกและคำนวณ bot+person เช่น bot = 3 / person = 2 / บวกกันเท่ากับ 5 แล้วให้โปรแกรมดูว่า bot กับ person อันไหนมีค่าน้อยกว่า ซึ่ง ตัวที่น้อยกว่าจะชนะ 
เพราะว่า 3=paper(กระดาษ) 2=scissors(กรรไกร) กรรไกรตัดกระดาษ และถ้า bot+person = 9,8 ก็จะทำงานคลายๆครับ แค่เปลี่ยนตรงที่ เครื่องหมายมากกว่าและน้อยกว่า

ทั้งหมดนี้เป็นการใช้ if elif หลายบรรทัดซึ่งอาจจะทำให้สับสนว่า แต่ละเงือนไข สิ้นสุดตรงบรรทัดไหน

hashkunzgame's People

Contributors

hashkunz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.