RL-- CONNECTX---kaggle

Introduction 

Connect Four is a game where two players alternate turns dropping colored discs into a vertical grid. Each player uses a different color (usually red or yellow), and the objective of the game is to be the first player to get four discs in a row.
 

import numpy as np

import random

from kaggle_environments import make,envaluate

#create the game environment 

env = make('connectx')

# TWO random agents play one game round

env.run([my_agent, 'random'])

# show the game

env.render(model='ipython')

The "random" agent selects (uniformly) at random from the set of valid moves. In Connect Four, a move is considered valid if there's still space in the column to place a disc (i.e., if the board has seven rows, the column has fewer than seven discs).

In the code cell below, this agent plays one game round against a copy of itself.

Defining agents

the agent is always implemented as a Python function that accepts two agrumwnts:obs and config

  1. obs : contains two pieces of information

      obs.board - the game board(a python list with one item for each grid location)
      obs.mark  - the piece

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值