Skip to content

Commit

Permalink
Try to fix renderer by removing unicode characters (#287)
Browse files Browse the repository at this point in the history
* try to fix renderer by removing unicode characters

* bump version
  • Loading branch information
bovard authored Oct 9, 2024
1 parent aaf3fba commit 1fa929e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion kaggle_environments/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from .main import http_request
from . import errors

__version__ = "1.15.0"
__version__ = "1.15.1"

__all__ = ["Agent", "environments", "errors", "evaluate", "http_request",
"make", "register", "utils", "__version__",
Expand Down
14 changes: 8 additions & 6 deletions kaggle_environments/envs/chess/chess.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ async function renderer(context) {
const {
environment,
frame,
height = 400,
height = 800,
parent,
step,
width = 400,
width = 1200,
} = context;

// Common Dimensions.
const maxWidth = 1200;
const maxHeight = 800;
const canvasSize = Math.min(height, width);
const boardSize = canvasSize * 0.8;
const squareSize = boardSize / 8;
Expand All @@ -23,8 +25,8 @@ async function renderer(context) {

// Canvas setup and reset.
let c = canvas.getContext("2d");
canvas.width = canvasSize;
canvas.height = canvasSize;
canvas.width = Math.min(maxWidth, width);
canvas.height = Math.min(maxHeight, height);
c.clearRect(0, 0, canvas.width, canvas.height);  

// Draw the Chessboard
Expand Down Expand Up @@ -61,8 +63,8 @@ async function renderer(context) {
const pieceCode = color === 'w' ? type.toUpperCase() : type.toLowerCase();
// Unicode characters for chess pieces
const pieceSymbols = {
'P': '', 'R': '', 'N': '', 'B': '', 'Q': '', 'K': '',
'p': '', 'r': '', 'n': '', 'b': '', 'q': '', 'k': '',
'P': 'P', 'R': 'R', 'N': 'N', 'B': 'B', 'Q': 'Q', 'K': 'K',
'p': 'p', 'r': 'r', 'n': 'n', 'b': 'b', 'q': 'q', 'k': 'k',
};

c.font = `${size * .8}px Arial`;
Expand Down

0 comments on commit 1fa929e

Please sign in to comment.