Sha256: 579eaa7c3f0539def1ed53aa522439460cb389b1ec2aa05754600520e8709821

Contents?: true

Size: 747 Bytes

Versions: 4

Compression:

Stored size: 747 Bytes

Contents

# encoding: UTF-8
require 'software_challenge_client'

class Client < ClientInterface
  attr_accessor :gamestate

  def initialize
    puts "Zufallsspieler erstellt."
  end

  # gets called, when it's your turn
  def getMove
    puts "Spielstand: #{self.gamestate.pointsForPlayer(self.gamestate.currentPlayer)} - #{self.gamestate.pointsForPlayer(self.gamestate.otherPlayer)}"
    mov = self.randomMove
    unless mov.nil?
      puts 'Zug gefunden: '
      puts mov.to_s
    end
    return mov
  end

  # choose a random move
  def randomMove
    possibleMoves = self.gamestate.getPossibleMoves
    if possibleMoves.length > 0
      return possibleMoves[SecureRandom.random_number(possibleMoves.length)]
    else
      return nil
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
software_challenge_client-0.1.5 example/client.rb
software_challenge_client-0.1.4 example/client.rb
software_challenge_client-0.1.3 example/client.rb
software_challenge_client-0.1.1 example/client.rb