Đang chuẩn bị liên kết để tải về tài liệu:
Best of Ruby Quiz Pragmatic programmers phần 2

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

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.time s do handl @player1.choose hand2 @player2.choose @player1_name handl @player2_name hand2 .each do player hand unless rock paper scissors .include hand raise Invalid choice by player . end end hands hand1.to_s @player1 hand2.to_s @player2 choice s hands.keys.sort if choice s.size 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 0.5 @score2 0.5 @player1.result hand1 hand2 draw @player2.result hand2 hand1 draw end def win winner hand1 hand2 if winner @player1 @score1 1 @player1.result hand1 hand2 win Report erratum Quiz 9. Rock Paper Scissors 24 @player2.result hand2 handl lose else @score2 1 @player1.result hand1 hand2 lose @player2.result hand2 handl win end end end match_game_count 1000 if ARGV.size 2 and ARGV 0 -m and ARGV 1 A 1-9 d ARGV.shift match_game_count ARGV.shift.to_i end ARGV.each do p if test d p Dir.foreach p do file next if file A . next unless file .rb require File.join p file end else require p end end Player.each_pair do one two game Game.new one two game.play match_game_count puts game.results end You can use the engine with a command like the following rock_paper_scissors.rb jeg_paper_player.rb jeg_queue_player.rb Or you can point it at a directory and it will treat all the .rb files in there as Players rock_paper_scissors.rb players You can also change the match game count rock_paper_scissors.rb -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 .

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.