After dynamic counting

I have little formal discrete math training, and I have a little problem. I am trying to write an agent who reads in a human game (arbitrary) ballat and scores a point so often. The agent must “lag behind” and “catch up” with everything so often that the human player considers that there is some competition. Then the agent must either win or lose (depending on the state) against the person.

I tried several different methods, including a random probabilistic loop (which failed terribly). I thought this problem required something like a Hidden Markov Model (HMM), but I'm not sure how to implement it (or even if this is the best approach).

I have a gist up, but again, this sucks.

I hope the function __main__gives some idea of ​​the purpose of this agent. It will be called in pygame.

+3
source share
2 answers

I think you can change your mind. You can use the simple probability of evaluating how often and by how many points the computer should “catch up”. In addition, you can calculate the difference between the computer score and the human score, and then pass this to the sigmoid function to give you the degree to which the computer score increases.

Illustrative Python:

#!/usr/bin/python
import random, math
human_score = 0
computer_score = 0
trials = 100
computer_ahead_factor = 5 # maximum amount of points the computer can be ahead by
computer_catchup_prob = 0.33 # probability of computer catching up
computer_ahead_prob = 0.5 # probability of computer being ahead of human
computer_advantage_count = 0
for i in xrange(trials):
    # Simulate player score increase.
    human_score += random.randint(0,5) # add an arbitrary random amount
    # Simulate computer lagging behind human, by calculating the probability of
    # computer jumping ahead based on proximity to the human score.
    score_diff = human_score - computer_score
    p = (math.atan(score_diff)/(math.pi/2.) + 1)/2.
    if random.random() < computer_ahead_prob:
        computer_score = human_score + random.randint(0,computer_ahead_factor)
    elif random.random() < computer_catchup_prob:
        computer_score += int(abs(score_diff)*p)
    # Display scores.
    print 'Human score:',human_score
    print 'Computer score:',computer_score
    computer_advantage_count += computer_score > human_score
print 'Effective computer advantage ratio: %.6f' % (computer_advantage_count/float(trials),)
+2
source

, , . , , .

, . , , . , . , , , .

- - , . , - , .

0

Source: https://habr.com/ru/post/1751707/


All Articles