generated from CogitoNTNU/README-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix.: correct RandomAgent so it makes random moves
- Loading branch information
1 parent
b6d4826
commit 46fbda3
Showing
1 changed file
with
7 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
from src.agents.agent import Agent | ||
from src.game.board import Board | ||
from src.game.board import Action, Board, get_all_actions | ||
|
||
from random import choice | ||
|
||
from random import random | ||
|
||
class RandomAgent(Agent): | ||
"""Random agent that selects a random move from the list of possible moves""" | ||
|
||
def result(board: Board) -> Board: | ||
possible_moves = board.getPossibleMoves() | ||
move = random.choice(possible_moves) | ||
return board.makeMove(move) | ||
def result(self, board: Board) -> Action: | ||
possible_moves = get_all_actions() | ||
move = choice(possible_moves) | ||
return move |