• Ei tuloksia

AIsHockey—An Introduction

N/A
N/A
Info
Lataa
Protected

Academic year: 2022

Jaa "AIsHockey—An Introduction"

Copied!
19
0
0

Kokoteksti

(1)

AIsHockey—An Introduction

Jouni Smed 2002

jouni.smed@cs.utu.fi

http://staff.cs.utu.fi/staff/jouni.smed/

(2)

What is AIsHockey?

w simplified ice hockey

n IIHF rules: http://www.iihf.com/

n game engine checks goals, offsides, icings, interfering the goalie

n no penalties

w distributed system

n server = game engine

n client(s) = player AI(s)

w the challenge: implement a team of autonomous, real-time AIs

(3)

Client/server model

Player AI

Client

Player AI

Client

Player AI

Client

Player AI

Player AI

Player AI

Player AI

Server

Game engine

view server to clients: multicast

client to server: unicast

(4)

Game engine physics

w player: m = 75 kg, r = 0.35 m

w dash forwards or backwards (i.e., brake) w skates: friction depends on orientation w player can change heading to any angle

w shooting from an operating range (0.50 m) w keeping the puck (only goalies)

w communication (64 bit messages)

(5)

The player

0.35 m 0.50 m

heading in radians:

0: towards opponent’s end () π/2: to the right ()

-π/2: to the left () π: towards own end ()

(6)

Player symbols

goalkeeper left

defense

right defense right wing center

left wing

(7)

Implementing an AI

w package fi.utu.cs.hockey.ai

n inherit the class AI and implement the abstract method react()

n useful constant values in the class Constants

w package fi.utu.cs.hockey.net

n interface Communication defines the inputs and outputs

(8)

Methods 1 (3)

shoot(p)

keepPuck() 0.0 <= p <= 1.0

(9)

Methods 2 (3)

dash(p)

brake(p) 0.0 <= p <= 1.0

0.0 <= p <= 1.0

(10)

Methods 3 (3)

head(a)

say(m)

*#&*!

a = angle in radians

m = 64-bit long word

(11)

Assorted inputs

w doubledouble[] player(

boolean

boolean us, int

int p)

w doubledouble[] puck() w longlong[] messages(

boolean

boolean us)

w intint getPosition() w intint faceoff()

w booleanboolean

isGameStopped() w booleanboolean isIcing(

boolean

boolean us)

w booleanboolean isOffside(

boolean

boolean us) w intint score(

boolean

boolean us) w longlong time()

(12)

Constants

OUR_ENDBOARD OUR_GOAL_LINE OUR_BLUE_LINE THEIR_BLUE_LINE THEIR_GOAL_LINE THEIR_ENDBOARD

CENTER_LINE

OUR_ENDZONE_FACEOFF

OUR_NEUTRAL_ZONE_FACEOFF THEIR_ENDZONE_FACEOFF

THEIR_NEUTRAL_ZONE_FACEOFF

FACEOFF_LEFT FACEOFF_RIGHT FACEOFF_CENTER

CENTER_CIRCLE_RADIUS

FACEOFF_CIRCLE_RADIUS GOAL_WIDTH

GOAL_CREASE_RADIUS RINK_WIDTH

RINK_LENGTH

(13)

Example: MyAI.java

import

import fi.utu.cs.hockey.ai.*;

public

public classclass MyAI extendsextends AI implementsimplements Constants { public

public voidvoid react() { if

if (isPuckWithinReach()) {

head(headingTo(0.0, THEIR_GOAL_LINE));

brake(1.0);

shoot(0.4);

say(1L);

} elseelse {

dash(1.0);

head(headingTo(puck()));

} } }

(14)

Configuration files

SERVER_PORT 2345 INIT_PORT 3456

GROUP_ADDRESS 239.123.213.231 GROUP_PORT 4567

# only in a client

SERVER_ADDRESS 127.0.0.1

(15)

Team configuration in a client

TEAM DataCity Scientists HELMET 0x0022FF

JERSEY 0xFFFFFF

LEFT_WING MyAI 22 L. Uuseri CENTER MyAI 10 Visa Koivu

(16)

Installation and use 1 (2)

w Installation, either (a) or (b):

n (a) copy AIsHockey.jar into the JDK directory tree to the directory /jre/lib/ext/

n (b) leave AIsHockey.jar in the work directory

w Starting the server, either (a) or (b)

n (a) java Server <configuration file>

n (b) java –cp AIsHockey.jar;. Server

<configuration file>

(17)

Installation and use 2 (2)

w Starting a client, either (a) or (b)

n (a) java Client <configuration file>

n (b) java –cp AIsHockey.jar;. Client

<configuration file>

w Compiling an AI file, either (a) or (b)

n (a) javac <file>.java

n (b) javac -classpath AIsHockey.jar

<file>.java

(18)

How to run AIsHockey

(1) Start the server (2) Start the clients

(3) Wait until the players have joined the game (4) Start the game with a center spot faceoff

(5) When the game is over, shut down the server and the clients

(6) Goto 1

(19)

The small print

© 2002 Jouni Smed

This software is provided for educational and non-commercial use only.

Viittaukset

LIITTYVÄT TIEDOSTOT

Indeed, while strongly criticized by human rights organizations, the refugee deal with Turkey is seen by member states as one of the EU’s main foreign poli- cy achievements of

the UN Human Rights Council, the discordance be- tween the notion of negotiations and its restrictive definition in the Sámi Parliament Act not only creates conceptual

Yleisesti voidaan todeta, että muutokset taiteen kentällä ja taiteen instituutioissa ovat aina oh- janneet paljon myös nimeämistä koskevia käytäntöjä.. Lyhyitä teosten

„ theory: players know what kind of game world they want. „ reality: how to

We introduce a computer game platform, AIsHockey, which is based on the real-world game of ice hockey.. The plat- form allows us to implement and study autonomous, real- time

That is why the development of technology today is increasingly about automation, making equipment work (together) seamlessly, and whatever technology that cannot be automated is

Myös historian opetuksen osalta 2010-luvulla laaditut opetus- suunnitelmat sekä perusopetuksessa että lukiokoulutuksessa korostavat sisältötavoitteiden rinnalla sekä

In particular, in parts of the game tree which are reached according to the players' strategies the beliefs must be consistent with the strategies. Extensive game with