Acting natural
Closed this issue · 1 comments
The bot is very obvious when playing against, it never "looks" at cards or minions, and plays immediately when the turn starts.
I do not want opponents to know they are playing a bot, so I have started trying to work on a function that makes it "act natural" during its turn.
Python3
I run the function once a turn using the following code:
# Do the following only once per turn
global turn_counter
if scene['Self']['Resources'] not in turn_counter:
turn_counter.append(scene['Self']['Resources'])
print('Turn ' + str(scene['Self']['Resources']) + ' has started') # Debug
once_per_turn(scene)
def once_per_turn(scene):
act_natural(scene)
turn_counter
is reset to a value of [0]
every time the bot Mulligans, which denotes a new game.
It's not perfect, since using the coin on turn one makes it think that it is a new turn, and then turn two won't run the once_per_turn()
function.
Anyway, acting natural is done with the very simple:
def act_natural(scene):
# Pause for a bit so I don't look like a bot so much
sleep(random.randint(2, 6) * enemy_minion_count(scene)) # Wait longer if the enemy has more minions, as if thinking.
def enemy_minion_count(scene):
minion_count = 0
for minion in scene['Opponent']['Minions']:
minion_count += 1
return minion_count
And I am very unhappy with how it works. While waiting, the entire game freezes. The first time this happened I thought I had managed to crash Hearthstone.
What I need in order to make it better:
- A
wait
orpause
feature to allow the bot to take human-like time to think, without locking the game up. - A
hover
feature to tell the game to hover over certain cards, minions that the enemy just played, etc. This is probably the biggest issue the bot has with acting natural. - The ability to receive and/or respond to the "Greetings, Thanks, Wow" chat, for that human touch.
First I want to emphasize that the purpose of this project is AI researching (and not include Turing test).
So we don't need to make the bots human-like. And personally, I prefer we don't do that because doing that might jeopardize this project (someone might abuse this project).
But I respect all recommendations, so I will investigate the possibilities but with lower priority.
About the details...
wait or pause it's easy to let bots control the speed of actions and the intervals between the actions. I can add few parameters in the actions returned by bots.
hovering it could be implemented by a new type of action.
chat SAA, but chatting should also be available during opponent's turn, need much more work.