TAILIEUCHUNG - Best of Ruby Quiz Pragmatic programmers phần 2

Quiz Ruby này là thực hiện một số AI để chơi tic-tac-ngón chân, bắt một: bạn không được phép nhúng bất kỳ kiến thức của trò chơi vào sáng tạo của bạn vượt ra ngoài làm cho di chuyển quy phạm pháp luật và công nhận rằng nó đã giành được hoặc bị mất. | Quiz 9. Rock Paper Scissors 23 def play num_matches num_matche s do handl @ hand2 @ @player1_name handl @player2_name hand2 .each do player hand unless rock paper scissors .include hand raise Invalid choice by player . end end hands @player1 @player2 choice s if choice 1 draw hand1 hand2 elsif choices w paper rock win hands paper hand1 hand2 elsif choices w rock scissors win hands rock hand1 hand2 elsif choices w paper scissors win hands scissors hand1 hand2 end end end def results match @player1_name vs. @player2_name n t @player1_name @score1 n t @player2_name @score2 n if @score1 @score2 match tDraw n elsif @score1 @score2 match t @player1_name Wins n else match t @player2_name Wins n end end private def draw hand1 hand2 @score1 @score2 @ hand1 hand2 draw @ hand2 hand1 draw end def win winner hand1 hand2 if winner @player1 @score1 1 @ hand1 hand2 win Report erratum Quiz 9. Rock Paper Scissors 24 @ hand2 handl lose else @score2 1 @ hand1 hand2 lose @ hand2 handl win end end end match_game_count 1000 if 2 and ARGV 0 -m and ARGV 1 A 1-9 d match_game_count end do p if test d p p do file next if file A . next unless file .rb require p file end else require p end end do one two game one two match_game_count puts end You can use the engine with a command like the following Or you can point it at a directory and it will treat all the .rb files in there as Players players You can also change the match game count -m 10000 players Report erratum Quiz 10. Knight s Travails 25 Quiz 10 127 I Knight s Travails Posed by J E Bailey Given a standard 8x8 chessboard where each position is .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.