Fix bugs in legal actions

This commit is contained in:
Daochen Zha 2021-05-30 09:22:28 -05:00
parent 767aeb13ec
commit f84b5a847f
2 changed files with 10 additions and 0 deletions

View File

@ -1,4 +1,6 @@
import os import os
import itertools
import torch import torch
import numpy as np import numpy as np
from heapq import nlargest from heapq import nlargest
@ -323,6 +325,9 @@ def _get_legal_card_play_actions(player_hand_cards, rival_move):
for m in moves: for m in moves:
m.sort() m.sort()
moves.sort()
moves = list(move for move,_ in itertools.groupby(moves))
return moves return moves
Card2Column = {'3': 0, '4': 1, '5': 2, '6': 3, '7': 4, '8': 5, '9': 6, 'T': 7, Card2Column = {'3': 0, '4': 1, '5': 2, '6': 3, '7': 4, '8': 5, '9': 6, 'T': 7,

View File

@ -1,3 +1,5 @@
import itertools
from flask import Flask, jsonify, request from flask import Flask, jsonify, request
from flask_cors import CORS from flask_cors import CORS
@ -237,6 +239,9 @@ def _get_legal_card_play_actions(player_hand_cards, rival_move):
for m in moves: for m in moves:
m.sort() m.sort()
moves.sort()
moves = list(move for move,_ in itertools.groupby(moves))
return moves return moves
if __name__ == '__main__': if __name__ == '__main__':