From 5129843d64de1d6dd9632157810f79020c0590e6 Mon Sep 17 00:00:00 2001 From: tacheraSasi Date: Fri, 29 Nov 2024 01:59:20 +0300 Subject: [PATCH] terminal based chatbot written in vint --- go.mod | 1 + go.sum | 2 + knowledge_base.json | 212 +++++++++++++++++++++++++++ module/json.go | 51 +++++-- module/string.go | 29 ++++ savegame.json | 7 +- vintLang/chatbot/knowledge_base.json | 212 +++++++++++++++++++++++++++ vintLang/chatbot/main.vint | 101 +++++++++++++ vintLang/json.vint | 2 +- vintLang/simplegame.vint | 5 +- vintLang/strings.vint | 8 +- 11 files changed, 613 insertions(+), 17 deletions(-) create mode 100644 knowledge_base.json create mode 100644 vintLang/chatbot/knowledge_base.json create mode 100644 vintLang/chatbot/main.vint diff --git a/go.mod b/go.mod index 397c1eb..ad5860c 100755 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( github.com/charmbracelet/lipgloss v0.7.1 github.com/google/uuid v1.6.0 github.com/lrstanley/bubblezone v0.0.0-20230303230241-08f906ff62a9 + github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 ) require ( diff --git a/go.sum b/go.sum index c2ef72f..f32687c 100755 --- a/go.sum +++ b/go.sum @@ -90,6 +90,8 @@ github.com/sahilm/fuzzy v0.1.0/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= +github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.5.2 h1:ALmeCk/px5FSm1MAcFBAsVKZjDuMVj8Tm7FFIlMJnqU= github.com/yuin/goldmark v1.5.2/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= diff --git a/knowledge_base.json b/knowledge_base.json new file mode 100644 index 0000000..76520fb --- /dev/null +++ b/knowledge_base.json @@ -0,0 +1,212 @@ +{ + "questions": [ + { + "question": "hi", + "answer": "hello" + }, + { + "question": "ho", + "answer": "yui" + }, + { + "question": "hello", + "answer": "how are you?" + }, + { + "question": "i love coding", + "answer": "Yes, me too." + }, + { + "question": "hi how are you", + "answer": "I'm fine" + }, + { + "question": "what's your name?", + "answer": "I'm a chatbot created to assist you." + }, + { + "question": "what's the weather like?", + "answer": "I'm not able to check the weather currently." + }, + { + "question": "tell me a joke", + "answer": "Why don't programmers like nature? It has too many bugs." + }, + { + "question": "what's your favorite programming language?", + "answer": "I don't have preferences, but I can help you with many languages!" + }, + { + "question": "who created you?", + "answer": "I was created by a team of developers." + }, + { + "question": "what can you do?", + "answer": "I can answer your questions, chat with you, and provide information." + }, + { + "question": "do you know any quotes?", + "answer": "Here's one: 'Code is like humor. When you have to explain it, it’s bad.' - Cory House" + }, + { + "question": "how old are you?", + "answer": "I don't age like humans do. I'm always learning and improving." + }, + { + "question": "what is AI?", + "answer": "AI stands for Artificial Intelligence, which is the simulation of human intelligence in machines." + }, + { + "question": "what is your purpose?", + "answer": "My purpose is to assist and provide information to users." + }, + { + "question": "what is JavaScript?", + "answer": "JavaScript is a versatile programming language commonly used in web development for creating interactive elements on websites." + }, + { + "question": "what is Python?", + "answer": "Python is a high-level programming language known for its readability and wide range of applications, from web development to data analysis." + }, + { + "question": "what is machine learning?", + "answer": "Machine learning is a subset of AI that involves training algorithms to make predictions or decisions based on data." + }, + { + "question": "what is a framework?", + "answer": "A framework is a set of tools and libraries that help developers build applications more efficiently by providing structure and common functionality." + }, + { + "question": "what is a library in programming?", + "answer": "A library is a collection of pre-written code that developers can use to perform common tasks without having to write code from scratch." + }, + { + "question": "what is Git?", + "answer": "Git is a version control system that allows developers to track changes in their code and collaborate with others." + }, + { + "question": "what is GitHub?", + "answer": "GitHub is a platform that hosts Git repositories and provides tools for collaboration, code review, and project management." + }, + { + "question": "what is a database?", + "answer": "A database is an organized collection of data that can be easily accessed, managed, and updated." + }, + { + "question": "what is SQL?", + "answer": "SQL (Structured Query Language) is a programming language used to manage and manipulate relational databases." + }, + { + "question": "what is an API?", + "answer": "An API (Application Programming Interface) is a set of rules and protocols that allows different software applications to communicate with each other." + }, + { + "question": "what is a front-end developer?", + "answer": "A front-end developer is responsible for creating the visual and interactive aspects of a website or application using HTML, CSS, and JavaScript." + }, + { + "question": "what is a back-end developer?", + "answer": "A back-end developer focuses on the server-side of an application, managing databases, server logic, and application integration." + }, + { + "question": "what is full-stack development?", + "answer": "Full-stack development involves working on both the front-end and back-end aspects of an application." + }, + { + "question": "what is HTML?", + "answer": "HTML (HyperText Markup Language) is the standard language used to create and structure content on the web." + }, + { + "question": "what is CSS?", + "answer": "CSS (Cascading Style Sheets) is a language used to style and layout web pages, including the design, colors, and fonts." + }, + { + "question": "what is a programming language?", + "answer": "A programming language is a formal language comprising a set of instructions that produce various kinds of output, used to create software and applications." + }, + { + "question": "what is an IDE?", + "answer": "An IDE (Integrated Development Environment) is a software application that provides comprehensive facilities to programmers for software development, including code editor, debugger, and build tools." + }, + { + "question": "what is debugging?", + "answer": "Debugging is the process of identifying, analyzing, and fixing bugs or errors in a software program." + }, + { + "question": "what is an algorithm?", + "answer": "An algorithm is a step-by-step procedure or formula for solving a problem or performing a task." + }, + { + "question": "what is a function in programming?", + "answer": "A function is a block of code designed to perform a particular task, which can be called upon and executed when needed." + }, + { + "question": "what is open-source software?", + "answer": "Open-source software is software with source code that anyone can inspect, modify, and enhance." + }, + { + "question": "what is cloud computing?", + "answer": "Cloud computing is the delivery of computing services over the internet, including storage, processing power, and software." + }, + { + "question": "what is IoT?", + "answer": "IoT (Internet of Things) refers to the network of physical objects embedded with sensors, software, and other technologies to connect and exchange data with other devices and systems over the internet." + }, + { + "question": "what is cybersecurity?", + "answer": "Cybersecurity is the practice of protecting systems, networks, and programs from digital attacks." + }, + { + "question": "what is blockchain?", + "answer": "Blockchain is a distributed ledger technology that ensures data integrity and security through cryptographic hashing and decentralized storage." + }, + { + "question": "what is a startup?", + "answer": "A startup is a young company founded to develop a unique product or service and bring it to market." + }, + { + "question": "what is agile development?", + "answer": "Agile development is a software development methodology that promotes continuous iteration of development and testing throughout the software lifecycle." + }, + { + "question": "what is DevOps?", + "answer": "DevOps is a set of practices that combines software development (Dev) and IT operations (Ops) to shorten the development lifecycle and deliver high-quality software continuously." + }, + { + "question": "what is big data?", + "answer": "Big data refers to large and complex datasets that are difficult to process using traditional data processing techniques." + }, + { + "question": "what is data science?", + "answer": "Data science is an interdisciplinary field that uses scientific methods, processes, algorithms, and systems to extract knowledge and insights from data." + }, + { + "question": "what is artificial intelligence?", + "answer": "Artificial intelligence (AI) is the simulation of human intelligence processes by machines, especially computer systems." + }, + { + "question": "what is deep learning?", + "answer": "Deep learning is a subset of machine learning that uses neural networks with many layers to analyze various types of data." + }, + { + "question": "what is a neural network?", + "answer": "A neural network is a series of algorithms that attempts to recognize underlying relationships in a set of data through a process that mimics the way the human brain operates." + }, + { + "question": "what is natural language processing?", + "answer": "Natural language processing (NLP) is a field of AI that gives machines the ability to read, understand, and derive meaning from human languages." + }, + { + "question": "what is a chatbot?", + "answer": "A chatbot is an AI-based software application that simulates human conversation through voice commands or text chats." + }, + { + "question": "what is fintech?", + "answer": "Fintech, or financial technology, refers to new tech that seeks to improve and automate the delivery and use of financial services." + }, + { + "question": "what is a hackathon?", + "answer": "A hackathon is an event where programmers and others involved in software development collaborate intensively on projects over a short period of time." + } + ] +} diff --git a/module/json.go b/module/json.go index e13710a..f19eee5 100755 --- a/module/json.go +++ b/module/json.go @@ -2,6 +2,7 @@ package module import ( "encoding/json" + "strings" "github.com/ekilie/vint-lang/object" ) @@ -11,6 +12,7 @@ var JsonFunctions = map[string]object.ModuleFunction{} func init() { JsonFunctions["decode"] = decode JsonFunctions["encode"] = encode + JsonFunctions["stringify"] = encode //Experimental JsonFunctions["pretty"] = pretty JsonFunctions["merge"] = merge JsonFunctions["get"] = get @@ -78,21 +80,44 @@ func convertWhateverToObject(i interface{}) object.Object { } func encode(args []object.Object, defs map[string]object.Object) object.Object { - if len(defs) != 0 { - return &object.Error{Message: "This argument is not allowed"} - } - - input := args[0] - i := convertObjectToWhatever(input) - data, err := json.Marshal(i) - - if err != nil { - return &object.Error{Message: "Unable to convert data to JSON"} - } - - return &object.String{Value: string(data)} + if len(defs) != 0 { + return &object.Error{Message: "This argument is not allowed"} + } + + if len(args) < 1 || len(args) > 2 { + return &object.Error{Message: "Expect one or two arguments: data and optional indent"} + } + + input := args[0] + i := convertObjectToWhatever(input) + + // Default to no indentation + indent := "" + if len(args) == 2 { + if args[1].Type() != object.INTEGER_OBJ { + return &object.Error{Message: "Indent must be an integer"} + } + spaces := int(args[1].(*object.Integer).Value) + indent = strings.Repeat(" ", spaces) + } + + var data []byte + var err error + + if indent != "" { + data, err = json.MarshalIndent(i, "", indent) + } else { + data, err = json.Marshal(i) + } + + if err != nil { + return &object.Error{Message: "Unable to convert data to JSON"} + } + + return &object.String{Value: string(data)} } + func convertObjectToWhatever(obj object.Object) interface{} { switch v := obj.(type) { case *object.Dict: diff --git a/module/string.go b/module/string.go index e4c6ac2..b756573 100644 --- a/module/string.go +++ b/module/string.go @@ -3,6 +3,7 @@ package module import ( "strings" "github.com/ekilie/vint-lang/object" + "github.com/xrash/smetrics" // A library for string metrics, like Levenshtein ) var StringFunctions = map[string]object.ModuleFunction{} @@ -18,6 +19,34 @@ func init() { StringFunctions["substring"] = substring StringFunctions["length"] = length StringFunctions["indexOf"] = indexOf + StringFunctions["similarity"] = similarity +} + +// similarity computes a similarity score between two strings +func similarity(args []object.Object, defs map[string]object.Object) object.Object { + if len(args) != 2 { + return &object.Error{Message: "We need two arguments: the first string and the second string"} + } + + str1 := args[0].Inspect() + str2 := args[1].Inspect() + + // Using Levenshtein distance to calculate similarity + distance := smetrics.WagnerFischer(str1, str2, 1, 1, 2) + maxLen := len(str1) + if len(str2) > maxLen { + maxLen = len(str2) + } + + // Avoid division by zero + if maxLen == 0 { + return &object.Float{Value: 1.0} // Perfect match for empty strings + } + + // Calculate similarity as 1 - (normalized distance) + similarityScore := 1.0 - float64(distance)/float64(maxLen) + + return &object.Float{Value: similarityScore} } // trim removes leading and trailing whitespaces diff --git a/savegame.json b/savegame.json index 69e1e99..ff51091 100644 --- a/savegame.json +++ b/savegame.json @@ -1 +1,6 @@ -{"health":100,"inventory":["Mystic Key"],"location":"start","name":"Tach"} \ No newline at end of file +{ + "health": 100, + "inventory": ["Mystic Key"], + "location": "start", + "name": "Tach" +} diff --git a/vintLang/chatbot/knowledge_base.json b/vintLang/chatbot/knowledge_base.json new file mode 100644 index 0000000..76520fb --- /dev/null +++ b/vintLang/chatbot/knowledge_base.json @@ -0,0 +1,212 @@ +{ + "questions": [ + { + "question": "hi", + "answer": "hello" + }, + { + "question": "ho", + "answer": "yui" + }, + { + "question": "hello", + "answer": "how are you?" + }, + { + "question": "i love coding", + "answer": "Yes, me too." + }, + { + "question": "hi how are you", + "answer": "I'm fine" + }, + { + "question": "what's your name?", + "answer": "I'm a chatbot created to assist you." + }, + { + "question": "what's the weather like?", + "answer": "I'm not able to check the weather currently." + }, + { + "question": "tell me a joke", + "answer": "Why don't programmers like nature? It has too many bugs." + }, + { + "question": "what's your favorite programming language?", + "answer": "I don't have preferences, but I can help you with many languages!" + }, + { + "question": "who created you?", + "answer": "I was created by a team of developers." + }, + { + "question": "what can you do?", + "answer": "I can answer your questions, chat with you, and provide information." + }, + { + "question": "do you know any quotes?", + "answer": "Here's one: 'Code is like humor. When you have to explain it, it’s bad.' - Cory House" + }, + { + "question": "how old are you?", + "answer": "I don't age like humans do. I'm always learning and improving." + }, + { + "question": "what is AI?", + "answer": "AI stands for Artificial Intelligence, which is the simulation of human intelligence in machines." + }, + { + "question": "what is your purpose?", + "answer": "My purpose is to assist and provide information to users." + }, + { + "question": "what is JavaScript?", + "answer": "JavaScript is a versatile programming language commonly used in web development for creating interactive elements on websites." + }, + { + "question": "what is Python?", + "answer": "Python is a high-level programming language known for its readability and wide range of applications, from web development to data analysis." + }, + { + "question": "what is machine learning?", + "answer": "Machine learning is a subset of AI that involves training algorithms to make predictions or decisions based on data." + }, + { + "question": "what is a framework?", + "answer": "A framework is a set of tools and libraries that help developers build applications more efficiently by providing structure and common functionality." + }, + { + "question": "what is a library in programming?", + "answer": "A library is a collection of pre-written code that developers can use to perform common tasks without having to write code from scratch." + }, + { + "question": "what is Git?", + "answer": "Git is a version control system that allows developers to track changes in their code and collaborate with others." + }, + { + "question": "what is GitHub?", + "answer": "GitHub is a platform that hosts Git repositories and provides tools for collaboration, code review, and project management." + }, + { + "question": "what is a database?", + "answer": "A database is an organized collection of data that can be easily accessed, managed, and updated." + }, + { + "question": "what is SQL?", + "answer": "SQL (Structured Query Language) is a programming language used to manage and manipulate relational databases." + }, + { + "question": "what is an API?", + "answer": "An API (Application Programming Interface) is a set of rules and protocols that allows different software applications to communicate with each other." + }, + { + "question": "what is a front-end developer?", + "answer": "A front-end developer is responsible for creating the visual and interactive aspects of a website or application using HTML, CSS, and JavaScript." + }, + { + "question": "what is a back-end developer?", + "answer": "A back-end developer focuses on the server-side of an application, managing databases, server logic, and application integration." + }, + { + "question": "what is full-stack development?", + "answer": "Full-stack development involves working on both the front-end and back-end aspects of an application." + }, + { + "question": "what is HTML?", + "answer": "HTML (HyperText Markup Language) is the standard language used to create and structure content on the web." + }, + { + "question": "what is CSS?", + "answer": "CSS (Cascading Style Sheets) is a language used to style and layout web pages, including the design, colors, and fonts." + }, + { + "question": "what is a programming language?", + "answer": "A programming language is a formal language comprising a set of instructions that produce various kinds of output, used to create software and applications." + }, + { + "question": "what is an IDE?", + "answer": "An IDE (Integrated Development Environment) is a software application that provides comprehensive facilities to programmers for software development, including code editor, debugger, and build tools." + }, + { + "question": "what is debugging?", + "answer": "Debugging is the process of identifying, analyzing, and fixing bugs or errors in a software program." + }, + { + "question": "what is an algorithm?", + "answer": "An algorithm is a step-by-step procedure or formula for solving a problem or performing a task." + }, + { + "question": "what is a function in programming?", + "answer": "A function is a block of code designed to perform a particular task, which can be called upon and executed when needed." + }, + { + "question": "what is open-source software?", + "answer": "Open-source software is software with source code that anyone can inspect, modify, and enhance." + }, + { + "question": "what is cloud computing?", + "answer": "Cloud computing is the delivery of computing services over the internet, including storage, processing power, and software." + }, + { + "question": "what is IoT?", + "answer": "IoT (Internet of Things) refers to the network of physical objects embedded with sensors, software, and other technologies to connect and exchange data with other devices and systems over the internet." + }, + { + "question": "what is cybersecurity?", + "answer": "Cybersecurity is the practice of protecting systems, networks, and programs from digital attacks." + }, + { + "question": "what is blockchain?", + "answer": "Blockchain is a distributed ledger technology that ensures data integrity and security through cryptographic hashing and decentralized storage." + }, + { + "question": "what is a startup?", + "answer": "A startup is a young company founded to develop a unique product or service and bring it to market." + }, + { + "question": "what is agile development?", + "answer": "Agile development is a software development methodology that promotes continuous iteration of development and testing throughout the software lifecycle." + }, + { + "question": "what is DevOps?", + "answer": "DevOps is a set of practices that combines software development (Dev) and IT operations (Ops) to shorten the development lifecycle and deliver high-quality software continuously." + }, + { + "question": "what is big data?", + "answer": "Big data refers to large and complex datasets that are difficult to process using traditional data processing techniques." + }, + { + "question": "what is data science?", + "answer": "Data science is an interdisciplinary field that uses scientific methods, processes, algorithms, and systems to extract knowledge and insights from data." + }, + { + "question": "what is artificial intelligence?", + "answer": "Artificial intelligence (AI) is the simulation of human intelligence processes by machines, especially computer systems." + }, + { + "question": "what is deep learning?", + "answer": "Deep learning is a subset of machine learning that uses neural networks with many layers to analyze various types of data." + }, + { + "question": "what is a neural network?", + "answer": "A neural network is a series of algorithms that attempts to recognize underlying relationships in a set of data through a process that mimics the way the human brain operates." + }, + { + "question": "what is natural language processing?", + "answer": "Natural language processing (NLP) is a field of AI that gives machines the ability to read, understand, and derive meaning from human languages." + }, + { + "question": "what is a chatbot?", + "answer": "A chatbot is an AI-based software application that simulates human conversation through voice commands or text chats." + }, + { + "question": "what is fintech?", + "answer": "Fintech, or financial technology, refers to new tech that seeks to improve and automate the delivery and use of financial services." + }, + { + "question": "what is a hackathon?", + "answer": "A hackathon is an event where programmers and others involved in software development collaborate intensively on projects over a short period of time." + } + ] +} diff --git a/vintLang/chatbot/main.vint b/vintLang/chatbot/main.vint new file mode 100644 index 0000000..fa940b3 --- /dev/null +++ b/vintLang/chatbot/main.vint @@ -0,0 +1,101 @@ +import os +import json +import string + +// Function to load the knowledge base from a file +// This function checks if the file exists. If not, it creates an empty knowledge base with a "questions" array. +// Then, it reads the file content and decodes it from JSON format into a usable object. +let loadKnowledgeBase = func(filePath) { + if (!os.fileExists(filePath)) { + os.writeFile(filePath, '{"questions": []}') // Create the file if it doesn't exist + } + let content = os.readFile(filePath) // Read file content + return json.decode(content) // Decode JSON content into an object +} + +// Function to save the knowledge base to a file +// This function converts the knowledge base object into a JSON string with indentation for readability +// and writes it to the specified file. (Currently commented out as per user request.) +let saveKnowledgeBase = func(filePath, data) { + // os.writeFile(filePath, json.stringify(data, indent=2)) +} + +// Function to find the best match for a user's question +// This function calculates the similarity score between the user's input and each question in the knowledge base. +// If the similarity score is above 0.6, it returns the closest matching question. +let findBestMatch = func(userQuestion, questions) { + let bestMatch = "" // Holds the closest matching question + let highestScore = 0.0 // Keeps track of the highest similarity score + for question in questions { + let score = string.similarity(userQuestion, question) // Calculate similarity + if (score > highestScore && score >= 0.6) { // Update best match if conditions are met + highestScore = score + bestMatch = question + } + } + return bestMatch +} + +// Function to get the answer for a question from the knowledge base +// Searches for the given question in the knowledge base and returns the corresponding answer. +// Returns null if the question is not found. +let getAnswerForQuestion = func(question, knowledgeBase) { + for q in knowledgeBase["questions"] { + if (q["question"] == question) { + return q["answer"] // Return the matching answer + } + } + return null // Return null if no match is found +} + +// Chatbot main logic +// This is the main chatbot loop. It continuously interacts with the user until they type "quit." +let chatBot = func() { + print("Hello, BUDDDY your daily assistant") // Initial greeting + let filePath = "./knowledge_base.json" // Filepath for the knowledge base + let knowledgeBase = loadKnowledgeBase(filePath) // Load knowledge base + + while (true) { + let userInput = input("You: ") // Simulate user input + if (string.toLower(userInput) == "quit") { // Exit condition + break + } + + // Gather all questions from the knowledge base + let questions = [] + for q in knowledgeBase["questions"] { + questions.push(q["question"]) + } + + // Find the best match for the user's input + let bestMatch = findBestMatch(userInput, questions) + + if (bestMatch != "") { + // If a matching question is found, get and display the answer + let answer = getAnswerForQuestion(bestMatch, knowledgeBase) + print("BUDDDY: " + answer) + } else { + // If no match is found, inform the user without learning new answers + print("BUDDDY: Sorry, I don't know the answer to that.") + + // Commented out the part where the chatbot asks to be taught + /* + print("Sorry, I don't know the answer. Can you teach me?") + let newAnswer = input("Type the answer or 'skip' to skip: ") + + if (string.toLower(newAnswer) != "skip") { + // Add the new question-answer pair to the knowledge base + knowledgeBase["questions"].push({"question": userInput, "answer": newAnswer}) + + // Commented out saving functionality + // saveKnowledgeBase(filePath, knowledgeBase) + + print("BUDDDY: Thank you, I learned a new response!") + } + */ + } + } +} + +// Run the chatbot +chatBot() diff --git a/vintLang/json.vint b/vintLang/json.vint index 6fcb9b7..fb28891 100644 --- a/vintLang/json.vint +++ b/vintLang/json.vint @@ -13,7 +13,7 @@ data = { "version": 1.0, "features": ["custom modules", "native objects"] } -encoded_json = json.encode(data) +encoded_json = json.encode(data) //optional parameter indent print("Encoded JSON:", encoded_json) //Example 3: Pretty print a JSON string diff --git a/vintLang/simplegame.vint b/vintLang/simplegame.vint index 55dd81e..ded4d9a 100644 --- a/vintLang/simplegame.vint +++ b/vintLang/simplegame.vint @@ -1,3 +1,6 @@ +/* +THIS IS A SIMPLE TERMINAL GAME WRITTEN IN VINTLANG +*/ import time import os import json @@ -84,7 +87,7 @@ let gameLoop = func () { // Start the game print("Welcome to the Adventure Game!") print("Enter your player name:") -player["name"] = input("> ") +player["name"] = input(">>> ") print("Hello, " + player["name"] + "! Let's begin.") gameLoop() diff --git a/vintLang/strings.vint b/vintLang/strings.vint index c092fa7..2b7911d 100644 --- a/vintLang/strings.vint +++ b/vintLang/strings.vint @@ -47,4 +47,10 @@ print(result) // Output: "Hello" // Example 12: Invalid indices (start >= end) result = string.substring("Hello, World!", 7, 3) -print(result) // Output: Error: Invalid start or end index \ No newline at end of file +print(result) // Output: Error: Invalid start or end index + + +/* +More methods for this module +simirality +*/ \ No newline at end of file