Commit 983d8e88 authored by Bruno Coudoin's avatar Bruno Coudoin

Yves created 2 new activities by changeing the erase one.

	Now we have a submenu in the computer menu to learn
	mouse move, simple and double click

	Laurent fixed connect4 activity. No more bug clicking on a full column.

	menu.c fixed to find boardicon in it's local board directory
parent aee015bf
2005-04-12 Bruno coudoin <bruno.coudoin@free.fr>
Yves created 2 new activities by changeing the erase one.
Now we have a submenu in the computer menu to learn
mouse move, simple and double click
Laurent fixed connect4 activity. No more bug clicking on a full column.
menu.c fixed to find boardicon in it's local board directory
* boards/Makefile.am:
* boards/boardicons/erase_clic.png:
* boards/boardicons/erase_double_clic.png:
* boards/erase.xml.in:
* boards/erase_clic.xml.in:
* boards/erase_double_clic.xml.in:
* boards/mouse.xml.in:
* docs/C/python.xml: added GNU Bonus
* po/POTFILES.in:
* src/boards/erase.c: (start_board), (end_board), (set_level),
(erase_next_level), (item_event):
* src/boards/menu.c: (menu_create_item):
* src/boards/py-mod-bonus.c: (python_gcompris_bonus_module_init):
* src/boards/python/algorithm.py:
* src/boards/python/connect4.py:
* src/boards/python/connect4p/minmax.py:
* src/boards/python/hexagon.py:
2005-04-11 Bruno coudoin <bruno.coudoin@free.fr>
* boards/sounds/sv/.cvsignore:
......
......@@ -34,6 +34,8 @@ xml_in_files = \
draw.xml.in \
enumerate.xml.in \
erase.xml.in \
erase_clic.xml.in \
erase_double_clic.xml.in \
experience.xml.in \
fifteen.xml.in \
followline.xml.in \
......@@ -56,6 +58,7 @@ xml_in_files = \
missing_letter.xml.in \
money.xml.in \
money_cents.xml.in \
mouse.xml.in \
paintings.xml.in \
paratrooper.xml.in \
planegame.xml.in \
......
......@@ -3,9 +3,10 @@
<Board
name="erase"
type="erase"
section="/computer/."
section="/computer/mouse/."
icon="boardicons/erase.png"
difficulty="1"
mode="normal"
author="Bruno Coudoin (bruno.coudoin@free.fr)"
boarddir="">
<_title>Move the mouse</_title>
......@@ -15,8 +16,7 @@
<_manual>
Move the mouse until all the blocks disappear.
</_manual>
<_credit>Animal pictures are taken from the Animal Photography Page of Ralf Schmode (http://schmode.net/)
Ralf has given gcompris the authorization to include his pictures. Thanks a lot Ralf.
<_credit>Animal pictures are taken from the Animal Photography Page of Ralf Schmode (http://schmode.net/) and from LE BERRE Daniel. They gave GCompris the authorization to include their pictures. Thanks a lot.
</_credit>
</Board>
</GCompris>
<?xml version="1.0" encoding="UTF-8"?>
<GCompris>
<Board
name="erase_clic"
type="erase"
section="/computer/mouse/."
icon="boardicons/erase_clic.png"
difficulty="1"
mode="clic"
author="Bruno Coudoin (bruno.coudoin@free.fr)"
boarddir="">
<_title>Clic with the mouse</_title>
<_description>Clic with the mouse to erase the area and discover the background</_description>
<_prerequisite>Mouse manipulation</_prerequisite>
<_goal>Motor coordination</_goal>
<_manual>
Clic on rectangles with the mouse until all the blocks disappear.
</_manual>
<_credit>Animal pictures are taken from the Animal Photography Page of Ralf Schmode (http://schmode.net/)
Ralf has given gcompris the authorization to include his pictures. Thanks a lot Ralf.
</_credit>
</Board>
</GCompris>
<?xml version="1.0" encoding="UTF-8"?>
<GCompris>
<Board
name="erase_double_clic"
type="erase"
section="/computer/mouse/."
icon="boardicons/erase_double_clic.png"
difficulty="2"
mode="double_clic"
author="Bruno Coudoin (bruno.coudoin@free.fr)"
boarddir="">
<_title>Double-clic with the mouse</_title>
<_description>Double-Clic with the mouse to erase the area and discover the background</_description>
<_prerequisite>Mouse manipulation</_prerequisite>
<_goal>Motor coordination</_goal>
<_manual>
Double clic on rectangles with the mouse until all the blocks disappear.
</_manual>
<_credit>Animal pictures are taken from the Animal Photography Page of Ralf Schmode (http://schmode.net/)
Ralf has given gcompris the authorization to include his pictures. Thanks a lot Ralf.
</_credit>
</Board>
</GCompris>
<?xml version="1.0" encoding="UTF-8"?>
<GCompris>
<Board
name="mouse"
type="menu"
section="/computer/mouse"
icon="boardicons/erase.png"
author="">
<_title>Mouse manipulation boards</_title>
<_description>Left-Click with the mouse to select an activity</_description>
</Board>
</GCompris>
......@@ -643,6 +643,8 @@ attribute is readeable and/or writable.</para>
<entry>BONUS_FLOWER</entry></row>
<row><entry>gcompris.bonus.TUX</entry>
<entry>BONUS_TUX</entry></row>
<row><entry>gcompris.bonus.GNU</entry>
<entry>BONUS_TUX</entry></row>
<row><entry>gcompris.bonus.LAST</entry>
<entry>BONUS_LAST</entry></row>
</tbody>
......
......@@ -71,6 +71,8 @@ boards/doubleentry/board3_0.xml.in
boards/draw.xml.in
boards/enumerate.xml.in
boards/erase.xml.in
boards/erase_click.xml.in
boards/erase_double_click.xml.in
boards/experience.xml.in
boards/followline.xml.in
boards/fifteen.xml.in
......@@ -108,6 +110,7 @@ boards/missing_letter.xml.in
boards/missing_letter/board1.xml.in
boards/money.xml.in
boards/money_cents.xml.in
boards/mouse.xml.in
boards/paintings.xml.in
boards/paintings/board1_0.xml.in
boards/paintings/board2_0.xml.in
......
......@@ -49,6 +49,11 @@ static int number_of_item_y = 0;
static gint timer_id = 0;
// Default Double clic distance to restore on exit.
gint DefaultDoubleClicDistance;
gint DoubleClicLevel[6]= { 1000, 750, 500, 400, 250, 150};
// List of images to use in the game
static gchar *imageList[] =
{
......@@ -135,6 +140,23 @@ static void start_board (GcomprisBoard *agcomprisBoard)
gcomprisBoard->number_of_sublevel=1; /* Go to next level after this number of 'play' */
gcompris_bar_set(GCOMPRIS_BAR_LEVEL);
if (strcmp(gcomprisBoard->mode,"double_clic")==0){
GtkSettings *DefaultsGtkSettings = gtk_settings_get_default ();
if (DefaultsGtkSettings == NULL) {
g_warning(_("Couldn't get GTK settings"));
} else {
g_object_get(G_OBJECT(DefaultsGtkSettings),
"gtk-double-click-time", &DefaultDoubleClicDistance, NULL);
g_warning(_("Double clic default value %d."),DefaultDoubleClicDistance);
}
gdk_display_set_double_click_time( gdk_display_get_default(),
DoubleClicLevel[gcomprisBoard->level-1]);
g_warning(_("Double clic value is now %d."),DoubleClicLevel[gcomprisBoard->level-1]);
}
erase_next_level();
gamewon = FALSE;
......@@ -144,6 +166,11 @@ static void start_board (GcomprisBoard *agcomprisBoard)
/* ======================================= */
static void end_board ()
{
if (strcmp(gcomprisBoard->mode,"double_clic")==0){
gdk_display_set_double_click_time( gdk_display_get_default(),
DefaultDoubleClicDistance);
g_warning(_("Double clic value is now %d."),DefaultDoubleClicDistance);
}
if(gcomprisBoard!=NULL)
{
pause_board(TRUE);
......@@ -162,6 +189,13 @@ static void set_level (guint level)
gcomprisBoard->sublevel=1;
erase_next_level();
}
if (strcmp(gcomprisBoard->mode,"double_clic")==0){
gdk_display_set_double_click_time( gdk_display_get_default(),
DoubleClicLevel[gcomprisBoard->level-1]);
g_warning(_("Double clic value is now %d."),DoubleClicLevel[gcomprisBoard->level-1]);
}
}
/* ======================================= */
static gboolean is_our_board (GcomprisBoard *gcomprisBoard)
......@@ -194,12 +228,17 @@ static void erase_next_level()
gamewon = FALSE;
/* Select level difficulty */
number_of_item_x = ((gcomprisBoard->level+1)%2+1)*5;
number_of_item_y = ((gcomprisBoard->level+1)%2+1)*5;
if (strcmp(gcomprisBoard->mode,"double_clic")==0){
number_of_item_x = 5;
number_of_item_y = 5;
} else {
number_of_item_x = ((gcomprisBoard->level+1)%2+1)*5;
number_of_item_y = ((gcomprisBoard->level+1)%2+1)*5;
}
/* Try the next level */
erase_create_item(gnome_canvas_root(gcomprisBoard->canvas));
}
erase_create_item(gnome_canvas_root(gcomprisBoard->canvas));}
/* ==================================== */
/* Destroy all the items */
static void erase_destroy_all_items()
......@@ -289,42 +328,71 @@ item_event(GnomeCanvasItem *item, GdkEvent *event, gpointer data)
if(board_paused)
return FALSE;
if(event->type!=GDK_ENTER_NOTIFY)
return FALSE;
state = (GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (item), "state")));
if(gcomprisBoard->level>2)
{
if(!state)
{
gnome_canvas_item_set(item,
"fill_color_rgba", gcompris_skin_get_color("erase/rectangle in2"),
"outline_color_rgba", gcompris_skin_get_color("erase/rectangle out2"),
NULL);
state++;
gtk_object_set_data(GTK_OBJECT(item),"state", GINT_TO_POINTER(state));
return FALSE;
}
if(gcomprisBoard->level>4) {
if(state==1)
{
if (strcmp(gcomprisBoard->mode,"normal")==0)
if (event->type != GDK_ENTER_NOTIFY)
return FALSE;
if (strcmp(gcomprisBoard->mode,"clic")==0)
if (event->type != GDK_BUTTON_PRESS)
return FALSE;
if (strcmp(gcomprisBoard->mode,"double_clic")==0)
if ((event->type != GDK_BUTTON_PRESS) &
(event->type != GDK_2BUTTON_PRESS) &
(event->type != GDK_BUTTON_RELEASE))
return FALSE;
if (strcmp(gcomprisBoard->mode,"double_clic")!=0){
state = (GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (item), "state")));
if(gcomprisBoard->level>2)
{
if(!state)
{
gnome_canvas_item_set(item,
"fill_color_rgba", gcompris_skin_get_color("erase/rectangle in2"),
"outline_color_rgba", gcompris_skin_get_color("erase/rectangle out2"),
NULL);
state++;
gtk_object_set_data(GTK_OBJECT(item),"state", GINT_TO_POINTER(state));
gnome_canvas_item_set(item,
"fill_color_rgba", gcompris_skin_get_color("erase/rectangle in3"),
"outline_color_rgba", NULL,
NULL);
return FALSE;
}
if(gcomprisBoard->level>4) {
if(state==1)
{
state++;
gtk_object_set_data(GTK_OBJECT(item),"state", GINT_TO_POINTER(state));
gnome_canvas_item_set(item,
"fill_color_rgba", gcompris_skin_get_color("erase/rectangle in3"),
"outline_color_rgba", NULL,
NULL);
return FALSE;
}
}
}
}
else {
if (event->type == GDK_BUTTON_PRESS){
gnome_canvas_item_set(item,
"fill_color_rgba", gcompris_skin_get_color("erase/rectangle in2"),
"outline_color_rgba", gcompris_skin_get_color("erase/rectangle out2"),
NULL);
return FALSE;
}
if (event->type == GDK_BUTTON_RELEASE){
gnome_canvas_item_set(item,
"fill_color_rgba", gcompris_skin_get_color("erase/rectangle in"),
"outline_color_rgba", gcompris_skin_get_color("erase/rectangle out"),
NULL);
return FALSE;
}
}
gtk_object_destroy(GTK_OBJECT(item));
if(--number_of_item == 0)
{
gamewon = TRUE;
......
/* gcompris - menu.c
*
* Time-stamp: <2004/09/29 00:16:53 bcoudoin>
* Time-stamp: <2005/04/12 23:03:33 bruno>
*
* Copyright (C) 2000 Bruno Coudoin
*
......@@ -280,8 +280,19 @@ static void menu_create_item(GnomeCanvasGroup *parent, MenuItems *menuitems, Gco
GdkPixbuf *pixmap = NULL;
GnomeCanvasItem *item, *menu_button;
int difficulty;
gchar *tmp_board_dir;
/*
* Take care to load the board->icon_name from the dir specified
* in the board->board_dir
* To make it simple and reuse the gcompris_load_pixmap, we overwrite temporarily
* the gcomprisBoard->board_dir and board->board_dir
*/
tmp_board_dir = gcomprisBoard->board_dir;
gcomprisBoard->board_dir = board->board_dir;
menu_pixmap = gcompris_load_pixmap(board->icon_name);
gcomprisBoard->board_dir = tmp_board_dir;
next_spot();
menu_button = gnome_canvas_item_new (parent,
......
......@@ -65,6 +65,7 @@ void python_gcompris_bonus_module_init(void)
PyModule_AddIntConstant(module, "SMILEY", BONUS_SMILEY );
PyModule_AddIntConstant(module, "FLOWER", BONUS_FLOWER );
PyModule_AddIntConstant(module, "TUX", BONUS_TUX );
PyModule_AddIntConstant(module, "GNU", BONUS_GNU );
PyModule_AddIntConstant(module, "LAST", BONUS_LAST );
/* BonusFinishedList constants */
......
......@@ -60,6 +60,11 @@ class Gcompris_algorithm:
self.distance = 80
self.leftx = 90
# These are used to let us restart only after the bonus is displayed.
# When the bonus is displayed, it call us first with pause(1) and then with pause(0)
self.board_paused = 0;
self.gamewon = 0;
def start(self):
gcompris.bar_set (0)
gcompris.set_background(self.gcomprisBoard.canvas.root(),
......@@ -88,6 +93,24 @@ class Gcompris_algorithm:
def ok(self):
print("Gcompris_algorithm ok.")
# Called by gcompris core
def pause(self, pause):
self.board_paused = pause
# When the bonus is displayed, it call us first with pause(1) and then with pause(0)
# the game is won
if(pause == 0):
self.increment_level()
self.gamewon = 0
return
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
def cleanup(self):
# Remove the root item removes all the others inside it
......@@ -184,8 +207,8 @@ class Gcompris_algorithm:
self.paint_image(index, self.place, 147)
self.place +=1
if self.place == self.anzahl:
self.increment_level()
return
gcompris.bonus.display(gcompris.bonus.WIN, gcompris.bonus.TUX)
return
self.paint_qm ()
def increment_level(self):
......
......@@ -25,13 +25,6 @@
#TODO
#Correct bug when click out of board: done
#Reset board on level change: done
#After level 4 go back to level 1: done
#Anim coin when playing: done
#Hide tux after first round: done
#Enable click on coins: done
import gobject
import gnome
......@@ -46,7 +39,6 @@ import gtk.gdk
from gettext import gettext as _
import types
import thread
from connect4p import rules
from connect4p import human
from connect4p import minmax
......@@ -55,7 +47,7 @@ from connect4p import board
#
class Gcompris_connect4:
"""catch the ball"""
"""Connect 4 stones"""
def __init__(self, gcomprisBoard):
......@@ -64,15 +56,17 @@ class Gcompris_connect4:
def start(self):
print "Gcompris_connect4_start."
self.board_size = 490.0
self.boarditem = None
self.nb_columns = 7
self.nb_lines = 6
self.stone_size = 70.0
self.boardSize = 490.0
self.nbColumns = 7
self.nbLines = 6
self.stoneSize = 70.0
self.maxVictory = 3
self.maxLevel = 4
self.firstPlayer = False
self.winPlayers = []
self.timer_anim = 0
self.timer_machine = 0
self.boardItem = None
self.timerAnim = 0
self.timerMachine = 0
self.humanVictory = 0
self.machineHasPlayed = True
self.endAnimCallback = None
self.gcomprisBoard.level=1
......@@ -110,7 +104,7 @@ class Gcompris_connect4:
selector = self.rootitem.add(
gnome.canvas.CanvasPixbuf,
pixbuf = gcompris.utils.load_pixmap("connect4/grid.png"),
x=1+(gcompris.BOARD_WIDTH-self.board_size)/2,
x=1+(gcompris.BOARD_WIDTH-self.boardSize)/2,
y=1+50.0
)
......@@ -135,21 +129,25 @@ class Gcompris_connect4:
del self.tuxboatitem
del self.tuxboatanim
self.rootitem.destroy()
self.boarditem.destroy()
if self.timer_anim:
gtk.timeout_remove(self.timer_anim)
if self.timer_machine:
gtk.timeout_remove(self.timer_machine)
self.boardItem.destroy()
if self.timerAnim:
gtk.timeout_remove(self.timerAnim)
if self.timerMachine:
gtk.timeout_remove(self.timerMachine)
def ok(self):
print("Gcompris_connect4 ok.")
def repeat(self):
print("Gcompris_connect4 repeat.")
if self.winPlayers[-3:] == ['H', 'H', 'H']:
self.winPlayers = []
self.set_level(self.gcomprisBoard.level+1)
print("Gcompris_connect4 repeat.", self.humanVictory)
if self.humanVictory >= self.maxVictory:
if self.gcomprisBoard.level < self.maxLevel:
self.set_level(self.gcomprisBoard.level+1)
else:
print "Level max is reached!"
self.end()
gcompris.end_board()
else:
self.newGame()
......@@ -167,24 +165,24 @@ class Gcompris_connect4:
# Called by gcompris when the user click on the level icon
def set_level(self, level):
if level > 4: level = 1
if level > self.maxLevel: level = 1
self.gcomprisBoard.level=level
self.gcomprisBoard.sublevel=1
gcompris.bar_set_level(self.gcomprisBoard)
self.player1.setDifficulty(level)
self.player2.setDifficulty(level)
self.winPlayers = []
self.humanVictory = 0
self.newGame()
# End of Initialisation
# ---------------------
def newGame(self):
if self.boarditem != None:
self.boarditem.destroy()
self.boarditem = self.gcomprisBoard.canvas.root().add(
if self.boardItem != None:
self.boardItem.destroy()
self.boardItem = self.gcomprisBoard.canvas.root().add(
gnome.canvas.CanvasGroup,
x=(gcompris.BOARD_WIDTH-self.board_size)/2.0,
x=(gcompris.BOARD_WIDTH-self.boardSize)/2.0,
y=50.0
)
self.player1 = human.Human(self.gcomprisBoard.level)
......@@ -203,23 +201,21 @@ class Gcompris_connect4:
if event.type == gtk.gdk.BUTTON_PRESS:
print event.x, event.y
if event.button == 1 and self.gamewon == False and self.machineHasPlayed:
column = int((event.x - (gcompris.BOARD_WIDTH-self.board_size)/2.0) // self.stone_size)
column = int((event.x - (gcompris.BOARD_WIDTH-self.boardSize)/2.0) // self.stoneSize)
print "columnItemEvent", column
if not (column < 0 or column > (self.nb_columns-1)):
self.play(self.player1, 1, column)
if self.gamewon == False:
self.tuxboatitem.gnome_canvas.show()
gcompris.bar_hide(True)
#To improve the two timers
#self.timer_machine = gtk.timeout_add(2000, self.machinePlay)
self.endAnimCallback = self.machinePlay
self.machineHasPlayed = False
#thread.start_new_thread(self.machinePlay, ())
if not (column < 0 or column > (self.nbColumns-1)):
if self.play(self.player1, 1, column):
if self.gamewon == False:
self.tuxboatitem.gnome_canvas.show()
gcompris.bar_hide(True)
self.endAnimCallback = self.machinePlay
self.machineHasPlayed = False
return gtk.FALSE
def profItemEvent(self, widget, event, column):
if event.type == gtk.gdk.BUTTON_PRESS and self.firstPlayer == False:
#if event.type == gtk.gdk.BUTTON_PRESS and self.firstPlayer == False:
if event.type == gtk.gdk.BUTTON_PRESS:
self.firstPlayer = True
self.machinePlay()
......@@ -247,9 +243,11 @@ class Gcompris_connect4:
self.drawBoard(self.board)
self.winLine = rules.isWinner(self.board, numPlayer)
if self.winLine:
return self.winner(numPlayer)
self.winner(numPlayer)
elif rules.isBoardFull(self.board):
return self.winner(0)
self.winner(0)
return True
return False
def drawBoard(self, board):
stone = self.board.state[self.board.last_move][-1]
......@@ -257,54 +255,52 @@ class Gcompris_connect4:
y = len(self.board.state[self.board.last_move])-1
file = "connect4/stone_%d.png" % stone
self.stone = self.boarditem.add(
self.stone = self.boardItem.add(
gnome.canvas.CanvasPixbuf,
pixbuf = gcompris.utils.load_pixmap(file),
x=x*(self.board_size/self.nb_columns),
#y=(self.board_size/self.nb_columns)*(self.nb_lines-1-y)
x=x*(self.boardSize/self.nbColumns),
#y=(self.boardSize/self.nbColumns)*(self.nbLines-1-y)
y=0
)
self.stone.connect("event", self.columnItemEvent, 0)
self.countAnim = self.nb_lines-y
self.timer_anim = gtk.timeout_add(200, self.timerAnim)
self.countAnim = self.nbLines-y
self.timerAnim = gtk.timeout_add(200, self.animTimer)
def timerAnim(self):
print "timerAnim", self.countAnim
def animTimer(self):
self.countAnim -= 1
if self.countAnim > 0:
y= self.stone.get_property('y')
self.stone.set_property('y', y + (self.board_size/self.nb_columns))
self.timer_anim = gtk.timeout_add(200, self.timerAnim)
self.stone.set_property('y', y + (self.boardSize/self.nbColumns))
self.timerAnim = gtk.timeout_add(200, self.animTimer)
else:
if self.endAnimCallback:
self.endAnimCallback()
def winner(self, player):
self.gamewon = True
print 'The winner is:', player, 'line', self.winLine
if (player != 0):
if ((self.firstPlayer and (player==2)) or
((not self.firstPlayer) and (player==1))):
self.winPlayers.append('H')
else:
self.winPlayers.append('N')
points = ( self.winLine[0][0]*(self.board_size/self.nb_columns)+self.stone_size/2,
(self.board_size/self.nb_columns)*(self.nb_lines-1-self.winLine[0][1])+self.stone_size/2,
self.winLine[1][0]*(self.board_size/self.nb_columns)+self.stone_size/2,
(self.board_size/self.nb_columns)*(self.nb_lines-1-self.winLine[1][1])+self.stone_size/2
)
print 'The winner is:', player
if ((self.firstPlayer and (player==2)) or
((not self.firstPlayer) and (player==1))):
self.humanVictory += 1
else:
self.humanVictory = 0
points = ( self.winLine[0][0]*(self.boardSize/self.nbColumns)+self.stoneSize/2,
(self.boardSize/self.nbColumns)*(self.nbLines-1-self.winLine[0][1])+self.stoneSize/2,
self.winLine[1][0]*(self.boardSize/self.nbColumns)+self.stoneSize/2,
(self.boardSize/self.nbColumns)*(self.nbLines-1-self.winLine[1][1])+self.stoneSize/2
)
self.redLine = self.boarditem.add(
gnome.canvas.CanvasLine,
fill_color_rgba=0xFF0000FFL,
points=points,
width_pixels = 8
)
if player == 1:
gcompris.bonus.display(gcompris.bonus.WIN, gcompris.bonus.FLOWER)
else:
# player == 2
gcompris.bonus.display(gcompris.bonus.LOOSE, gcompris.bonus.FLOWER)
self.redLine = self.boardItem.add(
gnome.canvas.CanvasLine,
fill_color_rgba=0xFF0000FFL,
points=points,
width_pixels = 8
)
self.redLine.set_property("cap-style", gtk.gdk.CAP_ROUND)
if player == 1:
gcompris.bonus.display(gcompris.bonus.WIN, gcompris.bonus.FLOWER)
elif player == 2:
gcompris.bonus.display(gcompris.bonus.LOOSE, gcompris.bonus.FLOWER)
else:
gcompris.bonus.display(gcompris.bonus.DRAW, gcompris.bonus.FLOWER)
......@@ -86,10 +86,12 @@ class MinMax(Player):
list = []
for child in node.childs:
list.append(child.value)
if node.player == player:
if node.player != player:
node.value = min(list)
#print 'min =', node.value,
else:
node.value = max(list)
#print 'max =', node.value,
else:
node.value = self.score(node, player, opponent) / (depth + 1)
......@@ -133,10 +135,10 @@ class MinMax(Player):
for move in self.listMoves(node.board, current_player):
node.board.move(move, current_player)
node.childs.append(self.statespace(Node( node.board, move, player), depth+1, next_player, player, opponent))
node.childs.append(self.statespace(Node( node.board, move, next_player), depth+1, next_player, player, opponent))
node.board.undomove(move)