WoldMor

Here is a description of the API interface of the WorldMor class with which work the gui part. This class is write in Cython and have C constructor. The values which are needed to be set are described below and their usage in class is described in Game logic.

WorldMor class C constructor parameters

  • rows - start size of the map
  • random_seed - seed for random generator, because C rand() is “hard” pseudo-random generator.
  • bullets_exponent, bullets_multiply, bullets_max_prob - Describe in map generator section in Game logic
  • health_exponent, health_multiply, health_max_prob - Describe in map generator section in Game logic
  • enemy_start_probability, enemy_distance_divider, enemy_max_prob - Describe in map generator section in Game logic
  • guns_exponent, guns_multiply, guns_max_prob - Describe in map generator section in Game logic
  • how_long_between_turn_ai - Time moments between the enemy step or shoot.
  • go_for_player_ai_prob, go_for_gun_ai_prob, go_for_health_ai_prob, go_for_bullets_ai_prob - Describe in enemies section in Game logic
  • view_range - View range of the player, how far the player sees the map and enemies and items.
  • check_range - This not base on Euclidean distance, but the check area is \(4 \cdot \text{check_range}^2\) with the player in the middle. In this area, the enemies do their steps.
  • how_far_see_ai - The view range of the enemies

WorldMor class

class worldmor.game.game.Worldmor

Game

do_one_time_moment()

The method does move or shoot at a given time, for the player and enemy. Flags set between time and actions are checked for creating move or shoot. Even in this step are make the AI actions.

down()

Set flag to want move down. In do_one_time_moment will be move done.

get_ai_how_far_see()

Returns the value of how many boxes your enemies see.

get_bullets()

Get bullets value from size(code) to number for represent and work.

get_direction()

Get direction value from size(code) to number for represent and work.

get_gun()

Get gun value from size(code) to number for represent and work.

get_health()

Get health value from size(code) to number for represent and work.

get_how_fast_ai_is()

Returns the value how many time moment wait ai for next action.

get_map()

Method for obtaining and creating a viewport from the map to be displayed. The center of map is always player.

Parameters:
  • row – number of rows to display
  • col – number of columns to display
Returns:

a part of global map with values

get_map_to_save()

Return map as numpy array for possibility save the game.

get_mid_col()

Return column position of start position.

get_mid_row()

Return row position of start position.

get_pos_col()

Return column position of player.

get_pos_row()

Return row position of player.

get_visible()

Get visible value from size(code) to number for represent and work.

left()

Set flag to want move left. In do_one_time_moment will be move done.

put_map_to_game()

Load game from numpy array set the game map. For correctly load game need set other flags as the position of player and start middle of the map (for the distance from the start are count the difficulty and levels set need be set.

right()

Set flag to want move right. In do_one_time_moment will be move done.

set_ai_how_far_see()

Set the value of how many boxes your enemies see.

set_how_fast_ai_is()

Set the value how many time moment wait ai for next action.

set_mid_col()

Set column position of start position.

set_mid_row()

Set row position of start position.

set_pos_col()

Set column position of player.

set_pos_row()

Set row position of player.

shoot()

Set shoot flag for wanting shoot in this time moment. Flag 1 for shoot before move and 2 for shoot after move.

to_bullets()

Convert bullets value to size(code) to save in map.

to_direction()

Convert direction value to size(code) to save in map.

to_gun()

Convert gun id value to size(code) to save in map.

to_health()

Convert health value to size(code) to save in map.

to_visible()

Convert visible value to size(code) to save in map.

up()

Set flag to want move up. In do_one_time_moment will be move done.

WorldMor constants

worldmor.constants.BULLETS_EXPONENT = 1.4

Constants for generate bullets on map, with a greater distance from the start, their numbers are greatly reduced.

According to the following formula (distance is Euclidean distance from start): p = min(BULLETS_MAX_PROB, (1/(distance^BULLETS_EXPONENT))*BULLETS_MULTIPLY) Constants bellow can be change to manage difficulty.

The exponent specifies how quickly the difficulty will deteriorate. The multiply constants do the linear scaling. The max specifies the maximum on the start. Avoid all neighbors are bullets.

worldmor.constants.BULLETS_MAX_PROB = 0.05

The mechanism of the effect of BULLETS_MAX_PROB on map generation is described in the BULLETS_EXPONENT comment.

worldmor.constants.BULLETS_MULTIPLY = 3

The mechanism of the effect of BULLETS_MULTIPLY on map generation is described in the BULLETS_EXPONENT comment.

worldmor.constants.CELL_SIZE = 70

Default cell size in grid.

worldmor.constants.CHECK_RANGE = 40

How far is do the game play. AI move, and do all checks

worldmor.constants.ENEMY_DISTANCE_DIVIDER = 10

The mechanism of the effect of ENEMY_DISTANCE_DIVIDER on map generation is described in the ENEMY_START_PROBABILITY comment.

worldmor.constants.ENEMY_MAX_PROB = 0.05

The mechanism of the effect of ENEMY_MAX_PROB on map generation is described in the ENEMY_START_PROBABILITY comment.

worldmor.constants.ENEMY_START_PROBABILITY = 0.01

Constants for generate enemy on map, with a greater distance from the start, their number increases.

According to the following formula (distance is Euclidean distance from start): p = min(ENEMY_MAX_PROB, ENEMY_START_PROBABILITY * (distance/ENEMY_DISTANCE_DIVIDER)) Constants bellow can be change to manage difficulty.

The distance divider uses to decrease the computed Euclidean distance from start to moderate difficulty increasing. The start probability constants add the scale to the valnted value. The max specifies the maximum. Avoid all fields are occupied by enemies.

worldmor.constants.GO_FOR_BULLETS_AI_PROB = 0.1

Probability of go for nearest bullets.

worldmor.constants.GO_FOR_GUN_AI_PROB = 0.05

Probability of go for nearest gun.

worldmor.constants.GO_FOR_HEALTH_AI_PROB = 0.9

Probability of go for nearest health.

worldmor.constants.GO_FOR_PLAYER_AI_PROB = 0.1

Probability of go for player. Select direction to player.

worldmor.constants.GUNS_EXPONENT = 1.4

Constants for generate guns on map, with a greater distance from the start, their numbers are greatly reduced.

According to the following formula (distance is Euclidean distance from start): p = min(GUNS_MAX_PROB, (1/(distance^GUNS_EXPONENT))*GUNS_MULTIPLY) Constants bellow can be change to manage difficulty.

The exponent specifies how quickly the difficulty will deteriorate. The multiply constants do the linear scaling. The max specifies the maximum on the start. Avoid all neighbors are guns.

worldmor.constants.GUNS_MAX_PROB = 0.01

The mechanism of the effect of GUNS_MAX_PROB on map generation is described in the GUNS_EXPONENT comment.

worldmor.constants.GUNS_MULTIPLY = 1

The mechanism of the effect of GUNS_MULTIPLY on map generation is described in the GUNS_EXPONENT comment.

worldmor.constants.HEALTH_EXPONENT = 1.4

Constants for generate healths on map, with a greater distance from the start, their numbers are greatly reduced.

According to the following formula (distance is Euclidean distance from start): p = min(HEALTH_MAX_PROB, (1/(distance^HEALTH_EXPONENT))*HEALTH_MULTIPLY) Constants bellow can be change to manage difficulty.

The exponent specifies how quickly the difficulty will deteriorate. The multiply constants do the linear scaling. The max specifies the maximum on the start. Avoid all neighbors are healths.

worldmor.constants.HEALTH_MAX_PROB = 0.01

The mechanism of the effect of HEALTH_MAX_PROB on map generation is described in the HEALTH_EXPONENT comment.

worldmor.constants.HEALTH_MULTIPLY = 1

The mechanism of the effect of HEALTH_MULTIPLY on map generation is described in the HEALTH_EXPONENT comment.

worldmor.constants.HOW_FAR_SEE_AI = 3

What is the view range of AI enemies. 1 easy the dont see far, but with the same as VIEW_RANGE it is hard.

worldmor.constants.HOW_LONG_BETWEEN_TURN_AI = 5

Haw fast will be the AI. Maximum is 9 for very slow and 0 for fast AI.

worldmor.constants.LEVEL_1_AI_FAST = 9

Time section between AI action for level 1. 0-9. 9 -> slow. 0 -> fast as possible.

worldmor.constants.LEVEL_1_AI_SIGHT = 2

View range of enemy on level 1

worldmor.constants.LEVEL_2_AI_FAST = 6

Time section between AI action for level 2. 0-9. 9 -> slow. 0 -> fast as possible.

worldmor.constants.LEVEL_2_AI_SIGHT = 4

View range of enemy on level 2

worldmor.constants.LEVEL_3_AI_FAST = 3

Time section between AI action for level 3. 0-9. 9 -> slow. 0 -> fast as possible.

worldmor.constants.LEVEL_3_AI_SIGHT = 6

View range of enemy on level 3

worldmor.constants.MAX_CELL_SIZE = 90

Minimum cell size in grid when zoom.

worldmor.constants.MIN_CELL_SIZE = 50

Minimum cell size in grid when zoom.

worldmor.constants.RENDER_RECT_SIZE = 700

Specifies how large the images from the SVG format will be rendered in pixels. Higher resolution may slow down the game.

worldmor.constants.START_GAME_TEXT = 'PRESS ENTER TO START'

Text show on start the game.

worldmor.constants.START_MAP_SIZE = 50

Initial map size. It does not matter much because the map is endless and can be moved freely.

worldmor.constants.TICK_TIME = 0.07

One tick in game. Discrete time. With low tick can simulate continual time theoretical.

worldmor.constants.VIEW_RANGE = 6

How far a character sees.

worldmor.constants.ZOOM_CELL_STEP = 2

One step when turn the mouse wheel.