• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegames API Reference
  • KDE Home
  • Contact Us
 

ksquares

  • sources
  • kde-4.14
  • kdegames
  • ksquares
  • src
aicontroller.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2006 by Matthew Williams <matt@milliams.com> *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  ***************************************************************************/
9 
10 #ifndef AICONTROLLER_H
11 #define AICONTROLLER_H
12 
13 #include <QList>
14 
15 namespace KSquares {enum Direction {HORIZONTAL, VERTICAL};}
16 
31 class aiController
32 {
33  public:
43  aiController(int newPlayerId, const QList<bool> &newLines, const QList<int> &newSquareOwners, int newWidth, int newHeight);
44 
45  ~aiController();
46 
55  int chooseLine() const;
62  QList<int> autoFill(int safeMovesLeft);
63 
64  protected:
68  QList<int> safeMoves() const;
74  QList<int> chooseLeastDamaging(const QList<int> &choiceList) const;
81  int countBorderLines(int squareIndex, const bool *linesList) const;
89  int countBorderLines(int *sidesOfSquare, int squareIndex, const bool *linesList) const;
95  QList<int> squaresFromLine(int lineIndex) const;
100  void linesFromSquare(int *sidesOfSquare, int squareIndex) const;
106  KSquares::Direction lineDirection(int lineIndex) const;
107 
109  QList<int> squareOwners;
111  int linesSize;
112  bool *lines;
114  int playerId;
116  int width;
118  int height;
119 };
120 
121 #endif // KSQUARES_H
aiController::linesFromSquare
void linesFromSquare(int *sidesOfSquare, int squareIndex) const
Definition: aicontroller.cpp:543
aiController::safeMoves
QList< int > safeMoves() const
Definition: aicontroller.cpp:152
KSquares::VERTICAL
Definition: aicontroller.h:15
KSquares::HORIZONTAL
Definition: aicontroller.h:15
aiController::lineDirection
KSquares::Direction lineDirection(int lineIndex) const
Definition: aicontroller.cpp:555
aiController::lines
bool * lines
Definition: aicontroller.h:112
aiController::squaresFromLine
QList< int > squaresFromLine(int lineIndex) const
Definition: aicontroller.cpp:515
aiController::~aiController
~aiController()
Definition: aicontroller.cpp:28
QList< bool >
aiController::height
int height
Height of the game board.
Definition: aicontroller.h:118
aiController::countBorderLines
int countBorderLines(int squareIndex, const bool *linesList) const
Definition: aicontroller.cpp:509
aiController
AI Controller for KSquares.
Definition: aicontroller.h:31
aiController::autoFill
QList< int > autoFill(int safeMovesLeft)
Finds lines that can be filled without causing squares to be surrounded by 3 lines as a result...
Definition: aicontroller.cpp:33
KSquares::Direction
Direction
Definition: aicontroller.h:15
aiController::width
int width
Width of the game board.
Definition: aicontroller.h:116
aiController::linesSize
int linesSize
List of which lines are complete.
Definition: aicontroller.h:111
aiController::squareOwners
QList< int > squareOwners
List of the owners of each square.
Definition: aicontroller.h:109
aiController::aiController
aiController(int newPlayerId, const QList< bool > &newLines, const QList< int > &newSquareOwners, int newWidth, int newHeight)
Create a new AI controller.
Definition: aicontroller.cpp:19
aiController::chooseLine
int chooseLine() const
Choses where to draw the line: Creates a list of all the squares which are surrounded by 3 lines and ...
Definition: aicontroller.cpp:59
aiController::chooseLeastDamaging
QList< int > chooseLeastDamaging(const QList< int > &choiceList) const
Definition: aicontroller.cpp:178
aiController::playerId
int playerId
The ID of the player this AI belongs to.
Definition: aicontroller.h:114
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

ksquares

Skip menu "ksquares"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegames API Reference

Skip menu "kdegames API Reference"
  • granatier
  • kapman
  • kblackbox
  • kgoldrunner
  • kigo
  • kmahjongg
  • KShisen
  • ksquares
  • libkdegames
  •   highscore
  •   libkdegamesprivate
  •     kgame
  • libkmahjongg
  • palapeli
  •   libpala

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal