Sha256: 19acc7e1222dbbb1cfa2a65530c25964a96bb3f586fab1cb86d4b57c89443ce6

Contents?: true

Size: 694 Bytes

Versions: 6

Compression:

Stored size: 694 Bytes

Contents

# encoding: UTF-8
require 'software_challenge_client'

# This is an example of a client playing the game using the software challenge
# gem.
class Client < ClientInterface
  include Logging

  attr_accessor :gamestate

  def initialize(log_level)
    logger.level = log_level
    logger.info 'Einfacher Spieler wurde erstellt.'
  end

  # gets called, when it's your turn
  def move_requested
    logger.info "Spielstand: #{gamestate.points_for_player(gamestate.current_player)} - #{gamestate.points_for_player(gamestate.other_player)}"
    move = best_move
    logger.debug "Zug gefunden: #{move}" unless move.nil?
    move
  end

  def best_move
    gamestate.possible_moves.sample
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
software_challenge_client-19.1.0 example/client.rb
software_challenge_client-19.0.4 example/client.rb
software_challenge_client-19.0.3 example/client.rb
software_challenge_client-19.0.2 example/client.rb
software_challenge_client-19.0.1 example/client.rb
software_challenge_client-19.0.0 example/client.rb