using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Test
{
class Program
{
static void Main(string[] args)
{
// Create a new character
Character character = new Character("Michael", 100);
// Welcoming the user
Console.WriteLine("Welcome " + character.Name);
Console.WriteLine("");
// Calling the function to enabling the user to choose actions
character.Action();
}
}
class Character
{
// Variables for the character
public string Name { get; set; }
public int Health { get; set; }
public int Weapon { get; set; }
public int Armour { get; set; }
public int Gold { get; set; }
public int InventoryCapacity { get; set; }
public string[] Inventory = new string[5];
// Constructor for the character
public Character(string Name,
class AI:
def __init__(self, name, age):
self.name = name
self.age = age
def talk(self):
print("Hi I'm {}".format(self.name))
def walk(self):
print("I'm walking")
def grow(self, step):
self.age = self.age + step
def get_ai_age(self):
return self.age
def AI(question):
if question == 'hello':
return 'hello!'
elif question == 'goodbye':
return 'goodbye!'
else:
return 'I don't understand'
AI('hello')
Func<Item> LoseItem = () =>
{
if (playerInventory.Count == 0)
{
return null;
}
var index = random.Next(0, playerInventory.Count);
var item = playerInventory[index];
playerInventory.RemoveAt(index);
return item;
}
x = 4**2022-6*4**522+5*64**510-3*2**330-100
s = str(x)
print s.count('7')
// declare function
private void LosePlayerItems();
//call function
LosePlayerItems();
def f(x):
return (x-1)//7 + 1
def f2(n):
res = 0
while n > 0:
res += n % 7
n //= 7
return res
def f3(n, x=7):
res = 0
while n > 0:
res += n % x
n //= x
return res
private void OnPlayerInput(InputValue value) {
if (value.isPressed) {
if (value.device == InputDevice.Keyboard) {
if (value.key == KeyCode.Q) {
ThrowItem();
}
}
}
}
List<string> inventory = new List<string>();
inventory.Add("sword");
inventory.Add("shield");
inventory.Add("potion");
foreach (string item in inventory) {
Console.WriteLine(item);
}
def sevens(x):
count = 0
x = str(x)
for i in x:
if i == '7':
count += 1
return count
sevens(4**2022-6*4**522+5*64**510-3*2**330-100)
public List<InventoryItem> SortInventory(SortBy sortBy, SortOrder sortOrder)
{
List<InventoryItem> sortedList = new List<InventoryItem>();
switch (sortBy)
{
case SortBy.Name:
sortedList = _inventory.OrderBy(item => item.Name).ToList();
break;
case SortBy.Weight:
sortedList = _inventory.OrderBy(item => item.Weight).ToList();
break;
case SortBy.Value:
sortedList = _inventory.OrderBy(item => item.Value).ToList();
break;
case SortBy.Quantity:
sortedList = _inventory.OrderBy(item => item.Quantity).ToList();
break;
}
if (sortOrder == SortOrder.Descending)
{
sortedList.Reverse();
}
return sortedList;
}
public static class ItemsAtDeath
{
public static async Task LoseItemsAsync(IDeathEvent deathEvent)
{
var success = await deathEvent.TryGetPlayerAsync();
if (!success) return;
var player = deathEvent.Player;
await player.SendMessageAsync("You have died.");
await Task.Delay(TimeSpan.FromSeconds(10));
await player.SendMessageAsync("You have lost the following items:");
await Task.Delay(TimeSpan.FromSeconds(1));
await player.DropItemAsync(ItemId.ItemLargeMutantWorm, 1);
await player.DropItemAsync(ItemId.ItemMutationSerum, 1);
await player.DropItemAsync(ItemId.ItemSmallMutantWorm, 1);
await player.DropItemAsync(ItemId.ItemSmallMutantWorm, 1);
await player.DropItemAsync(ItemId.ItemSmallMutantWorm, 1);
await player.DropItemAsync(ItemId.ItemSmallMutantW
void DropItems()
{
foreach (var item in player.Items)
{
item.Drop();
}
}
public class Character
{
public string Name {get; set;}
public int HP {get; set;}
public int Attack {get; set;}
public int Defense {get; set;}
public int Speed {get; set;}
public int Luck {get; set;}
public void Walk()
{
//walk
}
public void Attack()
{
//attack
}
public void Inventory()
{
//inventory
}
public void Jump()
{
//jump
}
public Character(string name, int hp, int attack, int defense, int speed, int luck)
{
Name = name;
HP = hp;
Attack = attack;
Defense = defense;
Speed = speed;
Luck = luck;
}
}
def createCharacter(name, height, weight, skill):
code = 'name: {name}\nheight: {height}\nweight: {weight}\nskill: {skill}'.format(
name = name,
height = height,
weight = weight,
skill = skill
)
return code
createCharacter('Mr. X', 200, 100, 'programming')
public static Action Death() {
return () => {
player.items = null;
};
}
Death();
public void lostItems(int numItems)
{
Random rand = new Random();
int goldLost = rand.Next(0, numItems);
int itemsLost = rand.Next(0, numItems);
int xpLost = rand.Next(0, numItems);
int hpLost = rand.Next(0, numItems);
string message = "You lost: " + goldLost + " gold, " + itemsLost + " items, " + xpLost + " xp, and " + hpLost + " hp.";
Console.WriteLine(message);
}
def ai(question):
if question == "what's the time?":
return time.time()
elif question == "what's the date?":
return date.today()
elif question == "what's the temperature?":
return thermometer.read()
elif question == "what's the weather?":
return weather.read()
elif question == "what's my name?":
return "your name is {}".format(name)
else:
return "I don't understand"
# end of function ai
ai("what's the weather")
def count_sevens(x):
cnt = 0
for i in str(x):
if i == '7':
cnt += 1
return cnt
count_sevens(4**2022-6*4**522+5*64**510-3*2**330-100)
public delegate void InventorySlotDelegate(int player, int item);
public static InventorySlotDelegate addInventorySlotDelegate(InventorySlotDelegate delegate, InventorySlotDelegate toAdd)
{
return delegate += toAdd;
}
public static InventorySlotDelegate removeInventorySlotDelegate(InventorySlotDelegate delegate, InventorySlotDelegate toRemove)
{
return delegate -= toRemove;
}
def count_7(number):
base = 8
result = 0
while number > 0:
digit = number % base
if digit == 7:
result += 1
number = number // base
return result
x = 4 ** 2022 - 6 * 4 ** 522 + 5 * 64 ** 510 - 3 * 2 ** 330 - 100
def function():
x = str(x)
i = 0
for a in x:
if a == '7':
i += 1
return i
function()
public void walk()
{
//code
}
public void attack()
{
//code
}
public void inventory()
{
//code
}
public void jump()
{
//code
}
def generate_ai(name, favorite_color):
return {
'name': name,
'favorite_color': favorite_color,
'flavor_text': f'{name} is a {favorite_color} AI, and you should do what it says!'
}
void RemoveItem(Player player) {
for (int i=0; i < player.inventory.Length; i++) {
player.inventory[i] = 0;
}
}
def game_character_builder(
name,
race,
gender='female',
profession='paladin',
strength=16
):
print(f'{name} is a {gender} {race} {profession} with {strength} strength')
game_character_builder('Konrad', 'human', 'male', 'warrior', 20)
game_character_builder('Lili', 'elf', strength=10)
def encode(a):
return ord(a)
encode('A')
def is_it_true(anything):
if anything:
return "Yes, it's true"
else:
return "No, it's false"
is_it_true(True)
public string GenerateCode(string name)
{
string hash = "";
foreach (char character in name)
{
hash += character;
hash += (int)character;
}
return hash;
}
GenerateCode("Sophie")
public void player_loss()
{
random_loss = rand.Next(1, 5);
if (random_loss == 1)
{
inv.Remove_item("pistol");
}
else if (random_loss == 2)
{
inv.Remove_item("rifle");
}
else if (random_loss == 3)
{
inv.Remove_item("machete");
}
else if (random_loss == 4)
{
inv.Remove_item("ammo");
}
else if (random_loss == 5)
{
inv.Remove_item("medkit");
}
}
public static Inventory RemovePlayerItemsAtDeath(int deathRate)
{
var playerItems = new Inventory();
for (var i = 0; i < playerItems.Count; i++)
{
if (playerItems[i].ItemName != "health potion")
{
playerItems[i].Quantity -= deathRate;
}
}
return playerItems;
}
public static void AddRemoveItemOnQ(this Inventory inv, int slotNum)
{
Action onQ = null;
Action remove = null;
onQ = () =>
{
if (!Game1.player.CurrentTool.isHeavyHitter())
{
if (Game1.player.Items[slotNum] != null)
{
Game1.player.Items[slotNum].actionWhenBeingHeld(Game1.player);
Game1.player.Items[slotNum] = null;
Game1.playSound("coin");
}
Game1.onScreenKeyboard.Subscriber = null;
Game1.afterDialogues = null;
Game1.keyboardDispatcher.Subscriber = null;
Game1.player.canMove = true;
Game1.player.completelyStopAnimatingOrDoAction();
Game1.player.faceDirection(0);
Game1.player.FarmerSprite.StopAnimation();
return;
}
if (Game1.
from math import log
def f(x):
return int(log(x, 8)) + 1
def f1(x):
return x % 8
def f2(x):
return int(x / 8)
def g(x):
if x < 8:
return 0
else:
return g(f2(x)) + f1(x)
g(f(4**2022-6*4**522+5*64**510-3*2**330-100))
def func_7(a,b,c,d,e,f,g):
return (4**a-b*4**c+d*64**e-f*2**g-h)
func_7(2022,6,522,5,510,3,330,100)
delegate int Del(int i);
class Program
{
static void Main(string[] args)
{
Del del = delegate(int i) { return i / 2; };
int value = del(10);
Console.WriteLine($"{value}");
}
}
def simpleArtificialIntelligence(question):
if question == "What is the meaning of life?":
return 42
else:
return "I do not know"
simpleArtificialIntelligence("What is the meaning of life?")
string[] inventory = {"iron sword", "wood shield", "wood bow", "wood arrow", "potion", "potion", "potion"}
void SortInventory(string[] inventory)
{
Array.Sort(inventory);
}
SortInventory(inventory);
foreach(string item in inventory)
{
Console.WriteLine($"{item}");
}
def generate_code(charac_name, charac_class, charac_age, charac_sexe):
"""
Generate the code for the game character
"""
return charac_name + "-" + charac_class + "-" + charac_age + "-" + charac_sexe
public static string generateCode(string name, int age) {
return string.Format("{0}_{1}", name, age);
}