-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathstudent_agent.py
More file actions
49 lines (40 loc) · 1.86 KB
/
student_agent.py
File metadata and controls
49 lines (40 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Student agent: Add your own agent here
from agents.agent import Agent
from store import register_agent
import sys
import numpy as np
from copy import deepcopy
import time
from helpers import random_move, count_capture, execute_move, check_endgame, get_valid_moves
@register_agent("student_agent")
class StudentAgent(Agent):
"""
A class for your implementation. Feel free to use this class to
add any helper functionalities needed for your agent.
"""
def __init__(self):
super(StudentAgent, self).__init__()
self.name = "StudentAgent"
def step(self, chess_board, player, opponent):
"""
Implement the step function of your agent here.
You can use the following variables to access the chess board:
- chess_board: a numpy array of shape (board_size, board_size)
where 0 represents an empty spot, 1 represents Player 1's discs (Blue),
and 2 represents Player 2's discs (Brown).
- player: 1 if this agent is playing as Player 1 (Blue), or 2 if playing as Player 2 (Brown).
- opponent: 1 if the opponent is Player 1 (Blue), or 2 if the opponent is Player 2 (Brown).
You should return a tuple (r,c), where (r,c) is the position where your agent
wants to place the next disc. Use functions in helpers to determine valid moves
and more helpful tools.
Please check the sample implementation in agents/random_agent.py or agents/human_agent.py for more details.
"""
# Some simple code to help you with timing. Consider checking
# time_taken during your search and breaking with the best answer
# so far when it nears 2 seconds.
start_time = time.time()
time_taken = time.time() - start_time
print("My AI's turn took ", time_taken, "seconds.")
# Dummy return (you should replace this with your actual logic)
# Returning a random valid move as an example
return random_move(chess_board,player)