You are on page 1of 6

Decision Algorithm for Pool Using Fuzzy System

S.C.Chua 1

W.C.Tan2

E.K.Wong 3

V.C.Koo4

Faculty of Engineering & Technology


Multimedia University, Jalan Ayer Keroh Lama, 75450 Bukit Beruang, Melaka, Malaysia
Tel: +60-06-252-3007, Fax: +60-06-231-6552, E-mail: scchua@mmu.edu.my
2
Faculty of Engineering & Technology
Multimedia University, Jalan Ayer Keroh Lama, 75450 Bukit Beruang, Melaka, Malaysia
Tel: +60-06-252-3007, Fax: +60-06-231-6552, E-mail: wctan@mmu.edu.my
3

Faculty of Engineering & Technology


Multimedia University, Jalan Ayer Keroh Lama, 75450 Bukit Beruang, Melaka, Malaysia
Tel: +60-06-252-3251, Fax: +60-06-231-6552, E-mail: ekwong@mmu.edu.my
4

Faculty of Engineering & Technology


Multimedia University, Jalan Ayer Keroh Lama, 75450 Bukit Beruang, Melaka, Malaysia
Tel: +60-06-252-3004, Fax: +60-06-231-6552, E-mail: vckoo@mmu.edu.my

Abstract

computers and augmented reality has been demonstrated to


enhance the game of billiards [4].

A decision algorithm using the concept of fuzzy logic is


proposed in determining strategic shots in a game of pool.
Each possible shot on the board is ranked in order to
determine the level of difficulty based on two distance
parameters and an angle parameter. The set of parameters in
the fuzzy system can be tuned to suit the specific playing style
(or players behavior) on the choice of the maneuver
undertaken. The algorithm has been demonstrated on
computer generated pool environments and results have
shown acceptable trajectories based on a players choice.

Billiards is a game played by two players with cues and balls


on a long table covered with green cloth (it is also refer to cue
sports). It is a game which require precise geometry and
strategy. The physics of the balls, cue and table together with
the human interactions have made it an interesting model to
implement an intelligent strategy-based automated system. In
order to realize such a system, vision system, image
extractions, geometry analysis, trajectory planning, pattern
recognition, modeling and actuator system are among the
various considerations and techniques which are needed to
complete the automation process.

Keywords: Fuzzy system, Trajectory Planning, Robotics

This paper describes a decision algorithm to decide on a


maneuver, that is, which ball to sink into which pocket in a
game of pool (a specific type of billiards). This would be the
part of trajectory planning of an automated system. If given
an input image of a pool game situation from the vision
system, the easiest (or best) shot to sink a ball is to be
computed. This would involve a selection from a set of balls
with different locations and relevant paths, which the relevant
balls should follow to the pocket (or pockets). Computer
generated pool environments would be used as the input
before going on to the used of images from the real world.
This is due to the fact that ball locations, pocket locations,
colors and ball-type are known parameters in computer
generated world, therefore releasing the hefty processing
which needs to be carry out on the raw input image from the
vision system. In the game of pool, there are two types of
balls which each player would be playing: solid (the entire
ball is one color) and stripe (the ball has white top and
bottom, with a colored stripe painted around the middle).

1 Introduction
Game playing has a long and distinguished history in
mankind and if not by far the most suitable leisure activity.
Over times, humans have made it possible to simulate games
in virtual environments and even automate system of games.
The integration of real and virtual environments of games
made it possible to organize, plan and even improve the game
accuracy since the virtual world provide the freedom for
constraints and precision of the digital world. Researches
have been carried out to promote intelligent robotics research
in area of mobile robot, i.e. robot soccer [1] [2]. As of recent
years, virtual reality has made it even possible to generate a
totally synthetic environment for game [3]. Another potential
area of development in game playing is in billiards. Wearable

1 =2

(2a)

d co1 =d op2

(2b)

2.1 Estimating Difficulty of A Shot

d co2 =d op1

(2c)

In order to estimate the difficulty of a shot on the board, there


are three parameters of great interest: the distance traveled by
the cue ball before the collision with the object ball, d co, the
distance from the collided cue ball to the pocket, d op , and the
angle between the line joining both the mentioned distances,
, as shown in Figure 1.

then for both cases would be the same. This shows the
deficiency of this mathematical formula for such a situation.
In practice, the difficulty is small if d co is large and d op is
small, but not if d co is small and d op is large. Thus by relying
on the use of mathematical formula to evaluate the difficulty
of a shot is not really the best way. In the next section, fuzzy
logic principle is applied to this problem.

2 Approach and Methods

cue
object 1
d co

d co1

cue

d co2

d op1
pocket 1

d op
object

pocket

Figure 1 Conventional Geometry System

pocket 2

If 90o , the shot is infeasible and it should be rejected. This


is due to the fact that at such a condition, an attempt to sink
the object using a direct shot into the pocket is never possible.
A common solution to the problem of estimating the
difficulty of the shot is to have a mathematical formula that
expresses an output as a function of the inputs. Theoretically,
the formula would represent an accurate model of the game
behavior. An approximate difficulty function [5], is assigned
as

d co d op b
cos
2

90 o < 180 o

object 2
d op 2

(1)

to the shot. The factor b depends on the value of the ball: it is


largest for yellow and smallest for the black (in snooker). One
might easily guess that b=1 for pool game since there is no
rules to which ball to sink before another except for the black
which shall be sink only after the player has sink all his balls
on the board.
If the cue ball, object ball, and pocket lie in a straight line
(easiest kind of shot), =180o and cos2 =1. The difficulty of
the shot is then proportional to the two path lengths. If90o ,
then cos0, then is large. This is appropriate, because it
correspond to a shot in which the cue ball just grazes the
object ball, and such shots are hard to play accurately.
By looking at the situation given in Figure 2 and using the
revised for pool (with b=1), if

Figure 2 Geometry Configurations for Two Object Balls


2.2 Estimating Difficulty Using Fuzzy Logic

cue

d co

object

d op
pocket

Figure 3 Modified Geometry System


In this fuzzy logic approach, d co, d op and are redefined. This
is just an approximation made to simplify the geometry
problem. d co will now be the length between the cue ball and
object ball, d op will be the length between the object ball and
the pocket, and will be the angle between the mentioned
lengths as shown in Figure 3. These 3 parameters will serve
as inputs to the fuzzy system. Three fuzzy sets are defined for
each of the inputs. Mapping is done for d co, d op , and for all
its fuzzy set to a set of rules. The rules follow the common
sense behavior of the game. As such, these rules can be

altered to suit to different players behavior (beginner, intermediate, or advance), by changing the level of difficulty (D
Difficult, ND Not Difficult, VD Very Difficult, NA Not
Relevant: such combination does not exist) based on the
combination of fuzzy sets (or combination of shot). This is
shown in Table 1. In the previous section, it is shown that the
evaluation of failed for a situation in Figure 2 with
conditions given in Equation 2. In the approach using fuzzy
logic principle, each combination of shot is given a level of
difficulty (as defined above). Therefore, the situation
encountered earlier will certainly give a different (in
existing approach, is the difficulty function. In fuzzy logic
approach, it is the output of the rule evaluation).

(b)

Table 1 Rules Evaluation for Fuzzy System.


is easy
d co

near
average
far

near
ND
ND
ND

d op
average
D
D
D

far
VD
VD
NA

(a)
is medium
d co

near
average
far

d op
near
ND
ND
D

average
D
D
VD

far
VD
VD
NA

(b)
is hard
d co

near
average
far

d op
near
D
D
VD

average
VD
VD
VD

far
VD
VD
NA

(c)
Figure 4 shows the plot of each of the membership functions
for the inputs. The reason behind the use of Gaussian
Membership Function is the narrow peak which give a
relatively high degree of membership within an acceptable
limit, and also gradual fall after the limit.

(c)
Figure 4 - Input membership functions for (a) cue ball to
object ball length (cm), (b) object ball to pocket length (cm),
and (c) the angle (degree) joining both lengths
Fuzzy inference that is employed is the Sugeno-type with
constant output membership functions. This is sufficient to
the needs in this research. Furthermore, in terms of coding, it
is definitely easier to be done. Sugeno-type inference also
enhances the efficiency of the defuzzification process as one
only need to compute the weighted average.
2.3 Decision Algorithm
The decision algorithm employs the concept of fuzzy logic at
its final stage to get the difficulty of each shot. The best shot
is the easiest shot to sink the object ball into the pocket, and it
is chosen from the fuzzy outputs. In general, the decision
algorithm is shown in Figure 5.
2.4 Computing Relevant Paths
For each shot, a determination of whether a clear path to
target ball from cue ball (center to center) exist for a direct
shot. If the ball must travel from A to B and that there is a ball
at C, (refer to Figure 6)
From the cosine rule, it can be shown that

(a)

u = b cos A =

b2 + c2 a2
2c

(3a)

v = a cos B =

a2 + c2 b2
2c

(3b)

then,

h = b2 u 2 = a2 v2

(4)

Ball C do not obstruct the path between A and B if h is more


than the ball diameter. In the actual situation, the clear path
depends on the point at which the cue ball collides with the
object ball. Hence, this consideration is taken into account.

3 Simulation and Results


Computer simulated environments were tested with the
decision algorithm. The output from the algorithm is based on
the rules in Table 1. Here, the playing area is of size 160x70
(cm2 ), ball radius of 1.75 cm and pocket radius of 4 cm.
Appropriate scaling would need to be done if standard pool
table and balls are to be simulated.
Some priori information are: cue ball (white), 8-ball (black),
ball number 1-7 (solid), ball number 9-15 (stripe). Few sets of
virtual data are tested. One such situation is shown in Table 2.
The graphical layout of the board is shown in Figure 7.

START
Table 2 Computer Simulated Data (a) Ball locations on the
boards (b) Fixed Pockets Location

Generate locations
for balls

Ball
Cue
1
2
3
4
5
6
7

Compute possible
shot and relevant
paths
For each possible
shot and path,
compute difficulty
(Fuzzy System)

Location (x,y)
(59,44)
(114,48)
(15,32)
(71,25)
(26,47)
(111,50)
(77,39)
(21,32)

Ball
8
9
10
11
12
13
14
15

Location (x,y)
(114,61)
(44,19)
(137,17)
(128,62)
(38,18)
(10,7)
(102,14)
(134,13)

(a)
Pocket
1
2
3
4
5
6

Find the best shot


from the set of fuzzy
outputs
END

Location (x,y)
(0,0)
(80,0)
(160,0)
(0,70)
(80,70)
(160,70)
(b)

Figure 5 - Decision Algorithm for Pool

C
b

Table 3 Results from the decision algorithm for (a) solid


player (b) stripe player. The best shot (in bold italic) is
ranked 1, which the difficulty value is the least from the set of
shots.

c
A

Figure 6 - Obstacle in a Path

The best shot to be chosen depends on the ball-type the


current player is playing. The opponent, on the other hand,
would have the opposite type (stripe if the current player is
solid, and vice versa). Table 3 shows the results for both solid
and stripe player following the data on Table 2.

Solid
{Ball, Pocket}

d co

d op

Difficulty

Rank

{3,2}
{4,4}
{6,2}
{7,1}
{8,3}

22.4722
33.1361
18.6815
39.8497
57.5674

26.5707
34.7131
39.1152
38.2753
76.4003

167.5232
143.6980
109.9228
140.8005
109.8440

0.1419
0.2148
0.5322
0.2503
0.7659

1
2
4
3
5

(a)

Stripe
{Ball, Pocket}

d co

d op

Difficulty

Rank

{13,1}
{14,3}
{14,6}

61.400.
52.4309
52.4309

12.2066
59.6657
80.6226

177.9355
158.6679
101.1026

0.0641
0.4076
0.8812

1
2
3

(b)
Figure 8 shows the set of possible shot for solid and stripe
player.

4 Discussion
This paper has shown that, the decision making of sinking a
ball from a set of pool balls on the board can be simulated
using the concept of fuzzy logic. The fuzzy system is able to
choose from a set of relevant paths, the easiest shot to sink a
ball. Also, the fuzzy rules can be changed to suit the players
preference and ability. This flexibility provides a practical,
inexpensive solution. All that is really needed is a practical
understanding of the overall game behavior.
Further research is currently investigating combination shots
and indirect shots (via a cushion) by the cue ball. Again,
fuzzy logic is proposed to be used.

6 Acknowledgements
Thanks to Prof. Peter Grogono from Department of Computer
Science, Concordia University, for sharing his work on
snooker (The Snooker Simulator and Mathematics for
Snooker Simulation), to make this research on pool possible.

References
[1]

Thomas Braunl. Dec. 1999. Research Relevance of


Mobile Robot Competitions. IEEE Robotics &
Automation Magazine: 32-37.

[2]

Hiroaki Kitano, Minoru Asada, Itsuki Noda and


Hitoshi Matsubara. Sept. 1998. RoboCup: Robot
World Cup. IEEE Robotics & Automation Magazine:
30-36.
Daniel G. Aliaga. Virtual Objects in the Real World.
Communications of the ACM (CACM), Vol.40. No.3:
49-54.,Mar. 1997.
Tony Jebara, Cyrus Eyster, Josh Weaver, Thad
Starner
and
Alex
Pentland.
"Stochasticks:
Augmenting
the
Billiards
Experience
with
Probabilistic Vision and Wearable Computers". In
Proceedings of the International Symposium on
Wearable
Computers:
138-145,
Cambridge,
Massachusetts, October 1997.
Peter Grogono. Jan. 1996. Mathematics for Snooker
Simulation. Unpublished.

[3]

[4]

5 Conclusions
A decision algorithm for pool playing has been tested
possible in choosing appropriate shot given a set of players
priorities in sinking the balls (rules). The algorithm has been
demonstrated on computer generated pool environments and
results have shown acceptable trajectories based on a players
choice. Results presented in this paper also demonstrate that
virtual environment of simulation is capable of scaling to the
real world situation.

[5]

Figure 7 - Layout of the Board (Playing Area: Lower left (0,0), Upper right (160,70))

(a)

(b)
Figure 8- A set of possible shot for (a) solid player (b) stripe player, of which the best shot is chosen

You might also like